Changeset 28983 in osm for applications/editors
- Timestamp:
- 2012-11-25T01:08:09+01:00 (12 years ago)
- Location:
- applications/editors/josm/plugins/wikipedia/src/org/wikipedia
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/WikipediaApp.java
r28506 r28983 65 65 } 66 66 67 static List<WikipediaEntry> getEntriesFromCategory(String wikipediaLang, String category ) {67 static List<WikipediaEntry> getEntriesFromCategory(String wikipediaLang, String category, int depth) { 68 68 try { 69 final String url = "http://toolserver.org/~daniel/WikiSense/CategoryIntersect.php?" 70 + "wikilang=" + wikipediaLang 71 + "&wikifam=.wikipedia.org" 72 + "&basecat=" + encodeURL(category) 73 + "&basedeep=3&templates=&mode=al&format=csv"; 69 final String url = "http://toolserver.org/~magnus/catscan_rewrite.php" 70 + "?project=wikipedia" 71 + "&ext_image_data=" 72 + "&file_usage_data=" 73 + "&show_redirects=no" 74 + "&format=tsv" 75 + "&doit=doit" 76 + "&depth=" + depth 77 + "&language=" + wikipediaLang 78 + "&categories=" + encodeURL(category); 74 79 System.out.println("Wikipedia: GET " + url); 75 final Scanner scanner = new Scanner(new URL(url).openStream() ).useDelimiter("\n");80 final Scanner scanner = new Scanner(new URL(url).openStream(), "UTF-8").useDelimiter("\n"); 76 81 final List<WikipediaEntry> entries = new ArrayList<WikipediaEntry>(); 82 { 83 // skip first two rows 84 final String header = scanner.next(); // |subset 85 if (!"|subset".equals(header.trim())) { 86 throw new RuntimeException("Wikipedia: Invalid header: " + header); 87 } 88 final String colspec = scanner.next(); //title id namespace len touched seen nstext 89 if (!colspec.startsWith("title")) { 90 throw new RuntimeException("Wikipedia: Invalid colspec: " + colspec); 91 } 92 } 77 93 while (scanner.hasNext()) { 78 // TODO ignore redirects 79 final String[] x = scanner.next().split("\t"); 80 if ("0".equals(x[0].trim())) { // denotes article 81 final String article = x[1].replace("_", " "); 82 entries.add(new WikipediaEntry(article, wikipediaLang, article)); 83 } 94 final String article = scanner.next().split("\t")[0].trim().replace("_", " "); 95 entries.add(new WikipediaEntry(article, wikipediaLang, article)); 84 96 } 85 97 return entries; … … 96 108 Map<String, Boolean> status = new HashMap<String, Boolean>(); 97 109 if (!articleNames.isEmpty()) { 98 final String url = "http://toolserver.org/~ simon04/getGeoJSON.php?action=check"110 final String url = "http://toolserver.org/~master/osmjson/getGeoJSON.php?action=check" 99 111 + "&lang=" + wikipediaLang; 100 112 System.out.println("Wikipedia: GET " + url); -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/WikipediaToggleDialog.java
r28485 r28983 145 145 return; 146 146 } 147 List<WikipediaEntry> entries = WikipediaApp.getEntriesFromCategory(wikipediaLang.get(), category); 147 List<WikipediaEntry> entries = WikipediaApp.getEntriesFromCategory( 148 wikipediaLang.get(), category, Main.pref.getInteger("wikipedia.depth", 3)); 148 149 setWikipediaEntries(entries); 149 150 setTitle(/* I18n: [language].Wikipedia.org: [category] */ tr("{0}.Wikipedia.org: {1}", wikipediaLang.get(), category));
Note:
See TracChangeset
for help on using the changeset viewer.