| 1 | // License: GPL. For details, see LICENSE file.
|
|---|
| 2 | /**
|
|---|
| 3 | * Compare and analyse the differences of the editor layer index and the JOSM imagery list.
|
|---|
| 4 | * The goal is to keep both lists in sync.
|
|---|
| 5 | *
|
|---|
| 6 | * The editor layer index project (https://github.com/osmlab/editor-layer-index)
|
|---|
| 7 | * provides also a version in the JOSM format, but the GEOJSON is the original source
|
|---|
| 8 | * format, so we read that.
|
|---|
| 9 | *
|
|---|
| 10 | * How to run:
|
|---|
| 11 | * -----------
|
|---|
| 12 | *
|
|---|
| 13 | * Main JOSM binary needs to be in classpath, e.g.
|
|---|
| 14 | *
|
|---|
| 15 | * $ groovy -cp ../dist/josm-custom.jar SyncEditorLayerIndex.groovy
|
|---|
| 16 | *
|
|---|
| 17 | * Add option "-h" to show the available command line flags.
|
|---|
| 18 | */
|
|---|
| 19 | import java.text.DecimalFormat
|
|---|
| 20 |
|
|---|
| 21 | import javax.json.Json
|
|---|
| 22 | import javax.json.JsonArray
|
|---|
| 23 | import javax.json.JsonObject
|
|---|
| 24 | import javax.json.JsonReader
|
|---|
| 25 | import javax.json.JsonValue
|
|---|
| 26 |
|
|---|
| 27 | import org.openstreetmap.josm.data.Preferences
|
|---|
| 28 | import org.openstreetmap.josm.data.imagery.ImageryInfo
|
|---|
| 29 | import org.openstreetmap.josm.data.imagery.Shape
|
|---|
| 30 | import org.openstreetmap.josm.data.preferences.JosmBaseDirectories
|
|---|
| 31 | import org.openstreetmap.josm.data.projection.Projections
|
|---|
| 32 | import org.openstreetmap.josm.data.validation.routines.DomainValidator
|
|---|
| 33 | import org.openstreetmap.josm.io.imagery.ImageryReader
|
|---|
| 34 | import org.openstreetmap.josm.spi.preferences.Config
|
|---|
| 35 |
|
|---|
| 36 | class SyncEditorLayerIndex {
|
|---|
| 37 |
|
|---|
| 38 | List<ImageryInfo> josmEntries
|
|---|
| 39 | JsonArray eliEntries
|
|---|
| 40 |
|
|---|
| 41 | def eliUrls = new HashMap<String, JsonObject>()
|
|---|
| 42 | def josmUrls = new HashMap<String, ImageryInfo>()
|
|---|
| 43 | def josmMirrors = new HashMap<String, ImageryInfo>()
|
|---|
| 44 | static def oldproj = new HashMap<String, String>()
|
|---|
| 45 | static def ignoreproj = new LinkedList<String>()
|
|---|
| 46 |
|
|---|
| 47 | static String eliInputFile = 'imagery_eli.geojson'
|
|---|
| 48 | static String josmInputFile = 'imagery_josm.imagery.xml'
|
|---|
| 49 | static String ignoreInputFile = 'imagery_josm.ignores.txt'
|
|---|
| 50 | static FileOutputStream outputFile = null
|
|---|
| 51 | static OutputStreamWriter outputStream = null
|
|---|
| 52 | def skip = [:]
|
|---|
| 53 |
|
|---|
| 54 | static def options
|
|---|
| 55 |
|
|---|
| 56 | /**
|
|---|
| 57 | * Main method.
|
|---|
| 58 | */
|
|---|
| 59 | static main(def args) {
|
|---|
| 60 | Locale.setDefault(Locale.ROOT)
|
|---|
| 61 | parse_command_line_arguments(args)
|
|---|
| 62 | def pref = new Preferences(JosmBaseDirectories.getInstance())
|
|---|
| 63 | Config.setPreferencesInstance(pref)
|
|---|
| 64 | pref.init(false)
|
|---|
| 65 | def script = new SyncEditorLayerIndex()
|
|---|
| 66 | script.setupProj()
|
|---|
| 67 | script.loadSkip()
|
|---|
| 68 | script.start()
|
|---|
| 69 | script.loadJosmEntries()
|
|---|
| 70 | if(options.josmxml) {
|
|---|
| 71 | def file = new FileOutputStream(options.josmxml)
|
|---|
| 72 | def stream = new OutputStreamWriter(file, "UTF-8")
|
|---|
| 73 | script.printentries(script.josmEntries, stream)
|
|---|
| 74 | stream.close()
|
|---|
| 75 | file.close()
|
|---|
| 76 | }
|
|---|
| 77 | script.loadELIEntries()
|
|---|
| 78 | if(options.elixml) {
|
|---|
| 79 | def file = new FileOutputStream(options.elixml)
|
|---|
| 80 | def stream = new OutputStreamWriter(file, "UTF-8")
|
|---|
| 81 | script.printentries(script.eliEntries, stream)
|
|---|
| 82 | stream.close()
|
|---|
| 83 | file.close()
|
|---|
| 84 | }
|
|---|
| 85 | script.checkInOneButNotTheOther()
|
|---|
| 86 | script.checkCommonEntries()
|
|---|
| 87 | script.end()
|
|---|
| 88 | if(outputStream != null) {
|
|---|
| 89 | outputStream.close()
|
|---|
| 90 | }
|
|---|
| 91 | if(outputFile != null) {
|
|---|
| 92 | outputFile.close()
|
|---|
| 93 | }
|
|---|
| 94 | }
|
|---|
| 95 |
|
|---|
| 96 | /**
|
|---|
| 97 | * Parse command line arguments.
|
|---|
| 98 | */
|
|---|
| 99 | static void parse_command_line_arguments(args) {
|
|---|
| 100 | def cli = new CliBuilder(width: 160)
|
|---|
| 101 | cli.o(longOpt:'output', args:1, argName: "output", "Output file, - prints to stdout (default: -)")
|
|---|
| 102 | cli.e(longOpt:'eli_input', args:1, argName:"eli_input", "Input file for the editor layer index (geojson). Default is $eliInputFile (current directory).")
|
|---|
| 103 | cli.j(longOpt:'josm_input', args:1, argName:"josm_input", "Input file for the JOSM imagery list (xml). Default is $josmInputFile (current directory).")
|
|---|
| 104 | cli.i(longOpt:'ignore_input', args:1, argName:"ignore_input", "Input file for the ignore list. Default is $ignoreInputFile (current directory).")
|
|---|
| 105 | cli.s(longOpt:'shorten', "shorten the output, so it is easier to read in a console window")
|
|---|
| 106 | cli.n(longOpt:'noskip', argName:"noskip", "don't skip known entries")
|
|---|
| 107 | cli.x(longOpt:'xhtmlbody', argName:"xhtmlbody", "create XHTML body for display in a web page")
|
|---|
| 108 | cli.X(longOpt:'xhtml', argName:"xhtml", "create XHTML for display in a web page")
|
|---|
| 109 | cli.p(longOpt:'elixml', args:1, argName:"elixml", "ELI entries for use in JOSM as XML file (incomplete)")
|
|---|
| 110 | cli.q(longOpt:'josmxml', args:1, argName:"josmxml", "JOSM entries reoutput as XML file (incomplete)")
|
|---|
| 111 | cli.m(longOpt:'noeli', argName:"noeli", "don't show output for ELI problems")
|
|---|
| 112 | cli.c(longOpt:'encoding', args:1, argName:"encoding", "output encoding (defaults to UTF-8 or cp850 on Windows)")
|
|---|
| 113 | cli.h(longOpt:'help', "show this help")
|
|---|
| 114 | options = cli.parse(args)
|
|---|
| 115 |
|
|---|
| 116 | if (options.h) {
|
|---|
| 117 | cli.usage()
|
|---|
| 118 | System.exit(0)
|
|---|
| 119 | }
|
|---|
| 120 | if (options.eli_input) {
|
|---|
| 121 | eliInputFile = options.eli_input
|
|---|
| 122 | }
|
|---|
| 123 | if (options.josm_input) {
|
|---|
| 124 | josmInputFile = options.josm_input
|
|---|
| 125 | }
|
|---|
| 126 | if (options.ignore_input) {
|
|---|
| 127 | ignoreInputFile = options.ignore_input
|
|---|
| 128 | }
|
|---|
| 129 | if (options.output && options.output != "-") {
|
|---|
| 130 | outputFile = new FileOutputStream(options.output)
|
|---|
| 131 | outputStream = new OutputStreamWriter(outputFile, options.encoding ? options.encoding : "UTF-8")
|
|---|
| 132 | } else if (options.encoding) {
|
|---|
| 133 | outputStream = new OutputStreamWriter(System.out, options.encoding)
|
|---|
| 134 | }
|
|---|
| 135 | }
|
|---|
| 136 |
|
|---|
| 137 | void setupProj() {
|
|---|
| 138 | oldproj.put("EPSG:3359", "EPSG:3404")
|
|---|
| 139 | oldproj.put("EPSG:3785", "EPSG:3857")
|
|---|
| 140 | oldproj.put("EPSG:31297", "EPGS:31287")
|
|---|
| 141 | oldproj.put("EPSG:31464", "EPSG:31468")
|
|---|
| 142 | oldproj.put("EPSG:54004", "EPSG:3857")
|
|---|
| 143 | oldproj.put("EPSG:102100", "EPSG:3857")
|
|---|
| 144 | oldproj.put("EPSG:102113", "EPSG:3857")
|
|---|
| 145 | oldproj.put("EPSG:900913", "EPGS:3857")
|
|---|
| 146 | ignoreproj.add("EPSG:4267")
|
|---|
| 147 | ignoreproj.add("EPSG:5221")
|
|---|
| 148 | ignoreproj.add("EPSG:5514")
|
|---|
| 149 | ignoreproj.add("EPSG:32019")
|
|---|
| 150 | ignoreproj.add("EPSG:102066")
|
|---|
| 151 | ignoreproj.add("EPSG:102067")
|
|---|
| 152 | ignoreproj.add("EPSG:102685")
|
|---|
| 153 | ignoreproj.add("EPSG:102711")
|
|---|
| 154 | }
|
|---|
| 155 |
|
|---|
| 156 | void loadSkip() {
|
|---|
| 157 | def fr = new InputStreamReader(new FileInputStream(ignoreInputFile), "UTF-8")
|
|---|
| 158 | def line
|
|---|
| 159 |
|
|---|
| 160 | while((line = fr.readLine()) != null) {
|
|---|
| 161 | def res = (line =~ /^\|\| *(ELI|Ignore) *\|\| *\{\{\{(.+)\}\}\} *\|\|/)
|
|---|
| 162 | if(res.count)
|
|---|
| 163 | {
|
|---|
| 164 | if(res[0][1].equals("Ignore")) {
|
|---|
| 165 | skip[res[0][2]] = "green"
|
|---|
| 166 | } else {
|
|---|
| 167 | skip[res[0][2]] = "darkgoldenrod"
|
|---|
| 168 | }
|
|---|
| 169 | }
|
|---|
| 170 | }
|
|---|
| 171 | }
|
|---|
| 172 |
|
|---|
| 173 | void myprintlnfinal(String s) {
|
|---|
| 174 | if(outputStream != null) {
|
|---|
| 175 | outputStream.write(s+System.getProperty("line.separator"))
|
|---|
| 176 | } else {
|
|---|
| 177 | println s
|
|---|
| 178 | }
|
|---|
| 179 | }
|
|---|
| 180 |
|
|---|
| 181 | void myprintln(String s) {
|
|---|
| 182 | if(skip.containsKey(s)) {
|
|---|
| 183 | String color = skip.get(s)
|
|---|
| 184 | skip.remove(s)
|
|---|
| 185 | if(options.xhtmlbody || options.xhtml) {
|
|---|
| 186 | s = "<pre style=\"margin:3px;color:"+color+"\">"+s.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">")+"</pre>"
|
|---|
| 187 | }
|
|---|
| 188 | if (!options.noskip) {
|
|---|
| 189 | return
|
|---|
| 190 | }
|
|---|
| 191 | } else if(options.xhtmlbody || options.xhtml) {
|
|---|
| 192 | String color = s.startsWith("***") ? "black" : ((s.startsWith("+ ") || s.startsWith("+++ ELI")) ? "blue" :
|
|---|
| 193 | (s.startsWith("#") ? "indigo" : (s.startsWith("!") ? "orange" : "red")))
|
|---|
| 194 | s = "<pre style=\"margin:3px;color:"+color+"\">"+s.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">")+"</pre>"
|
|---|
| 195 | }
|
|---|
| 196 | if ((s.startsWith("+ ") || s.startsWith("+++ ELI") || s.startsWith("#")) && options.noeli) {
|
|---|
| 197 | return
|
|---|
| 198 | }
|
|---|
| 199 | myprintlnfinal(s)
|
|---|
| 200 | }
|
|---|
| 201 |
|
|---|
| 202 | void start() {
|
|---|
| 203 | if (options.xhtml) {
|
|---|
| 204 | myprintlnfinal "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
|
|---|
| 205 | myprintlnfinal "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/><title>JOSM - ELI differences</title></head><body>\n"
|
|---|
| 206 | }
|
|---|
| 207 | }
|
|---|
| 208 |
|
|---|
| 209 | void end() {
|
|---|
| 210 | for (def s: skip.keySet()) {
|
|---|
| 211 | myprintln "+++ Obsolete skip entry: " + s
|
|---|
| 212 | }
|
|---|
| 213 | if (options.xhtml) {
|
|---|
| 214 | myprintlnfinal "</body></html>\n"
|
|---|
| 215 | }
|
|---|
| 216 | }
|
|---|
| 217 |
|
|---|
| 218 | void loadELIEntries() {
|
|---|
| 219 | def fr = new InputStreamReader(new FileInputStream(eliInputFile), "UTF-8")
|
|---|
| 220 | JsonReader jr = Json.createReader(fr)
|
|---|
| 221 | eliEntries = jr.readObject().get("features")
|
|---|
| 222 | jr.close()
|
|---|
| 223 |
|
|---|
| 224 | for (def e : eliEntries) {
|
|---|
| 225 | def url = getUrlStripped(e)
|
|---|
| 226 | if (url.contains("{z}")) {
|
|---|
| 227 | myprintln "+++ ELI-URL uses {z} instead of {zoom}: "+url
|
|---|
| 228 | url = url.replace("{z}","{zoom}")
|
|---|
| 229 | }
|
|---|
| 230 | if (eliUrls.containsKey(url)) {
|
|---|
| 231 | myprintln "+++ ELI-URL is not unique: "+url
|
|---|
| 232 | } else {
|
|---|
| 233 | eliUrls.put(url, e)
|
|---|
| 234 | }
|
|---|
| 235 | def s = e.get("properties").get("available_projections")
|
|---|
| 236 | if (s) {
|
|---|
| 237 | def old = new LinkedList<String>()
|
|---|
| 238 | for (def p : s) {
|
|---|
| 239 | def proj = p.getString()
|
|---|
| 240 | if(oldproj.containsKey(proj) || ("CRS:84".equals(proj) && !(url =~ /(?i)version=1\.3/))) {
|
|---|
| 241 | old.add(proj)
|
|---|
| 242 | }
|
|---|
| 243 | }
|
|---|
| 244 | if (old) {
|
|---|
| 245 | def str = String.join(", ", old)
|
|---|
| 246 | myprintln "+ ELI Projections ${str} not useful: ${getDescription(e)}"
|
|---|
| 247 | }
|
|---|
| 248 | }
|
|---|
| 249 | }
|
|---|
| 250 | myprintln "*** Loaded ${eliEntries.size()} entries (ELI). ***"
|
|---|
| 251 | }
|
|---|
| 252 | String cdata(def s, boolean escape = false) {
|
|---|
| 253 | if(escape) {
|
|---|
| 254 | return s.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">")
|
|---|
| 255 | } else if(s =~ /[<>&]/)
|
|---|
| 256 | return "<![CDATA[$s]]>"
|
|---|
| 257 | return s
|
|---|
| 258 | }
|
|---|
| 259 |
|
|---|
| 260 | String maininfo(def entry, String offset) {
|
|---|
| 261 | String t = getType(entry)
|
|---|
| 262 | String res = offset + "<type>$t</type>\n"
|
|---|
| 263 | res += offset + "<url>${cdata(getUrl(entry))}</url>\n"
|
|---|
| 264 | if(getMinZoom(entry) != null)
|
|---|
| 265 | res += offset + "<min-zoom>${getMinZoom(entry)}</min-zoom>\n"
|
|---|
| 266 | if(getMaxZoom(entry) != null)
|
|---|
| 267 | res += offset + "<max-zoom>${getMaxZoom(entry)}</max-zoom>\n"
|
|---|
| 268 | if (t == "wms") {
|
|---|
| 269 | def p = getProjections(entry)
|
|---|
| 270 | if (p) {
|
|---|
| 271 | res += offset + "<projections>\n"
|
|---|
| 272 | for (def c : p)
|
|---|
| 273 | res += offset + " <code>$c</code>\n"
|
|---|
| 274 | res += offset + "</projections>\n"
|
|---|
| 275 | }
|
|---|
| 276 | }
|
|---|
| 277 | return res
|
|---|
| 278 | }
|
|---|
| 279 |
|
|---|
| 280 | void printentries(def entries, def stream) {
|
|---|
| 281 | DecimalFormat df = new DecimalFormat("#.#######")
|
|---|
| 282 | df.setRoundingMode(java.math.RoundingMode.CEILING)
|
|---|
| 283 | stream.write "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
|
|---|
| 284 | stream.write "<imagery xmlns=\"http://josm.openstreetmap.de/maps-1.0\">\n"
|
|---|
| 285 | for (def e : entries) {
|
|---|
| 286 | stream.write(" <entry"
|
|---|
| 287 | + ("eli-best".equals(getQuality(e)) ? " eli-best=\"true\"" : "" )
|
|---|
| 288 | + (getOverlay(e) ? " overlay=\"true\"" : "" )
|
|---|
| 289 | + ">\n")
|
|---|
| 290 | def t
|
|---|
| 291 | if((t = getName(e)))
|
|---|
| 292 | stream.write " <name>${cdata(t, true)}</name>\n"
|
|---|
| 293 | if((t = getId(e)))
|
|---|
| 294 | stream.write " <id>$t</id>\n"
|
|---|
| 295 | if((t = getCategory(e)))
|
|---|
| 296 | stream.write " <category>$t</category>\n"
|
|---|
| 297 | if((t = getDate(e)))
|
|---|
| 298 | stream.write " <date>$t</date>\n"
|
|---|
| 299 | if((t = getCountryCode(e)))
|
|---|
| 300 | stream.write " <country-code>$t</country-code>\n"
|
|---|
| 301 | if((getDefault(e)))
|
|---|
| 302 | stream.write " <default>true</default>\n"
|
|---|
| 303 | stream.write maininfo(e, " ")
|
|---|
| 304 | if((t = getAttributionText(e)))
|
|---|
| 305 | stream.write " <attribution-text mandatory=\"true\">${cdata(t, true)}</attribution-text>\n"
|
|---|
| 306 | if((t = getAttributionUrl(e)))
|
|---|
| 307 | stream.write " <attribution-url>${cdata(t)}</attribution-url>\n"
|
|---|
| 308 | if((t = getLogoImage(e)))
|
|---|
| 309 | stream.write " <logo-image>${cdata(t, true)}</logo-image>\n"
|
|---|
| 310 | if((t = getLogoUrl(e)))
|
|---|
| 311 | stream.write " <logo-url>${cdata(t)}</logo-url>\n"
|
|---|
| 312 | if((t = getTermsOfUseText(e)))
|
|---|
| 313 | stream.write " <terms-of-use-text>${cdata(t, true)}</terms-of-use-text>\n"
|
|---|
| 314 | if((t = getTermsOfUseUrl(e)))
|
|---|
| 315 | stream.write " <terms-of-use-url>${cdata(t)}</terms-of-use-url>\n"
|
|---|
| 316 | if((t = getPermissionReferenceUrl(e)))
|
|---|
| 317 | stream.write " <permission-ref>${cdata(t)}</permission-ref>\n"
|
|---|
| 318 | if((getValidGeoreference(e)))
|
|---|
| 319 | stream.write " <valid-georeference>true</valid-georeference>\n"
|
|---|
| 320 | if((t = getIcon(e)))
|
|---|
| 321 | stream.write " <icon>${cdata(t)}</icon>\n"
|
|---|
| 322 | for (def d : getDescriptions(e)) {
|
|---|
| 323 | stream.write " <description lang=\"${d.getKey()}\">${d.getValue()}</description>\n"
|
|---|
| 324 | }
|
|---|
| 325 | for (def m : getMirrors(e)) {
|
|---|
| 326 | stream.write " <mirror>\n"+maininfo(m, " ")+" </mirror>\n"
|
|---|
| 327 | }
|
|---|
| 328 | def minlat = 1000
|
|---|
| 329 | def minlon = 1000
|
|---|
| 330 | def maxlat = -1000
|
|---|
| 331 | def maxlon = -1000
|
|---|
| 332 | def shapes = ""
|
|---|
| 333 | def sep = "\n "
|
|---|
| 334 | try {
|
|---|
| 335 | for(def s: getShapes(e)) {
|
|---|
| 336 | shapes += " <shape>"
|
|---|
| 337 | def i = 0
|
|---|
| 338 | for(def p: s.getPoints()) {
|
|---|
| 339 | def lat = p.getLat()
|
|---|
| 340 | def lon = p.getLon()
|
|---|
| 341 | if(lat > maxlat) maxlat = lat
|
|---|
| 342 | if(lon > maxlon) maxlon = lon
|
|---|
| 343 | if(lat < minlat) minlat = lat
|
|---|
| 344 | if(lon < minlon) minlon = lon
|
|---|
| 345 | if(!(i++%3)) {
|
|---|
| 346 | shapes += sep + " "
|
|---|
| 347 | }
|
|---|
| 348 | shapes += "<point lat='${df.format(lat)}' lon='${df.format(lon)}'/>"
|
|---|
| 349 | }
|
|---|
| 350 | shapes += sep + "</shape>\n"
|
|---|
| 351 | }
|
|---|
| 352 | } catch(IllegalArgumentException ignored) {
|
|---|
| 353 | }
|
|---|
| 354 | if(shapes) {
|
|---|
| 355 | stream.write " <bounds min-lat='${df.format(minlat)}' min-lon='${df.format(minlon)}' max-lat='${df.format(maxlat)}' max-lon='${df.format(maxlon)}'>\n"
|
|---|
| 356 | stream.write shapes + " </bounds>\n"
|
|---|
| 357 | }
|
|---|
| 358 | stream.write " </entry>\n"
|
|---|
| 359 | }
|
|---|
| 360 | stream.write "</imagery>\n"
|
|---|
| 361 | stream.close()
|
|---|
| 362 | }
|
|---|
| 363 |
|
|---|
| 364 | void loadJosmEntries() {
|
|---|
| 365 | def reader = new ImageryReader(josmInputFile)
|
|---|
| 366 | josmEntries = reader.parse()
|
|---|
| 367 |
|
|---|
| 368 | for (def e : josmEntries) {
|
|---|
| 369 | if(!getUrl(e)) {
|
|---|
| 370 | myprintln "+++ JOSM-Entry without URL: " + getDescription(e)
|
|---|
| 371 | continue;
|
|---|
| 372 | }
|
|---|
| 373 | if(!getName(e)) {
|
|---|
| 374 | myprintln "+++ JOSM-Entry without Name: " + getDescription(e)
|
|---|
| 375 | continue;
|
|---|
| 376 | }
|
|---|
| 377 | def url = getUrlStripped(e)
|
|---|
| 378 | if (url.contains("{z}")) {
|
|---|
| 379 | myprintln "+++ JOSM-URL uses {z} instead of {zoom}: "+url
|
|---|
| 380 | url = url.replace("{z}","{zoom}")
|
|---|
| 381 | }
|
|---|
| 382 | if (josmUrls.containsKey(url)) {
|
|---|
| 383 | myprintln "+++ JOSM-URL is not unique: "+url
|
|---|
| 384 | } else {
|
|---|
| 385 | josmUrls.put(url, e)
|
|---|
| 386 | }
|
|---|
| 387 | for (def m : e.getMirrors()) {
|
|---|
| 388 | url = getUrlStripped(m)
|
|---|
| 389 | m.origName = m.getOriginalName().replaceAll(" mirror server( \\d+)?","")
|
|---|
| 390 | if (josmUrls.containsKey(url)) {
|
|---|
| 391 | myprintln "+++ JOSM-Mirror-URL is not unique: "+url
|
|---|
| 392 | } else {
|
|---|
| 393 | josmUrls.put(url, m)
|
|---|
| 394 | josmMirrors.put(url, m)
|
|---|
| 395 | }
|
|---|
| 396 | }
|
|---|
| 397 | }
|
|---|
| 398 | myprintln "*** Loaded ${josmEntries.size()} entries (JOSM). ***"
|
|---|
| 399 | }
|
|---|
| 400 |
|
|---|
| 401 | void checkInOneButNotTheOther() {
|
|---|
| 402 | def le = new LinkedList<String>(eliUrls.keySet())
|
|---|
| 403 | def lj = new LinkedList<String>(josmUrls.keySet())
|
|---|
| 404 |
|
|---|
| 405 | def ke = new LinkedList<String>(le)
|
|---|
| 406 | for (def url : ke) {
|
|---|
| 407 | if(lj.contains(url)) {
|
|---|
| 408 | le.remove(url)
|
|---|
| 409 | lj.remove(url)
|
|---|
| 410 | }
|
|---|
| 411 | }
|
|---|
| 412 |
|
|---|
| 413 | if(le && lj) {
|
|---|
| 414 | ke = new LinkedList<String>(le)
|
|---|
| 415 | for (def urle : ke) {
|
|---|
| 416 | def e = eliUrls.get(urle)
|
|---|
| 417 | def ide = getId(e)
|
|---|
| 418 | String urlhttps = urle.replace("http:","https:")
|
|---|
| 419 | if(lj.contains(urlhttps))
|
|---|
| 420 | {
|
|---|
| 421 | myprintln "+ Missing https: ${getDescription(e)}"
|
|---|
| 422 | eliUrls.put(urlhttps, eliUrls.get(urle))
|
|---|
| 423 | eliUrls.remove(urle)
|
|---|
| 424 | le.remove(urle)
|
|---|
| 425 | lj.remove(urlhttps)
|
|---|
| 426 | } else if(ide) {
|
|---|
| 427 | def kj = new LinkedList<String>(lj)
|
|---|
| 428 | for (def urlj : kj) {
|
|---|
| 429 | def j = josmUrls.get(urlj)
|
|---|
| 430 | def idj = getId(j)
|
|---|
| 431 |
|
|---|
| 432 | if (ide.equals(idj) && getType(j) == getType(e)) {
|
|---|
| 433 | myprintln "* URL for id ${idj} differs ($urle): ${getDescription(j)}"
|
|---|
| 434 | le.remove(urle)
|
|---|
| 435 | lj.remove(urlj)
|
|---|
| 436 | /* replace key for this entry with JOSM URL */
|
|---|
| 437 | eliUrls.remove(urle)
|
|---|
| 438 | eliUrls.put(urlj,e)
|
|---|
| 439 | break
|
|---|
| 440 | }
|
|---|
| 441 | }
|
|---|
| 442 | }
|
|---|
| 443 | }
|
|---|
| 444 | }
|
|---|
| 445 |
|
|---|
| 446 | myprintln "*** URLs found in ELI but not in JOSM (${le.size()}): ***"
|
|---|
| 447 | le.sort()
|
|---|
| 448 | if (!le.isEmpty()) {
|
|---|
| 449 | for (def l : le) {
|
|---|
| 450 | myprintln "- " + getDescription(eliUrls.get(l))
|
|---|
| 451 | }
|
|---|
| 452 | }
|
|---|
| 453 | myprintln "*** URLs found in JOSM but not in ELI (${lj.size()}): ***"
|
|---|
| 454 | lj.sort()
|
|---|
| 455 | if (!lj.isEmpty()) {
|
|---|
| 456 | for (def l : lj) {
|
|---|
| 457 | myprintln "+ " + getDescription(josmUrls.get(l))
|
|---|
| 458 | }
|
|---|
| 459 | }
|
|---|
| 460 | }
|
|---|
| 461 |
|
|---|
| 462 | void checkCommonEntries() {
|
|---|
| 463 | myprintln "*** Same URL, but different name: ***"
|
|---|
| 464 | for (def url : eliUrls.keySet()) {
|
|---|
| 465 | def e = eliUrls.get(url)
|
|---|
| 466 | if (!josmUrls.containsKey(url)) continue
|
|---|
| 467 | def j = josmUrls.get(url)
|
|---|
| 468 | def ename = getName(e).replace("'","\u2019")
|
|---|
| 469 | def jname = getName(j).replace("'","\u2019")
|
|---|
| 470 | if (!ename.equals(jname)) {
|
|---|
| 471 | myprintln "* Name differs ('${getName(e)}' != '${getName(j)}'): ${getUrl(j)}"
|
|---|
| 472 | }
|
|---|
| 473 | }
|
|---|
| 474 |
|
|---|
| 475 | myprintln "*** Same URL, but different Id: ***"
|
|---|
| 476 | for (def url : eliUrls.keySet()) {
|
|---|
| 477 | def e = eliUrls.get(url)
|
|---|
| 478 | if (!josmUrls.containsKey(url)) continue
|
|---|
| 479 | def j = josmUrls.get(url)
|
|---|
| 480 | def ename = getId(e)
|
|---|
| 481 | def jname = getId(j)
|
|---|
| 482 | if (!ename.equals(jname)) {
|
|---|
| 483 | myprintln "# Id differs ('${getId(e)}' != '${getId(j)}'): ${getUrl(j)}"
|
|---|
| 484 | }
|
|---|
| 485 | }
|
|---|
| 486 |
|
|---|
| 487 | myprintln "*** Same URL, but different type: ***"
|
|---|
| 488 | for (def url : eliUrls.keySet()) {
|
|---|
| 489 | def e = eliUrls.get(url)
|
|---|
| 490 | if (!josmUrls.containsKey(url)) continue
|
|---|
| 491 | def j = josmUrls.get(url)
|
|---|
| 492 | if (!getType(e).equals(getType(j))) {
|
|---|
| 493 | myprintln "* Type differs (${getType(e)} != ${getType(j)}): ${getName(j)} - ${getUrl(j)}"
|
|---|
| 494 | }
|
|---|
| 495 | }
|
|---|
| 496 |
|
|---|
| 497 | myprintln "*** Same URL, but different zoom bounds: ***"
|
|---|
| 498 | for (def url : eliUrls.keySet()) {
|
|---|
| 499 | def e = eliUrls.get(url)
|
|---|
| 500 | if (!josmUrls.containsKey(url)) continue
|
|---|
| 501 | def j = josmUrls.get(url)
|
|---|
| 502 |
|
|---|
| 503 | Integer eMinZoom = getMinZoom(e)
|
|---|
| 504 | Integer jMinZoom = getMinZoom(j)
|
|---|
| 505 | /* dont warn for entries copied from the base of the mirror */
|
|---|
| 506 | if(eMinZoom == null && "wms".equals(getType(j)) && j.getName() =~ / mirror/)
|
|---|
| 507 | jMinZoom = null;
|
|---|
| 508 | if (eMinZoom != jMinZoom && !(eMinZoom == 0 && jMinZoom == null)) {
|
|---|
| 509 | myprintln "* Minzoom differs (${eMinZoom} != ${jMinZoom}): ${getDescription(j)}"
|
|---|
| 510 | }
|
|---|
| 511 | Integer eMaxZoom = getMaxZoom(e)
|
|---|
| 512 | Integer jMaxZoom = getMaxZoom(j)
|
|---|
| 513 | /* dont warn for entries copied from the base of the mirror */
|
|---|
| 514 | if(eMaxZoom == null && "wms".equals(getType(j)) && j.getName() =~ / mirror/)
|
|---|
| 515 | jMaxZoom = null;
|
|---|
| 516 | if (eMaxZoom != jMaxZoom) {
|
|---|
| 517 | myprintln "* Maxzoom differs (${eMaxZoom} != ${jMaxZoom}): ${getDescription(j)}"
|
|---|
| 518 | }
|
|---|
| 519 | }
|
|---|
| 520 |
|
|---|
| 521 | myprintln "*** Same URL, but different country code: ***"
|
|---|
| 522 | for (def url : eliUrls.keySet()) {
|
|---|
| 523 | def e = eliUrls.get(url)
|
|---|
| 524 | if (!josmUrls.containsKey(url)) continue
|
|---|
| 525 | def j = josmUrls.get(url)
|
|---|
| 526 | def cce = getCountryCode(e)
|
|---|
| 527 | if ("ZZ".equals(cce)) { /* special ELI country code */
|
|---|
| 528 | cce = null
|
|---|
| 529 | }
|
|---|
| 530 | if (!cce.equals(getCountryCode(j))) {
|
|---|
| 531 | myprintln "* Country code differs (${getCountryCode(e)} != ${getCountryCode(j)}): ${getDescription(j)}"
|
|---|
| 532 | }
|
|---|
| 533 | }
|
|---|
| 534 | myprintln "*** Same URL, but different quality: ***"
|
|---|
| 535 | for (def url : eliUrls.keySet()) {
|
|---|
| 536 | def e = eliUrls.get(url)
|
|---|
| 537 | if (!josmUrls.containsKey(url)) {
|
|---|
| 538 | def q = getQuality(e)
|
|---|
| 539 | if("eli-best".equals(q)) {
|
|---|
| 540 | myprintln "- Quality best entry not in JOSM for ${getDescription(e)}"
|
|---|
| 541 | }
|
|---|
| 542 | continue
|
|---|
| 543 | }
|
|---|
| 544 | def j = josmUrls.get(url)
|
|---|
| 545 | if (!getQuality(e).equals(getQuality(j))) {
|
|---|
| 546 | myprintln "* Quality differs (${getQuality(e)} != ${getQuality(j)}): ${getDescription(j)}"
|
|---|
| 547 | }
|
|---|
| 548 | }
|
|---|
| 549 | myprintln "*** Same URL, but different dates: ***"
|
|---|
| 550 | for (def url : eliUrls.keySet()) {
|
|---|
| 551 | def ed = getDate(eliUrls.get(url))
|
|---|
| 552 | if (!josmUrls.containsKey(url)) continue
|
|---|
| 553 | def j = josmUrls.get(url)
|
|---|
| 554 | def jd = getDate(j)
|
|---|
| 555 | // The forms 2015;- or -;2015 or 2015;2015 are handled equal to 2015
|
|---|
| 556 | String ef = ed.replaceAll("\\A-;","").replaceAll(";-\\z","").replaceAll("\\A([0-9-]+);\\1\\z","\$1")
|
|---|
| 557 | // ELI has a strange and inconsistent used end_date definition, so we try again with subtraction by one
|
|---|
| 558 | String ed2 = ed
|
|---|
| 559 | def reg = (ed =~ /^(.*;)(\d\d\d\d)(-(\d\d)(-(\d\d))?)?$/)
|
|---|
| 560 | if(reg != null && reg.count == 1) {
|
|---|
| 561 | Calendar cal = Calendar.getInstance()
|
|---|
| 562 | 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)
|
|---|
| 563 | cal.add(Calendar.DAY_OF_MONTH, -1)
|
|---|
| 564 | ed2 = reg[0][1] + cal.get(Calendar.YEAR)
|
|---|
| 565 | if (reg[0][4] != null)
|
|---|
| 566 | ed2 += "-" + String.format("%02d", cal.get(Calendar.MONTH)+1)
|
|---|
| 567 | if (reg[0][6] != null)
|
|---|
| 568 | ed2 += "-" + String.format("%02d", cal.get(Calendar.DAY_OF_MONTH))
|
|---|
| 569 | }
|
|---|
| 570 | String ef2 = ed2.replaceAll("\\A-;","").replaceAll(";-\\z","").replaceAll("\\A([0-9-]+);\\1\\z","\$1")
|
|---|
| 571 | if (!ed.equals(jd) && !ef.equals(jd) && !ed2.equals(jd) && !ef2.equals(jd)) {
|
|---|
| 572 | String t = "'${ed}'"
|
|---|
| 573 | if (!ed.equals(ef)) {
|
|---|
| 574 | t += " or '${ef}'"
|
|---|
| 575 | }
|
|---|
| 576 | if (jd.isEmpty()) {
|
|---|
| 577 | myprintln "- Missing JOSM date (${t}): ${getDescription(j)}"
|
|---|
| 578 | } else if (!ed.isEmpty()) {
|
|---|
| 579 | myprintln "* Date differs ('${t}' != '${jd}'): ${getDescription(j)}"
|
|---|
| 580 | } else if (!options.nomissingeli) {
|
|---|
| 581 | myprintln "+ Missing ELI date ('${jd}'): ${getDescription(j)}"
|
|---|
| 582 | }
|
|---|
| 583 | }
|
|---|
| 584 | }
|
|---|
| 585 | myprintln "*** Same URL, but different information: ***"
|
|---|
| 586 | for (def url : eliUrls.keySet()) {
|
|---|
| 587 | if (!josmUrls.containsKey(url)) continue
|
|---|
| 588 | def e = eliUrls.get(url)
|
|---|
| 589 | def j = josmUrls.get(url)
|
|---|
| 590 |
|
|---|
| 591 | def et = getDescriptions(e)
|
|---|
| 592 | def jt = getDescriptions(j)
|
|---|
| 593 | et = (et.size() > 0) ? et["en"] : ""
|
|---|
| 594 | jt = (jt.size() > 0) ? jt["en"] : ""
|
|---|
| 595 | if (!et.equals(jt)) {
|
|---|
| 596 | if (!jt) {
|
|---|
| 597 | myprintln "- Missing JOSM description (${et}): ${getDescription(j)}"
|
|---|
| 598 | } else if (et) {
|
|---|
| 599 | myprintln "* Description differs ('${et}' != '${jt}'): ${getDescription(j)}"
|
|---|
| 600 | } else if (!options.nomissingeli) {
|
|---|
| 601 | myprintln "+ Missing ELI description ('${jt}'): ${getDescription(j)}"
|
|---|
| 602 | }
|
|---|
| 603 | }
|
|---|
| 604 |
|
|---|
| 605 | et = getPermissionReferenceUrl(e)
|
|---|
| 606 | jt = getPermissionReferenceUrl(j)
|
|---|
| 607 | def jt2 = getTermsOfUseUrl(j)
|
|---|
| 608 | if (!jt) jt = jt2
|
|---|
| 609 | if (!et.equals(jt)) {
|
|---|
| 610 | if (!jt) {
|
|---|
| 611 | myprintln "- Missing JOSM license URL (${et}): ${getDescription(j)}"
|
|---|
| 612 | } else if (et) {
|
|---|
| 613 | def ethttps = et.replace("http:","https:")
|
|---|
| 614 | if(!jt2 || !(jt2.equals(ethttps) || jt2.equals(et+"/") || jt2.equals(ethttps+"/"))) {
|
|---|
| 615 | if(jt.equals(ethttps) || jt.equals(et+"/") || jt.equals(ethttps+"/")) {
|
|---|
| 616 | myprintln "+ License URL differs ('${et}' != '${jt}'): ${getDescription(j)}"
|
|---|
| 617 | } else {
|
|---|
| 618 | def ja = getAttributionUrl(j)
|
|---|
| 619 | if (ja && (ja.equals(et) || ja.equals(ethttps) || ja.equals(et+"/") || ja.equals(ethttps+"/"))) {
|
|---|
| 620 | myprintln "+ ELI License URL in JOSM Attribution: ${getDescription(j)}"
|
|---|
| 621 | } else {
|
|---|
| 622 | myprintln "* License URL differs ('${et}' != '${jt}'): ${getDescription(j)}"
|
|---|
| 623 | }
|
|---|
| 624 | }
|
|---|
| 625 | }
|
|---|
| 626 | } else if (!options.nomissingeli) {
|
|---|
| 627 | myprintln "+ Missing ELI license URL ('${jt}'): ${getDescription(j)}"
|
|---|
| 628 | }
|
|---|
| 629 | }
|
|---|
| 630 |
|
|---|
| 631 | et = getAttributionUrl(e)
|
|---|
| 632 | jt = getAttributionUrl(j)
|
|---|
| 633 | if (!et.equals(jt)) {
|
|---|
| 634 | if (!jt) {
|
|---|
| 635 | myprintln "- Missing JOSM attribution URL (${et}): ${getDescription(j)}"
|
|---|
| 636 | } else if (et) {
|
|---|
| 637 | def ethttps = et.replace("http:","https:")
|
|---|
| 638 | if(jt.equals(ethttps) || jt.equals(et+"/") || jt.equals(ethttps+"/")) {
|
|---|
| 639 | myprintln "+ Attribution URL differs ('${et}' != '${jt}'): ${getDescription(j)}"
|
|---|
| 640 | } else {
|
|---|
| 641 | myprintln "* Attribution URL differs ('${et}' != '${jt}'): ${getDescription(j)}"
|
|---|
| 642 | }
|
|---|
| 643 | } else if (!options.nomissingeli) {
|
|---|
| 644 | myprintln "+ Missing ELI attribution URL ('${jt}'): ${getDescription(j)}"
|
|---|
| 645 | }
|
|---|
| 646 | }
|
|---|
| 647 |
|
|---|
| 648 | et = getAttributionText(e)
|
|---|
| 649 | jt = getAttributionText(j)
|
|---|
| 650 | if (!et.equals(jt)) {
|
|---|
| 651 | if (!jt) {
|
|---|
| 652 | myprintln "- Missing JOSM attribution text (${et}): ${getDescription(j)}"
|
|---|
| 653 | } else if (et) {
|
|---|
| 654 | myprintln "* Attribution text differs ('${et}' != '${jt}'): ${getDescription(j)}"
|
|---|
| 655 | } else if (!options.nomissingeli) {
|
|---|
| 656 | myprintln "+ Missing ELI attribution text ('${jt}'): ${getDescription(j)}"
|
|---|
| 657 | }
|
|---|
| 658 | }
|
|---|
| 659 |
|
|---|
| 660 | et = getProjections(e)
|
|---|
| 661 | jt = getProjections(j)
|
|---|
| 662 | if (et) { et = new LinkedList(et); Collections.sort(et); et = String.join(" ", et) }
|
|---|
| 663 | if (jt) { jt = new LinkedList(jt); Collections.sort(jt); jt = String.join(" ", jt) }
|
|---|
| 664 | if (!et.equals(jt)) {
|
|---|
| 665 | if (!jt) {
|
|---|
| 666 | def t = getType(e)
|
|---|
| 667 | if(t == "wms_endpoint" || t == "tms") {
|
|---|
| 668 | myprintln "+ ELI projections for type ${t}: ${getDescription(j)}"
|
|---|
| 669 | }
|
|---|
| 670 | else {
|
|---|
| 671 | myprintln "- Missing JOSM projections (${et}): ${getDescription(j)}"
|
|---|
| 672 | }
|
|---|
| 673 | } else if (et) {
|
|---|
| 674 | if("EPSG:3857 EPSG:4326".equals(et) || "EPSG:3857".equals(et) || "EPSG:4326".equals(et)) {
|
|---|
| 675 | myprintln "+ ELI has minimal projections ('${et}' != '${jt}'): ${getDescription(j)}"
|
|---|
| 676 | } else {
|
|---|
| 677 | myprintln "* Projections differ ('${et}' != '${jt}'): ${getDescription(j)}"
|
|---|
| 678 | }
|
|---|
| 679 | } else if (!options.nomissingeli && !getType(e).equals("tms")) {
|
|---|
| 680 | myprintln "+ Missing ELI projections ('${jt}'): ${getDescription(j)}"
|
|---|
| 681 | }
|
|---|
| 682 | }
|
|---|
| 683 |
|
|---|
| 684 | et = getDefault(e)
|
|---|
| 685 | jt = getDefault(j)
|
|---|
| 686 | if (!et.equals(jt)) {
|
|---|
| 687 | if (!jt) {
|
|---|
| 688 | myprintln "- Missing JOSM default: ${getDescription(j)}"
|
|---|
| 689 | } else if (!options.nomissingeli) {
|
|---|
| 690 | myprintln "+ Missing ELI default: ${getDescription(j)}"
|
|---|
| 691 | }
|
|---|
| 692 | }
|
|---|
| 693 | et = getOverlay(e)
|
|---|
| 694 | jt = getOverlay(j)
|
|---|
| 695 | if (!et.equals(jt)) {
|
|---|
| 696 | if (!jt) {
|
|---|
| 697 | myprintln "- Missing JOSM overlay flag: ${getDescription(j)}"
|
|---|
| 698 | } else if (!options.nomissingeli) {
|
|---|
| 699 | myprintln "+ Missing ELI overlay flag: ${getDescription(j)}"
|
|---|
| 700 | }
|
|---|
| 701 | }
|
|---|
| 702 | }
|
|---|
| 703 | myprintln "*** Mismatching shapes: ***"
|
|---|
| 704 | for (def url : josmUrls.keySet()) {
|
|---|
| 705 | def j = josmUrls.get(url)
|
|---|
| 706 | def num = 1
|
|---|
| 707 | for (def shape : getShapes(j)) {
|
|---|
| 708 | def p = shape.getPoints()
|
|---|
| 709 | if(!p[0].equals(p[p.size()-1])) {
|
|---|
| 710 | myprintln "+++ JOSM shape $num unclosed: ${getDescription(j)}"
|
|---|
| 711 | }
|
|---|
| 712 | for (def nump = 1; nump < p.size(); ++nump) {
|
|---|
| 713 | if (p[nump-1] == p[nump]) {
|
|---|
| 714 | myprintln "+++ JOSM shape $num double point at ${nump-1}: ${getDescription(j)}"
|
|---|
| 715 | }
|
|---|
| 716 | }
|
|---|
| 717 | ++num
|
|---|
| 718 | }
|
|---|
| 719 | }
|
|---|
| 720 | for (def url : eliUrls.keySet()) {
|
|---|
| 721 | def e = eliUrls.get(url)
|
|---|
| 722 | def num = 1
|
|---|
| 723 | def s
|
|---|
| 724 | try {
|
|---|
| 725 | s = getShapes(e)
|
|---|
| 726 | for (def shape : s) {
|
|---|
| 727 | def p = shape.getPoints()
|
|---|
| 728 | if(!p[0].equals(p[p.size()-1]) && !options.nomissingeli) {
|
|---|
| 729 | myprintln "+++ ELI shape $num unclosed: ${getDescription(e)}"
|
|---|
| 730 | }
|
|---|
| 731 | for (def nump = 1; nump < p.size(); ++nump) {
|
|---|
| 732 | if (p[nump-1] == p[nump]) {
|
|---|
| 733 | myprintln "+++ ELI shape $num double point at ${nump-1}: ${getDescription(e)}"
|
|---|
| 734 | }
|
|---|
| 735 | }
|
|---|
| 736 | ++num
|
|---|
| 737 | }
|
|---|
| 738 | } catch(IllegalArgumentException err) {
|
|---|
| 739 | def desc = getDescription(e)
|
|---|
| 740 | myprintln("* Invalid data in ELI geometry for $desc: ${err.getMessage()}")
|
|---|
| 741 | }
|
|---|
| 742 | if (s == null || !josmUrls.containsKey(url)) {
|
|---|
| 743 | continue
|
|---|
| 744 | }
|
|---|
| 745 | def j = josmUrls.get(url)
|
|---|
| 746 | def js = getShapes(j)
|
|---|
| 747 | if(!s.size() && js.size()) {
|
|---|
| 748 | if(!options.nomissingeli) {
|
|---|
| 749 | myprintln "+ No ELI shape: ${getDescription(j)}"
|
|---|
| 750 | }
|
|---|
| 751 | } else if(!js.size() && s.size()) {
|
|---|
| 752 | // don't report boundary like 5 point shapes as difference
|
|---|
| 753 | if (s.size() != 1 || s[0].getPoints().size() != 5) {
|
|---|
| 754 | myprintln "- No JOSM shape: ${getDescription(j)}"
|
|---|
| 755 | }
|
|---|
| 756 | } else if(s.size() != js.size()) {
|
|---|
| 757 | myprintln "* Different number of shapes (${s.size()} != ${js.size()}): ${getDescription(j)}"
|
|---|
| 758 | } else {
|
|---|
| 759 | boolean[] edone = new boolean[s.size()]
|
|---|
| 760 | boolean[] jdone = new boolean[js.size()]
|
|---|
| 761 | for(def enums = 0; enums < s.size(); ++enums) {
|
|---|
| 762 | def ep = s[enums].getPoints()
|
|---|
| 763 | for(def jnums = 0; jnums < js.size() && !edone[enums]; ++jnums) {
|
|---|
| 764 | def jp = js[jnums].getPoints()
|
|---|
| 765 | if(ep.size() == jp.size() && !jdone[jnums]) {
|
|---|
| 766 | boolean err = false;
|
|---|
| 767 | for(def nump = 0; nump < ep.size() && !err; ++nump) {
|
|---|
| 768 | def ept = ep[nump]
|
|---|
| 769 | def jpt = jp[nump]
|
|---|
| 770 | if(Math.abs(ept.getLat()-jpt.getLat()) > 0.00001 || Math.abs(ept.getLon()-jpt.getLon()) > 0.00001)
|
|---|
| 771 | err = true
|
|---|
| 772 | }
|
|---|
| 773 | if(!err) {
|
|---|
| 774 | edone[enums] = true
|
|---|
| 775 | jdone[jnums] = true
|
|---|
| 776 | break
|
|---|
| 777 | }
|
|---|
| 778 | }
|
|---|
| 779 | }
|
|---|
| 780 | }
|
|---|
| 781 | for(def enums = 0; enums < s.size(); ++enums) {
|
|---|
| 782 | def ep = s[enums].getPoints()
|
|---|
| 783 | for(def jnums = 0; jnums < js.size() && !edone[enums]; ++jnums) {
|
|---|
| 784 | def jp = js[jnums].getPoints()
|
|---|
| 785 | if(ep.size() == jp.size() && !jdone[jnums]) {
|
|---|
| 786 | boolean err = false;
|
|---|
| 787 | for(def nump = 0; nump < ep.size() && !err; ++nump) {
|
|---|
| 788 | def ept = ep[nump]
|
|---|
| 789 | def jpt = jp[nump]
|
|---|
| 790 | if(Math.abs(ept.getLat()-jpt.getLat()) > 0.00001 || Math.abs(ept.getLon()-jpt.getLon()) > 0.00001) {
|
|---|
| 791 | def numtxt = ((enums == jnums) ? "${enums+1}" : "${enums+1}/${jnums+1}")
|
|---|
| 792 | myprintln "* Different coordinate for point ${nump+1} of shape $numtxt: ${getDescription(j)}"
|
|---|
| 793 | break
|
|---|
| 794 | }
|
|---|
| 795 | }
|
|---|
| 796 | edone[enums] = true
|
|---|
| 797 | jdone[jnums] = true
|
|---|
| 798 | break
|
|---|
| 799 | }
|
|---|
| 800 | }
|
|---|
| 801 | }
|
|---|
| 802 | for(def enums = 0; enums < s.size(); ++enums) {
|
|---|
| 803 | def ep = s[enums].getPoints()
|
|---|
| 804 | for(def jnums = 0; jnums < js.size() && !edone[enums]; ++jnums) {
|
|---|
| 805 | def jp = js[jnums].getPoints()
|
|---|
| 806 | if(!jdone[jnums]) {
|
|---|
| 807 | def numtxt = ((enums == jnums) ? "${enums+1}" : "${enums+1}/${jnums+1}")
|
|---|
| 808 | myprintln "* Different number of points for shape $numtxt (${ep.size()} ! = ${jp.size()})): ${getDescription(j)}"
|
|---|
| 809 | edone[enums] = true
|
|---|
| 810 | jdone[jnums] = true
|
|---|
| 811 | break
|
|---|
| 812 | }
|
|---|
| 813 | }
|
|---|
| 814 | }
|
|---|
| 815 | }
|
|---|
| 816 | }
|
|---|
| 817 | myprintln "*** Mismatching icons: ***"
|
|---|
| 818 | for (def url : eliUrls.keySet()) {
|
|---|
| 819 | def e = eliUrls.get(url)
|
|---|
| 820 | if (!josmUrls.containsKey(url)) {
|
|---|
| 821 | continue
|
|---|
| 822 | }
|
|---|
| 823 | def j = josmUrls.get(url)
|
|---|
| 824 | def ij = getIcon(j)
|
|---|
| 825 | def ie = getIcon(e)
|
|---|
| 826 | if(ij != null && ie == null) {
|
|---|
| 827 | if(!options.nomissingeli) {
|
|---|
| 828 | myprintln "+ No ELI icon: ${getDescription(j)}"
|
|---|
| 829 | }
|
|---|
| 830 | } else if(ij == null && ie != null) {
|
|---|
| 831 | myprintln "- No JOSM icon: ${getDescription(j)}"
|
|---|
| 832 | } else if(!ij.equals(ie) && !(
|
|---|
| 833 | (ie.startsWith("https://osmlab.github.io/editor-layer-index/")
|
|---|
| 834 | || ie.startsWith("https://raw.githubusercontent.com/osmlab/editor-layer-index/")) &&
|
|---|
| 835 | ij.startsWith("data:"))) {
|
|---|
| 836 | def iehttps = ie.replace("http:","https:")
|
|---|
| 837 | if(ij.equals(iehttps)) {
|
|---|
| 838 | myprintln "+ Different icons: ${getDescription(j)}"
|
|---|
| 839 | } else {
|
|---|
| 840 | myprintln "* Different icons: ${getDescription(j)}"
|
|---|
| 841 | }
|
|---|
| 842 | }
|
|---|
| 843 | }
|
|---|
| 844 | myprintln "*** Miscellaneous checks: ***"
|
|---|
| 845 | def josmIds = new HashMap<String, ImageryInfo>()
|
|---|
| 846 | def all = Projections.getAllProjectionCodes()
|
|---|
| 847 | DomainValidator dv = DomainValidator.getInstance();
|
|---|
| 848 | for (def url : josmUrls.keySet()) {
|
|---|
| 849 | def j = josmUrls.get(url)
|
|---|
| 850 | def id = getId(j)
|
|---|
| 851 | if("wms".equals(getType(j))) {
|
|---|
| 852 | if(!getProjections(j)) {
|
|---|
| 853 | myprintln "* WMS without projections: ${getDescription(j)}"
|
|---|
| 854 | } else {
|
|---|
| 855 | def unsupported = new LinkedList<String>()
|
|---|
| 856 | def old = new LinkedList<String>()
|
|---|
| 857 | for (def p : getProjectionsUnstripped(j)) {
|
|---|
| 858 | if("CRS:84".equals(p)) {
|
|---|
| 859 | if(!(url =~ /(?i)version=1\.3/)) {
|
|---|
| 860 | myprintln "* CRS:84 without WMS 1.3: ${getDescription(j)}"
|
|---|
| 861 | }
|
|---|
| 862 | } else if(oldproj.containsKey(p)) {
|
|---|
| 863 | old.add(p)
|
|---|
| 864 | } else if(!all.contains(p) && !ignoreproj.contains(p)) {
|
|---|
| 865 | unsupported.add(p)
|
|---|
| 866 | }
|
|---|
| 867 | }
|
|---|
| 868 | if (unsupported) {
|
|---|
| 869 | def s = String.join(", ", unsupported)
|
|---|
| 870 | myprintln "* Projections ${s} not supported by JOSM: ${getDescription(j)}"
|
|---|
| 871 | }
|
|---|
| 872 | for (def o : old) {
|
|---|
| 873 | myprintln "* Projection ${o} is an old unsupported code and has been replaced by ${oldproj.get(o)}: ${getDescription(j)}"
|
|---|
| 874 | }
|
|---|
| 875 | }
|
|---|
| 876 | if((url =~ /(?i)version=1\.3/) && !(url =~ /[Cc][Rr][Ss]=\{proj\}/)) {
|
|---|
| 877 | myprintln "* WMS 1.3 with strange CRS specification: ${getDescription(j)}"
|
|---|
| 878 | }
|
|---|
| 879 | if((url =~ /(?i)version=1\.1/) && !(url =~ /[Ss][Rr][Ss]=\{proj\}/)) {
|
|---|
| 880 | myprintln "* WMS 1.1 with strange SRS specification: ${getDescription(j)}"
|
|---|
| 881 | }
|
|---|
| 882 | }
|
|---|
| 883 | def urls = new LinkedList<String>()
|
|---|
| 884 | if(!"scanex".equals(getType(j))) {
|
|---|
| 885 | urls += url
|
|---|
| 886 | }
|
|---|
| 887 | def jt = getPermissionReferenceUrl(j)
|
|---|
| 888 | if(jt && !"Public Domain".equals(jt))
|
|---|
| 889 | urls += jt
|
|---|
| 890 | jt = getTermsOfUseUrl(j)
|
|---|
| 891 | if(jt)
|
|---|
| 892 | urls += jt
|
|---|
| 893 | jt = getAttributionUrl(j)
|
|---|
| 894 | if(jt)
|
|---|
| 895 | urls += jt
|
|---|
| 896 | jt = getIcon(j)
|
|---|
| 897 | if(jt && !(jt =~ /^data:image\/png;base64,/))
|
|---|
| 898 | urls += jt
|
|---|
| 899 | for(def u : urls) {
|
|---|
| 900 | def m = u =~ /^https?:\/\/([^\/]+?)(:\d+)?\//
|
|---|
| 901 | if(!m || u =~ /[ \t]+$/)
|
|---|
| 902 | myprintln "* Strange URL '${u}': ${getDescription(j)}"
|
|---|
| 903 | else {
|
|---|
| 904 | def domain = m[0][1].replaceAll("\\{switch:.*\\}","x")
|
|---|
| 905 | def port = m[0][2]
|
|---|
| 906 | if (!(domain =~ /^\d+\.\d+\.\d+\.\d+$/) && !dv.isValid(domain))
|
|---|
| 907 | myprintln "* Strange Domain '${domain}': ${getDescription(j)}"
|
|---|
| 908 | else if (port != null && (port == ":80" || port == ":443")) {
|
|---|
| 909 | myprintln "* Useless port '${port}': ${getDescription(j)}"
|
|---|
| 910 | }
|
|---|
| 911 | }
|
|---|
| 912 | }
|
|---|
| 913 |
|
|---|
| 914 | if(josmMirrors.containsKey(url)) {
|
|---|
| 915 | continue
|
|---|
| 916 | }
|
|---|
| 917 | if(id == null) {
|
|---|
| 918 | myprintln "* No JOSM-ID: ${getDescription(j)}"
|
|---|
| 919 | } else if(josmIds.containsKey(id)) {
|
|---|
| 920 | myprintln "* JOSM-ID ${id} not unique: ${getDescription(j)}"
|
|---|
| 921 | } else {
|
|---|
| 922 | josmIds.put(id, j)
|
|---|
| 923 | }
|
|---|
| 924 | def d = getDate(j)
|
|---|
| 925 | if(!d.isEmpty()) {
|
|---|
| 926 | def reg = (d =~ /^(-|(\d\d\d\d)(-(\d\d)(-(\d\d))?)?)(;(-|(\d\d\d\d)(-(\d\d)(-(\d\d))?)?))?$/)
|
|---|
| 927 | if(reg == null || reg.count != 1) {
|
|---|
| 928 | myprintln "* JOSM-Date '${d}' is strange: ${getDescription(j)}"
|
|---|
| 929 | } else {
|
|---|
| 930 | try {
|
|---|
| 931 | def first = verifyDate(reg[0][2],reg[0][4],reg[0][6])
|
|---|
| 932 | def second = verifyDate(reg[0][9],reg[0][11],reg[0][13])
|
|---|
| 933 | if(second.compareTo(first) < 0) {
|
|---|
| 934 | myprintln "* JOSM-Date '${d}' is strange (second earlier than first): ${getDescription(j)}"
|
|---|
| 935 | }
|
|---|
| 936 | }
|
|---|
| 937 | catch (Exception e) {
|
|---|
| 938 | myprintln "* JOSM-Date '${d}' is strange (${e.getMessage()}): ${getDescription(j)}"
|
|---|
| 939 | }
|
|---|
| 940 | }
|
|---|
| 941 | }
|
|---|
| 942 | if(getAttributionUrl(j) && !getAttributionText(j)) {
|
|---|
| 943 | myprintln "* Attribution link without text: ${getDescription(j)}"
|
|---|
| 944 | }
|
|---|
| 945 | if(getLogoUrl(j) && !getLogoImage(j)) {
|
|---|
| 946 | myprintln "* Logo link without image: ${getDescription(j)}"
|
|---|
| 947 | }
|
|---|
| 948 | if(getTermsOfUseText(j) && !getTermsOfUseUrl(j)) {
|
|---|
| 949 | myprintln "* Terms of Use text without link: ${getDescription(j)}"
|
|---|
| 950 | }
|
|---|
| 951 | def js = getShapes(j)
|
|---|
| 952 | if(js.size()) {
|
|---|
| 953 | def minlat = 1000
|
|---|
| 954 | def minlon = 1000
|
|---|
| 955 | def maxlat = -1000
|
|---|
| 956 | def maxlon = -1000
|
|---|
| 957 | for(def s: js) {
|
|---|
| 958 | for(def p: s.getPoints()) {
|
|---|
| 959 | def lat = p.getLat()
|
|---|
| 960 | def lon = p.getLon()
|
|---|
| 961 | if(lat > maxlat) maxlat = lat
|
|---|
| 962 | if(lon > maxlon) maxlon = lon
|
|---|
| 963 | if(lat < minlat) minlat = lat
|
|---|
| 964 | if(lon < minlon) minlon = lon
|
|---|
| 965 | }
|
|---|
| 966 | }
|
|---|
| 967 | def b = j.getBounds()
|
|---|
| 968 | if(b.getMinLat() != minlat || b.getMinLon() != minlon || b.getMaxLat() != maxlat || b.getMaxLon() != maxlon) {
|
|---|
| 969 | 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)}"
|
|---|
| 970 | }
|
|---|
| 971 | }
|
|---|
| 972 | def cat = getCategory(j)
|
|---|
| 973 | if(cat == null) {
|
|---|
| 974 | myprintln "* No category: ${getDescription(j)}"
|
|---|
| 975 | } else if(cat != "photo" && cat != "map" && cat != "historicmap" && cat != "osmbasedmap" && cat != "historicphoto" && cat != "other") {
|
|---|
| 976 | myprintln "* Strange category ${cat}: ${getDescription(j)}"
|
|---|
| 977 | }
|
|---|
| 978 | }
|
|---|
| 979 | }
|
|---|
| 980 |
|
|---|
| 981 | /**
|
|---|
| 982 | * Utility functions that allow uniform access for both ImageryInfo and JsonObject.
|
|---|
| 983 | */
|
|---|
| 984 | static String getUrl(Object e) {
|
|---|
| 985 | if (e instanceof ImageryInfo) return e.url
|
|---|
| 986 | return e.get("properties").getString("url")
|
|---|
| 987 | }
|
|---|
| 988 | static String getUrlStripped(Object e) {
|
|---|
| 989 | return getUrl(e).replaceAll("\\?(apikey|access_token)=.*","")
|
|---|
| 990 | }
|
|---|
| 991 | static String getDate(Object e) {
|
|---|
| 992 | if (e instanceof ImageryInfo) return e.date ? e.date : ""
|
|---|
| 993 | def p = e.get("properties")
|
|---|
| 994 | def start = p.containsKey("start_date") ? p.getString("start_date") : ""
|
|---|
| 995 | def end = p.containsKey("end_date") ? p.getString("end_date") : ""
|
|---|
| 996 | if(!start.isEmpty() && !end.isEmpty())
|
|---|
| 997 | return start+";"+end
|
|---|
| 998 | else if(!start.isEmpty())
|
|---|
| 999 | return start+";-"
|
|---|
| 1000 | else if(!end.isEmpty())
|
|---|
| 1001 | return "-;"+end
|
|---|
| 1002 | return ""
|
|---|
| 1003 | }
|
|---|
| 1004 | static Date verifyDate(String year, String month, String day) {
|
|---|
| 1005 | def date
|
|---|
| 1006 | if(year == null) {
|
|---|
| 1007 | date = "3000-01-01"
|
|---|
| 1008 | } else {
|
|---|
| 1009 | date = year + "-" + (month == null ? "01" : month) + "-" + (day == null ? "01" : day)
|
|---|
| 1010 | }
|
|---|
| 1011 | def df = new java.text.SimpleDateFormat("yyyy-MM-dd")
|
|---|
| 1012 | df.setLenient(false)
|
|---|
| 1013 | return df.parse(date)
|
|---|
| 1014 | }
|
|---|
| 1015 | static String getId(Object e) {
|
|---|
| 1016 | if (e instanceof ImageryInfo) return e.getId()
|
|---|
| 1017 | return e.get("properties").getString("id")
|
|---|
| 1018 | }
|
|---|
| 1019 | static String getName(Object e) {
|
|---|
| 1020 | if (e instanceof ImageryInfo) return e.getOriginalName()
|
|---|
| 1021 | return e.get("properties").getString("name")
|
|---|
| 1022 | }
|
|---|
| 1023 | static List<Object> getMirrors(Object e) {
|
|---|
| 1024 | if (e instanceof ImageryInfo) return e.getMirrors()
|
|---|
| 1025 | return []
|
|---|
| 1026 | }
|
|---|
| 1027 | static List<Object> getProjections(Object e) {
|
|---|
| 1028 | def r = []
|
|---|
| 1029 | def u = getProjectionsUnstripped(e)
|
|---|
| 1030 | if(u) {
|
|---|
| 1031 | for (def p : u) {
|
|---|
| 1032 | if(!oldproj.containsKey(p) && !("CRS:84".equals(p) && !(getUrlStripped(e) =~ /(?i)version=1\.3/))) {
|
|---|
| 1033 | r += p
|
|---|
| 1034 | }
|
|---|
| 1035 | }
|
|---|
| 1036 | }
|
|---|
| 1037 | return r
|
|---|
| 1038 | }
|
|---|
| 1039 | static List<Object> getProjectionsUnstripped(Object e) {
|
|---|
| 1040 | def r
|
|---|
| 1041 | if (e instanceof ImageryInfo) {
|
|---|
| 1042 | r = e.getServerProjections()
|
|---|
| 1043 | } else {
|
|---|
| 1044 | def s = e.get("properties").get("available_projections")
|
|---|
| 1045 | if (s) {
|
|---|
| 1046 | r = []
|
|---|
| 1047 | for (def p : s) {
|
|---|
| 1048 | r += p.getString()
|
|---|
| 1049 | }
|
|---|
| 1050 | }
|
|---|
| 1051 | }
|
|---|
| 1052 | return r ? r : []
|
|---|
| 1053 | }
|
|---|
| 1054 | static List<Shape> getShapes(Object e) {
|
|---|
| 1055 | if (e instanceof ImageryInfo) {
|
|---|
| 1056 | def bounds = e.getBounds()
|
|---|
| 1057 | if(bounds != null) {
|
|---|
| 1058 | return bounds.getShapes()
|
|---|
| 1059 | }
|
|---|
| 1060 | return []
|
|---|
| 1061 | }
|
|---|
| 1062 | def ex = e.get("geometry")
|
|---|
| 1063 | if (ex != null && !JsonValue.NULL.equals(ex) && !ex.isNull("coordinates")) {
|
|---|
| 1064 | def poly = ex.get("coordinates")
|
|---|
| 1065 | List<Shape> l = []
|
|---|
| 1066 | for(def shapes: poly) {
|
|---|
| 1067 | def s = new Shape()
|
|---|
| 1068 | for(def point: shapes) {
|
|---|
| 1069 | def lon = point[0].toString()
|
|---|
| 1070 | def lat = point[1].toString()
|
|---|
| 1071 | s.addPoint(lat, lon)
|
|---|
| 1072 | }
|
|---|
| 1073 | l.add(s)
|
|---|
| 1074 | }
|
|---|
| 1075 | return l
|
|---|
| 1076 | }
|
|---|
| 1077 | return []
|
|---|
| 1078 | }
|
|---|
| 1079 | static String getType(Object e) {
|
|---|
| 1080 | if (e instanceof ImageryInfo) return e.getImageryType().getTypeString()
|
|---|
| 1081 | return e.get("properties").getString("type")
|
|---|
| 1082 | }
|
|---|
| 1083 | static Integer getMinZoom(Object e) {
|
|---|
| 1084 | if (e instanceof ImageryInfo) {
|
|---|
| 1085 | int mz = e.getMinZoom()
|
|---|
| 1086 | return mz == 0 ? null : mz
|
|---|
| 1087 | } else {
|
|---|
| 1088 | def num = e.get("properties").getJsonNumber("min_zoom")
|
|---|
| 1089 | if (num == null) return null
|
|---|
| 1090 | return num.intValue()
|
|---|
| 1091 | }
|
|---|
| 1092 | }
|
|---|
| 1093 | static Integer getMaxZoom(Object e) {
|
|---|
| 1094 | if (e instanceof ImageryInfo) {
|
|---|
| 1095 | int mz = e.getMaxZoom()
|
|---|
| 1096 | return mz == 0 ? null : mz
|
|---|
| 1097 | } else {
|
|---|
| 1098 | def num = e.get("properties").getJsonNumber("max_zoom")
|
|---|
| 1099 | if (num == null) return null
|
|---|
| 1100 | return num.intValue()
|
|---|
| 1101 | }
|
|---|
| 1102 | }
|
|---|
| 1103 | static String getCountryCode(Object e) {
|
|---|
| 1104 | if (e instanceof ImageryInfo) return "".equals(e.getCountryCode()) ? null : e.getCountryCode()
|
|---|
| 1105 | return e.get("properties").getString("country_code", null)
|
|---|
| 1106 | }
|
|---|
| 1107 | static String getQuality(Object e) {
|
|---|
| 1108 | if (e instanceof ImageryInfo) return e.isBestMarked() ? "eli-best" : null
|
|---|
| 1109 | return (e.get("properties").containsKey("best")
|
|---|
| 1110 | && e.get("properties").getBoolean("best")) ? "eli-best" : null
|
|---|
| 1111 | }
|
|---|
| 1112 | static Boolean getOverlay(Object e) {
|
|---|
| 1113 | if (e instanceof ImageryInfo) return e.isOverlay()
|
|---|
| 1114 | return (e.get("properties").containsKey("overlay")
|
|---|
| 1115 | && e.get("properties").getBoolean("overlay"))
|
|---|
| 1116 | }
|
|---|
| 1117 | static String getIcon(Object e) {
|
|---|
| 1118 | if (e instanceof ImageryInfo) return e.getIcon()
|
|---|
| 1119 | return e.get("properties").getString("icon", null)
|
|---|
| 1120 | }
|
|---|
| 1121 | static String getAttributionText(Object e) {
|
|---|
| 1122 | if (e instanceof ImageryInfo) return e.getAttributionText(0, null, null)
|
|---|
| 1123 | try {return e.get("properties").get("attribution").getString("text", null)} catch (NullPointerException ex) {return null}
|
|---|
| 1124 | }
|
|---|
| 1125 | static String getAttributionUrl(Object e) {
|
|---|
| 1126 | if (e instanceof ImageryInfo) return e.getAttributionLinkURL()
|
|---|
| 1127 | try {return e.get("properties").get("attribution").getString("url", null)} catch (NullPointerException ex) {return null}
|
|---|
| 1128 | }
|
|---|
| 1129 | static String getTermsOfUseText(Object e) {
|
|---|
| 1130 | if (e instanceof ImageryInfo) return e.getTermsOfUseText()
|
|---|
| 1131 | return null
|
|---|
| 1132 | }
|
|---|
| 1133 | static String getTermsOfUseUrl(Object e) {
|
|---|
| 1134 | if (e instanceof ImageryInfo) return e.getTermsOfUseURL()
|
|---|
| 1135 | return null
|
|---|
| 1136 | }
|
|---|
| 1137 | static String getCategory(Object e) {
|
|---|
| 1138 | if (e instanceof ImageryInfo) {
|
|---|
| 1139 | return e.getImageryCategoryOriginalString()
|
|---|
| 1140 | }
|
|---|
| 1141 | return null
|
|---|
| 1142 | }
|
|---|
| 1143 | static String getLogoImage(Object e) {
|
|---|
| 1144 | if (e instanceof ImageryInfo) return e.getAttributionImageRaw()
|
|---|
| 1145 | return null
|
|---|
| 1146 | }
|
|---|
| 1147 | static String getLogoUrl(Object e) {
|
|---|
| 1148 | if (e instanceof ImageryInfo) return e.getAttributionImageURL()
|
|---|
| 1149 | return null
|
|---|
| 1150 | }
|
|---|
| 1151 | static String getPermissionReferenceUrl(Object e) {
|
|---|
| 1152 | if (e instanceof ImageryInfo) return e.getPermissionReferenceURL()
|
|---|
| 1153 | return e.get("properties").getString("license_url", null)
|
|---|
| 1154 | }
|
|---|
| 1155 | static Map<String,String> getDescriptions(Object e) {
|
|---|
| 1156 | Map<String,String> res = new HashMap<String, String>()
|
|---|
| 1157 | if (e instanceof ImageryInfo) {
|
|---|
| 1158 | String a = e.getDescription()
|
|---|
| 1159 | if (a) res.put("en", a)
|
|---|
| 1160 | } else {
|
|---|
| 1161 | String a = e.get("properties").getString("description", null)
|
|---|
| 1162 | if (a) res.put("en", a.replaceAll("''","'"))
|
|---|
| 1163 | }
|
|---|
| 1164 | return res
|
|---|
| 1165 | }
|
|---|
| 1166 | static Boolean getValidGeoreference(Object e) {
|
|---|
| 1167 | if (e instanceof ImageryInfo) return e.isGeoreferenceValid()
|
|---|
| 1168 | return false
|
|---|
| 1169 | }
|
|---|
| 1170 | static Boolean getDefault(Object e) {
|
|---|
| 1171 | if (e instanceof ImageryInfo) return e.isDefaultEntry()
|
|---|
| 1172 | return e.get("properties").getBoolean("default", false)
|
|---|
| 1173 | }
|
|---|
| 1174 | String getDescription(Object o) {
|
|---|
| 1175 | def url = getUrl(o)
|
|---|
| 1176 | def cc = getCountryCode(o)
|
|---|
| 1177 | if (cc == null) {
|
|---|
| 1178 | def j = josmUrls.get(url)
|
|---|
| 1179 | if (j != null) cc = getCountryCode(j)
|
|---|
| 1180 | if (cc == null) {
|
|---|
| 1181 | def e = eliUrls.get(url)
|
|---|
| 1182 | if (e != null) cc = getCountryCode(e)
|
|---|
| 1183 | }
|
|---|
| 1184 | }
|
|---|
| 1185 | if (cc == null) {
|
|---|
| 1186 | cc = ''
|
|---|
| 1187 | } else {
|
|---|
| 1188 | cc = "[$cc] "
|
|---|
| 1189 | }
|
|---|
| 1190 | def d = cc + getName(o) + " - " + getUrl(o)
|
|---|
| 1191 | if (options.shorten) {
|
|---|
| 1192 | def MAXLEN = 140
|
|---|
| 1193 | if (d.length() > MAXLEN) d = d.substring(0, MAXLEN-1) + "..."
|
|---|
| 1194 | }
|
|---|
| 1195 | return d
|
|---|
| 1196 | }
|
|---|
| 1197 | }
|
|---|