Changeset 11412 in josm for trunk/scripts/SyncEditorImageryIndex.groovy
- Timestamp:
- 2016-12-22T18:03:12+01:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/scripts/SyncEditorImageryIndex.groovy
r11411 r11412 21 21 import javax.json.JsonObject 22 22 import javax.json.JsonReader 23 import javax.json.JsonValue 23 24 24 25 import org.openstreetmap.josm.data.imagery.ImageryInfo … … 34 35 def josmUrls = new HashMap<String, ImageryInfo>() 35 36 36 static String eiiInputFile = 'imagery. json'37 static String eiiInputFile = 'imagery.geojson' 37 38 static String josmInputFile = 'maps.xml' 38 39 static String ignoreInputFile = 'maps_ignores.txt' … … 174 175 FileReader fr = new FileReader(eiiInputFile) 175 176 JsonReader jr = Json.createReader(fr) 176 eiiEntries = jr.read Array()177 eiiEntries = jr.readObject().get("features") 177 178 jr.close() 178 179 … … 234 235 myprintln "*** URLs found in EII but not in JOSM (${l1.size()}): ***" 235 236 if (!l1.isEmpty()) { 236 for (def l : l1) 237 myprintln "-"+l 237 for (def l : l1) { 238 myprintln "-" + l 239 } 238 240 } 239 241 … … 243 245 myprintln "*** URLs found in JOSM but not in EII (${l2.size()}): ***" 244 246 if (!l2.isEmpty()) { 245 for (def l : l2) 247 for (def l : l2) { 246 248 myprintln "+" + l 249 } 247 250 } 248 251 } … … 368 371 static String getUrl(Object e) { 369 372 if (e instanceof ImageryInfo) return e.url 370 return e.get String("url")373 return e.get("properties").getString("url") 371 374 } 372 375 static String getName(Object e) { 373 376 if (e instanceof ImageryInfo) return e.getOriginalName() 374 return e.get String("name")377 return e.get("properties").getString("name") 375 378 } 376 379 static List<Shape> getShapes(Object e) { … … 382 385 return [] 383 386 } 384 def ex = e.get("extent")385 if(ex != null) {386 def poly = ex.get("polygon")387 if(poly != null) {387 if(!e.isNull("geometry")) { 388 def ex = e.get("geometry") 389 if(ex != null && !ex.isNull("coordinates")) { 390 def poly = ex.get("coordinates") 388 391 List<Shape> l = [] 389 392 for(def shapes: poly) { … … 406 409 static String getType(Object e) { 407 410 if (e instanceof ImageryInfo) return e.getImageryType().getTypeString() 408 return e.get String("type")411 return e.get("properties").getString("type") 409 412 } 410 413 static Integer getMinZoom(Object e) { … … 413 416 return mz == 0 ? null : mz 414 417 } else { 415 def ext = e.getJsonObject("extent") 416 if (ext == null) return null 417 def num = ext.getJsonNumber("min_zoom") 418 def num = e.get("properties").getJsonNumber("min_zoom") 418 419 if (num == null) return null 419 420 return num.intValue() … … 425 426 return mz == 0 ? null : mz 426 427 } else { 427 def ext = e.getJsonObject("extent") 428 if (ext == null) return null 429 def num = ext.getJsonNumber("max_zoom") 428 def num = e.get("properties").getJsonNumber("max_zoom") 430 429 if (num == null) return null 431 430 return num.intValue() … … 434 433 static String getCountryCode(Object e) { 435 434 if (e instanceof ImageryInfo) return "".equals(e.getCountryCode()) ? null : e.getCountryCode() 436 return e.get String("country_code", null)435 return e.get("properties").getString("country_code", null) 437 436 } 438 437 static String getQuality(Object e) { 439 438 //if (e instanceof ImageryInfo) return "".equals(e.getQuality()) ? null : e.getQuality() 440 439 if (e instanceof ImageryInfo) return null 441 return e.get(" best") ? "best" : null440 return e.get("properties").get("best") ? "best" : null 442 441 } 443 442 String getDescription(Object o) {
Note:
See TracChangeset
for help on using the changeset viewer.