- Timestamp:
- 2017-04-21T11:54:35+02:00 (8 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/build.xml
r11963 r11964 702 702 <groovy src="scripts/SyncEditorLayerIndex.groovy" classpath="${dist.dir}/josm-custom.jar"> 703 703 <arg value="-noskip"/> 704 <arg value="-p"/> 705 <arg value="eli.imagery.xml"/> 706 <arg value="-q"/> 707 <arg value="josm.imagery.xml"/> 704 708 </groovy> 705 709 </target> -
trunk/scripts/SyncEditorLayerIndex.groovy
r11951 r11964 53 53 script.start() 54 54 script.loadJosmEntries() 55 if(options.josmxml) { 56 def file = new FileWriter(options.josmxml) 57 def stream = new BufferedWriter(file) 58 script.printentries(script.josmEntries, stream) 59 } 55 60 script.loadELIEntries() 61 if(options.elixml) { 62 def file = new FileWriter(options.elixml) 63 def stream = new BufferedWriter(file) 64 script.printentries(script.eliEntries, stream) 65 } 56 66 script.checkInOneButNotTheOther() 57 67 script.checkCommonEntries() … … 78 88 cli.x(longOpt:'xhtmlbody', argName:"xhtmlbody", "create XHTML body for display in a web page") 79 89 cli.X(longOpt:'xhtml', argName:"xhtml", "create XHTML for display in a web page") 90 cli.p(longOpt:'elixml', args:1, argName:"elixml", "ELI entries for use in JOSM as XML file (incomplete)") 91 cli.q(longOpt:'josmxml', args:1, argName:"josmxml", "JOSM entries reoutput as XML file (incomplete)") 80 92 cli.m(longOpt:'nomissingeli', argName:"nomissingeli", "don't show missing editor layer index entries") 81 93 cli.h(longOpt:'help', "show this help") … … 120 132 void myprintlnfinal(String s) { 121 133 if(outputStream != null) { 122 outputStream.write(s) ;123 outputStream.newLine() ;134 outputStream.write(s) 135 outputStream.newLine() 124 136 } else { 125 println s ;137 println s 126 138 } 127 139 } … … 135 147 } 136 148 if (!options.noskip) { 137 return ;149 return 138 150 } 139 151 } else if(options.xhtmlbody || options.xhtml) { … … 179 191 } 180 192 myprintln "*** Loaded ${eliEntries.size()} entries (ELI). ***" 193 } 194 195 void printentries(def entries, def stream) { 196 stream.write "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" 197 stream.write "<imagery xmlns=\"http://josm.openstreetmap.de/maps-1.0\">\n" 198 for (def e : entries) { 199 def best = "eli-best".equals(getQuality(e)) 200 stream.write " <entry"+(best ? " eli-best=\"true\"" : "" )+">\n" 201 stream.write " <name>${getName(e)}</name>\n" 202 stream.write " <id>${getId(e)}</id>\n" 203 def minlat = 1000 204 def minlon = 1000 205 def maxlat = -1000 206 def maxlon = -1000 207 def shapes = "" 208 def sep = "\n " 209 for(def s: getShapes(e)) { 210 shapes += " <shape>" 211 def i = 0 212 for(def p: s.getPoints()) { 213 def lat = p.getLat() 214 def lon = p.getLon() 215 if(lat > maxlat) maxlat = lat 216 if(lon > maxlon) maxlon = lon 217 if(lat < minlat) minlat = lat 218 if(lon < minlon) minlon = lon 219 if(!(i++%3)) { 220 shapes += sep + " " 221 } 222 shapes += "<point lat='${String.format(Locale.ROOT, "%.7f",lat)}' lon='${String.format(Locale.ROOT, "%.7f",lon)}'/>" 223 } 224 shapes += sep + "</shape>\n" 225 } 226 if(shapes) { 227 stream.write " <bounds min-lat='${minlat}' min-lon='${minlon}' max-lat='${maxlat}' max-lon='${maxlon}'>\n" 228 stream.write shapes + " </bounds>\n" 229 stream.write " </entry>\n" 230 } 231 } 232 stream.write "</imagery>\n" 233 stream.close() 181 234 } 182 235 … … 313 366 def jd = getDate(j) 314 367 // The forms 2015;- or -;2015 or 2015;2015 are handled equal to 2015 315 String ef = ed.replaceAll("\\A-;","").replaceAll(";-\\z","").replaceAll("\\A([0-9-]+);\\1\\z","\$1") ;368 String ef = ed.replaceAll("\\A-;","").replaceAll(";-\\z","").replaceAll("\\A([0-9-]+);\\1\\z","\$1") 316 369 // ELI has a strange and inconsistent used end_date definition, so we try again with subtraction by one 317 String ed2 = ed ;370 String ed2 = ed 318 371 def reg = (ed =~ /^(.*;)(\d\d\d\d)(-(\d\d)(-(\d\d))?)?$/) 319 372 if(reg != null && reg.count == 1) { 320 Calendar cal = Calendar.getInstance() ;373 Calendar cal = Calendar.getInstance() 321 374 cal.set(reg[0][2] as Integer, reg[0][4] == null ? 0 : (reg[0][4] as Integer)-1, reg[0][6] == null ? 1 : reg[0][6] as Integer) 322 375 cal.add(Calendar.DAY_OF_MONTH, -1) … … 327 380 ed2 += "-" + String.format("%02d", cal.get(Calendar.DAY_OF_MONTH)) 328 381 } 329 String ef2 = ed2.replaceAll("\\A-;","").replaceAll(";-\\z","").replaceAll("\\A([0-9-]+);\\1\\z","\$1") ;382 String ef2 = ed2.replaceAll("\\A-;","").replaceAll(";-\\z","").replaceAll("\\A([0-9-]+);\\1\\z","\$1") 330 383 if (!ed.equals(jd) && !ef.equals(jd) && !ed2.equals(jd) && !ef2.equals(jd)) { 331 String t = "'${ed}'" ;384 String t = "'${ed}'" 332 385 if (!ed.equals(ef)) { 333 t += " or '${ef}'" ;386 t += " or '${ef}'" 334 387 } 335 388 if (jd.isEmpty()) { … … 350 403 if(!p[0].equals(p[p.size()-1])) { 351 404 myprintln "+++ JOSM shape $num unclosed: ${getDescription(j)}" 405 } 406 for (def nump = 1; nump < p.size(); ++nump) { 407 if (p[nump-1] == p[nump]) { 408 myprintln "+++ JOSM shape $num double point at ${nump-1}: ${getDescription(j)}" 409 } 352 410 } 353 411 ++num … … 362 420 if(!p[0].equals(p[p.size()-1]) && !options.nomissingeli) { 363 421 myprintln "+++ ELI shape $num unclosed: ${getDescription(e)}" 422 } 423 for (def nump = 1; nump < p.size(); ++nump) { 424 if (p[nump-1] == p[nump]) { 425 myprintln "+++ ELI shape $num double point at ${nump-1}: ${getDescription(e)}" 426 } 364 427 } 365 428 ++num … … 426 489 def id = getId(j) 427 490 if(josmMirrors.containsKey(url)) { 428 continue ;491 continue 429 492 } 430 493 if(id == null) { … … 433 496 myprintln "* JOSM-ID ${id} not unique: ${getDescription(j)}" 434 497 } else { 435 josmIds.put(id, j) ;498 josmIds.put(id, j) 436 499 } 437 500 def d = getDate(j) … … 442 505 } else { 443 506 try { 444 def first = verifyDate(reg[0][2],reg[0][4],reg[0][6]) ;445 def second = verifyDate(reg[0][9],reg[0][11],reg[0][13]) ;507 def first = verifyDate(reg[0][2],reg[0][4],reg[0][6]) 508 def second = verifyDate(reg[0][9],reg[0][11],reg[0][13]) 446 509 if(second.compareTo(first) < 0) { 447 510 myprintln "* JOSM-Date '${d}' is strange (second earlier than first): ${getDescription(j)}" … … 455 518 def js = getShapes(j) 456 519 if(js.size()) { 457 def minlat = 1000 ;458 def minlon = 1000 ;459 def maxlat = -1000 ;460 def maxlon = -1000 ;520 def minlat = 1000 521 def minlon = 1000 522 def maxlat = -1000 523 def maxlon = -1000 461 524 for(def s: js) { 462 525 for(def p: s.getPoints()) { 463 def lat = p.getLat() ;464 def lon = p.getLon() ;465 if(lat > maxlat) maxlat = lat ;466 if(lon > maxlon) maxlon = lon ;467 if(lat < minlat) minlat = lat ;468 if(lon < minlon) minlon = lon ;469 } 470 } 471 def b = j.getBounds() ;526 def lat = p.getLat() 527 def lon = p.getLon() 528 if(lat > maxlat) maxlat = lat 529 if(lon > maxlon) maxlon = lon 530 if(lat < minlat) minlat = lat 531 if(lon < minlon) minlon = lon 532 } 533 } 534 def b = j.getBounds() 472 535 if(b.getMinLat() != minlat || b.getMinLon() != minlon || b.getMaxLat() != maxlat || b.getMaxLon() != maxlon) { 473 536 myprintln "* Bounds do not match shape (is ${b.getMinLat()},${b.getMinLon()},${b.getMaxLat()},${b.getMaxLon()}, calculated <bounds min-lat='${minlat}' min-lon='${minlon}' max-lat='${maxlat}' max-lon='${maxlon}'>): ${getDescription(j)}" … … 495 558 else if(!end.isEmpty()) 496 559 return "-;"+end 497 return "" ;560 return "" 498 561 } 499 562 static Date verifyDate(String year, String month, String day) { … … 518 581 static List<Shape> getShapes(Object e) { 519 582 if (e instanceof ImageryInfo) { 520 def bounds = e.getBounds() ;583 def bounds = e.getBounds() 521 584 if(bounds != null) { 522 return bounds.getShapes() ;585 return bounds.getShapes() 523 586 } 524 587 return []
Note:
See TracChangeset
for help on using the changeset viewer.