Changeset 11967 in josm for trunk/scripts
- Timestamp:
- 2017-04-21T23:10:21+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/scripts/SyncEditorLayerIndex.groovy
r11965 r11967 17 17 * Add option "-h" to show the available command line flags. 18 18 */ 19 import java.text.DecimalFormat 19 20 import javax.json.Json 20 21 import javax.json.JsonArray … … 48 49 */ 49 50 static main(def args) { 51 Locale.setDefault(Locale.ROOT); 50 52 parse_command_line_arguments(args) 51 53 def script = new SyncEditorLayerIndex() … … 196 198 } 197 199 200 String maininfo(def entry, String offset) { 201 String res = offset + "<type>${getType(entry)}</type>\n" 202 res += offset + "<url><![CDATA[${getUrl(entry)}]]></url>\n" 203 if(getType(entry) == "tms") { 204 if(getMinZoom(entry) != null) 205 res += offset + "<min-zoom>${getMinZoom(entry)}</min-zoom>\n" 206 if(getMaxZoom(entry) != null) 207 res += offset + "<max-zoom>${getMaxZoom(entry)}</max-zoom>\n" 208 } 209 return res 210 } 211 212 198 213 void printentries(def entries, def stream) { 214 DecimalFormat df = new DecimalFormat("#.#######") 215 df.setRoundingMode(java.math.RoundingMode.CEILING) 199 216 stream.write "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" 200 217 stream.write "<imagery xmlns=\"http://josm.openstreetmap.de/maps-1.0\">\n" … … 204 221 stream.write " <name>${getName(e)}</name>\n" 205 222 stream.write " <id>${getId(e)}</id>\n" 223 if(getDate(e) != "") 224 stream.write " <date>${getDate(e)}</date>\n" 225 stream.write maininfo(e, " ") 226 for (def m : getMirrors(e)) { 227 stream.write " <mirror>\n"+maininfo(m, " ")+" </mirror>\n" 228 } 206 229 def minlat = 1000 207 230 def minlon = 1000 … … 223 246 shapes += sep + " " 224 247 } 225 shapes += "<point lat='${ String.format(Locale.ROOT, "%.7f",lat)}' lon='${String.format(Locale.ROOT, "%.7f",lon)}'/>"248 shapes += "<point lat='${df.format(lat)}' lon='${df.format(lon)}'/>" 226 249 } 227 250 shapes += sep + "</shape>\n" 228 251 } 229 252 if(shapes) { 230 stream.write " <bounds min-lat='${ minlat}' min-lon='${minlon}' max-lat='${maxlat}' max-lon='${maxlon}'>\n"253 stream.write " <bounds min-lat='${df.format(minlat)}' min-lon='${df.format(minlon)}' max-lat='${df.format(maxlat)}' max-lon='${df.format(maxlon)}'>\n" 231 254 stream.write shapes + " </bounds>\n" 232 stream.write " </entry>\n"233 }255 } 256 stream.write " </entry>\n" 234 257 } 235 258 stream.write "</imagery>\n" … … 580 603 return e.get("properties").getString("name") 581 604 } 605 static List<Object> getMirrors(Object e) { 606 if (e instanceof ImageryInfo) return e.getMirrors() 607 return [] 608 } 582 609 static List<Shape> getShapes(Object e) { 583 610 if (e instanceof ImageryInfo) {
Note:
See TracChangeset
for help on using the changeset viewer.