Changeset 19137 in josm for trunk/scripts
- Timestamp:
- 2024-07-10T16:56:12+02:00 (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/scripts/SyncEditorLayerIndex.java
r19106 r19137 88 88 private List<ImageryInfo> josmEntries; 89 89 private JsonArray eliEntries; 90 private JsonArray idEntries; 91 private JsonArray rapidEntries; 90 92 91 93 private final Map<String, JsonObject> eliUrls = new HashMap<>(); 94 private final Map<String, JsonObject> idUrls = new HashMap<>(); 95 private final Map<String, JsonObject> rapidUrls = new HashMap<>(); 92 96 private final Map<String, ImageryInfo> josmUrls = new HashMap<>(); 93 97 private final Map<String, ImageryInfo> josmMirrors = new HashMap<>(); … … 96 100 97 101 private static String eliInputFile = "imagery_eli.geojson"; 102 private static String idInputFile = "imagery_id.geojson"; 103 private static String rapidInputFile = "imagery_rapid.geojson"; 98 104 private static String josmInputFile = "imagery_josm.imagery.xml"; 99 105 private static String ignoreInputFile = "imagery_josm.ignores.txt"; … … 136 142 } 137 143 script.loadELIEntries(); 144 script.loadELIUsers(); 138 145 if (optionEliXml != null) { 139 146 try (BufferedWriter writer = Files.newBufferedWriter(Paths.get(optionEliXml), UTF_8)) { … … 162 169 "-e,--eli_input <eli_input> Input file for the editor layer index (geojson). " + 163 170 "Default is imagery_eli.geojson (current directory).\n" + 171 "-d,--id_input <id_input> Input file for the id index (geojson). " + 172 "Default is imagery_id.geojson (current directory).\n" + 164 173 "-h,--help show this help\n" + 165 174 "-i,--ignore_input <ignore_input> Input file for the ignore list. Default is imagery_josm.ignores.txt (current directory).\n" + 166 175 "-j,--josm_input <josm_input> Input file for the JOSM imagery list (xml). " + 167 176 "Default is imagery_josm.imagery.xml (current directory).\n" + 168 "-m,--noeli don't show output for ELI problems\n" +177 "-m,--noeli don't show output for ELI, Rapid or iD problems\n" + 169 178 "-n,--noskip don't skip known entries\n" + 170 179 "-o,--output <output> Output file, - prints to stdout (default: -)\n" + 171 180 "-p,--elixml <elixml> ELI entries for use in JOSM as XML file (incomplete)\n" + 172 181 "-q,--josmxml <josmxml> JOSM entries reoutput as XML file (incomplete)\n" + 182 "-r,--rapid_input <rapid_input> Input file for the rapid index (geojson). " + 183 "Default is imagery_rapid.geojson (current directory).\n" + 173 184 "-s,--shorten shorten the output, so it is easier to read in a console window\n" + 174 185 "-x,--xhtmlbody create XHTML body for display in a web page\n" + … … 189 200 .addArgumentParameter("eli_input", OptionCount.OPTIONAL, x -> eliInputFile = x) 190 201 .addShortAlias("eli_input", "e") 202 .addArgumentParameter("id_input", OptionCount.OPTIONAL, x -> idInputFile = x) 203 .addShortAlias("id_input", "d") 204 .addArgumentParameter("rapid_input", OptionCount.OPTIONAL, x -> rapidInputFile = x) 205 .addShortAlias("rapid_input", "r") 191 206 .addArgumentParameter("josm_input", OptionCount.OPTIONAL, x -> josmInputFile = x) 192 207 .addShortAlias("josm_input", "j") … … 370 385 } 371 386 myprintln("*** Loaded "+eliEntries.size()+" entries (ELI). ***"); 387 } 388 void loadELIUsers() throws IOException { 389 try (JsonReader jr = Json.createReader(Files.newBufferedReader(Paths.get(idInputFile), UTF_8))) { 390 idEntries = jr.readArray(); 391 } 392 for (JsonValue e : idEntries) { 393 String url = getUrlStripped(e); 394 if (!eliUrls.containsKey(url)) 395 myprintln("+++ iD-URL not in ELI: "+url); 396 idUrls.put(url, e.asJsonObject()); 397 } 398 myprintln("*** Loaded "+idEntries.size()+" entries (iD). ***"); 399 try (JsonReader jr = Json.createReader(Files.newBufferedReader(Paths.get(rapidInputFile), UTF_8))) { 400 rapidEntries = jr.readArray(); 401 } 402 for (JsonValue e : rapidEntries) { 403 String url = getUrlStripped(e); 404 if (!eliUrls.containsKey(url)) 405 myprintln("+++ Rapid-URL not in ELI: "+url); 406 rapidUrls.put(url, e.asJsonObject()); 407 } 408 myprintln("*** Loaded "+rapidEntries.size()+" entries (Rapid). ***"); 372 409 } 373 410 … … 450 487 stream.write(" <icon>"+cdata(t)+"</icon>\n"); 451 488 for (Entry<String, String> d : getDescriptions(e).entrySet()) { 452 stream.write(" <description lang=\""+d.getKey()+"\">"+ d.getValue()+"</description>\n");489 stream.write(" <description lang=\""+d.getKey()+"\">"+cdata(d.getValue(), true)+"</description>\n"); 453 490 } 454 491 for (ImageryInfo m : getMirrors(e)) { … … 597 634 if (!le.isEmpty()) { 598 635 for (String l : le) { 599 myprintln("- " + getDescription(eliUrls.get(l))); 636 String e = ""; 637 if(idUrls.get(l) != null && rapidUrls.get(l) != null) 638 e = " **iD+Rapid**"; 639 else if(idUrls.get(l) != null) 640 e = " **iD**"; 641 else if(rapidUrls.get(l) != null) 642 e = " **Rapid**"; 643 myprintln("- " + getDescription(eliUrls.get(l)) + e); 600 644 } 601 645 } … … 1324 1368 static String getUrl(Object e) { 1325 1369 if (e instanceof ImageryInfo) return ((ImageryInfo) e).getUrl(); 1326 return ((Map<String, JsonObject>) e).get("properties").getString("url"); 1370 JsonObject p = ((Map<String, JsonObject>) e).get("properties"); 1371 if (p != null) 1372 return p.getString("url"); 1373 else 1374 return ((JsonObject)e).getString("template"); 1327 1375 } 1328 1376
Note:
See TracChangeset
for help on using the changeset viewer.