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 | import javax.json.Json |
---|
21 | import javax.json.JsonArray |
---|
22 | import javax.json.JsonObject |
---|
23 | import javax.json.JsonReader |
---|
24 | |
---|
25 | import org.openstreetmap.josm.data.imagery.ImageryInfo |
---|
26 | import org.openstreetmap.josm.data.imagery.Shape |
---|
27 | import org.openstreetmap.josm.io.imagery.ImageryReader |
---|
28 | |
---|
29 | class SyncEditorLayerIndex { |
---|
30 | |
---|
31 | List<ImageryInfo> josmEntries; |
---|
32 | JsonArray eliEntries; |
---|
33 | |
---|
34 | def eliUrls = new HashMap<String, JsonObject>() |
---|
35 | def josmUrls = new HashMap<String, ImageryInfo>() |
---|
36 | def josmMirrors = new HashMap<String, ImageryInfo>() |
---|
37 | |
---|
38 | static String eliInputFile = 'imagery_eli.geojson' |
---|
39 | static String josmInputFile = 'imagery_josm.imagery.xml' |
---|
40 | static String ignoreInputFile = 'imagery_josm.ignores.txt' |
---|
41 | static FileOutputStream outputFile = null |
---|
42 | static OutputStreamWriter outputStream = null |
---|
43 | def skip = [:] |
---|
44 | |
---|
45 | static def options |
---|
46 | |
---|
47 | /** |
---|
48 | * Main method. |
---|
49 | */ |
---|
50 | static main(def args) { |
---|
51 | Locale.setDefault(Locale.ROOT); |
---|
52 | parse_command_line_arguments(args) |
---|
53 | def script = new SyncEditorLayerIndex() |
---|
54 | script.loadSkip() |
---|
55 | script.start() |
---|
56 | script.loadJosmEntries() |
---|
57 | if(options.josmxml) { |
---|
58 | def file = new FileOutputStream(options.josmxml) |
---|
59 | def stream = new OutputStreamWriter(file, "UTF-8") |
---|
60 | script.printentries(script.josmEntries, stream) |
---|
61 | stream.close(); |
---|
62 | file.close(); |
---|
63 | } |
---|
64 | script.loadELIEntries() |
---|
65 | if(options.elixml) { |
---|
66 | def file = new FileOutputStream(options.elixml) |
---|
67 | def stream = new OutputStreamWriter(file, "UTF-8") |
---|
68 | script.printentries(script.eliEntries, stream) |
---|
69 | stream.close(); |
---|
70 | file.close(); |
---|
71 | } |
---|
72 | script.checkInOneButNotTheOther() |
---|
73 | script.checkCommonEntries() |
---|
74 | script.end() |
---|
75 | if(outputStream != null) { |
---|
76 | outputStream.close(); |
---|
77 | } |
---|
78 | if(outputFile != null) { |
---|
79 | outputFile.close(); |
---|
80 | } |
---|
81 | } |
---|
82 | |
---|
83 | /** |
---|
84 | * Parse command line arguments. |
---|
85 | */ |
---|
86 | static void parse_command_line_arguments(args) { |
---|
87 | def cli = new CliBuilder(width: 160) |
---|
88 | cli.o(longOpt:'output', args:1, argName: "output", "Output file, - prints to stdout (default: -)") |
---|
89 | cli.e(longOpt:'eli_input', args:1, argName:"eli_input", "Input file for the editor layer index (geojson). Default is $eliInputFile (current directory).") |
---|
90 | cli.j(longOpt:'josm_input', args:1, argName:"josm_input", "Input file for the JOSM imagery list (xml). Default is $josmInputFile (current directory).") |
---|
91 | cli.i(longOpt:'ignore_input', args:1, argName:"ignore_input", "Input file for the ignore list. Default is $ignoreInputFile (current directory).") |
---|
92 | cli.s(longOpt:'shorten', "shorten the output, so it is easier to read in a console window") |
---|
93 | cli.n(longOpt:'noskip', argName:"noskip", "don't skip known entries") |
---|
94 | cli.x(longOpt:'xhtmlbody', argName:"xhtmlbody", "create XHTML body for display in a web page") |
---|
95 | cli.X(longOpt:'xhtml', argName:"xhtml", "create XHTML for display in a web page") |
---|
96 | cli.p(longOpt:'elixml', args:1, argName:"elixml", "ELI entries for use in JOSM as XML file (incomplete)") |
---|
97 | cli.q(longOpt:'josmxml', args:1, argName:"josmxml", "JOSM entries reoutput as XML file (incomplete)") |
---|
98 | cli.m(longOpt:'noeli', argName:"noeli", "don't show output for ELI problems") |
---|
99 | cli.h(longOpt:'help', "show this help") |
---|
100 | options = cli.parse(args) |
---|
101 | |
---|
102 | if (options.h) { |
---|
103 | cli.usage() |
---|
104 | System.exit(0) |
---|
105 | } |
---|
106 | if (options.eli_input) { |
---|
107 | eliInputFile = options.eli_input |
---|
108 | } |
---|
109 | if (options.josm_input) { |
---|
110 | josmInputFile = options.josm_input |
---|
111 | } |
---|
112 | if (options.ignore_input) { |
---|
113 | ignoreInputFile = options.ignore_input |
---|
114 | } |
---|
115 | if (options.output && options.output != "-") { |
---|
116 | outputFile = new FileOutputStream(options.output) |
---|
117 | outputStream = new OutputStreamWriter(outputFile, "UTF-8") |
---|
118 | } |
---|
119 | } |
---|
120 | |
---|
121 | void loadSkip() { |
---|
122 | def fr = new InputStreamReader(new FileInputStream(ignoreInputFile), "UTF-8") |
---|
123 | def line |
---|
124 | |
---|
125 | while((line = fr.readLine()) != null) { |
---|
126 | def res = (line =~ /^\|\| *(ELI|Ignore) *\|\| *\{\{\{(.+)\}\}\} *\|\|/) |
---|
127 | if(res.count) |
---|
128 | { |
---|
129 | if(res[0][1].equals("Ignore")) { |
---|
130 | skip[res[0][2]] = "green" |
---|
131 | } else { |
---|
132 | skip[res[0][2]] = "darkgoldenrod" |
---|
133 | } |
---|
134 | } |
---|
135 | } |
---|
136 | } |
---|
137 | |
---|
138 | void myprintlnfinal(String s) { |
---|
139 | if(outputStream != null) { |
---|
140 | outputStream.write(s+System.getProperty("line.separator")) |
---|
141 | } else { |
---|
142 | println s |
---|
143 | } |
---|
144 | } |
---|
145 | |
---|
146 | void myprintln(String s) { |
---|
147 | if(skip.containsKey(s)) { |
---|
148 | String color = skip.get(s) |
---|
149 | skip.remove(s) |
---|
150 | if(options.xhtmlbody || options.xhtml) { |
---|
151 | s = "<pre style=\"margin:3px;color:"+color+"\">"+s.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">")+"</pre>" |
---|
152 | } |
---|
153 | if (!options.noskip) { |
---|
154 | return |
---|
155 | } |
---|
156 | } else if(options.xhtmlbody || options.xhtml) { |
---|
157 | String color = s.startsWith("***") ? "black" : ((s.startsWith("+ ") || s.startsWith("+++ ELI")) ? "blue" : (s.startsWith("#") ? "indigo" : "red")) |
---|
158 | s = "<pre style=\"margin:3px;color:"+color+"\">"+s.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">")+"</pre>" |
---|
159 | } |
---|
160 | if ((s.startsWith("+ ") || s.startsWith("+++ ELI") || s.startsWith("#")) && options.noeli) { |
---|
161 | return |
---|
162 | } |
---|
163 | myprintlnfinal(s) |
---|
164 | } |
---|
165 | |
---|
166 | void start() { |
---|
167 | if (options.xhtml) { |
---|
168 | myprintlnfinal "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n" |
---|
169 | myprintlnfinal "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/><title>JOSM - ELI differences</title></head><body>\n" |
---|
170 | } |
---|
171 | } |
---|
172 | |
---|
173 | void end() { |
---|
174 | for (def s: skip.keySet()) { |
---|
175 | myprintln "+++ Obsolete skip entry: " + s |
---|
176 | } |
---|
177 | if (options.xhtml) { |
---|
178 | myprintlnfinal "</body></html>\n" |
---|
179 | } |
---|
180 | } |
---|
181 | |
---|
182 | void loadELIEntries() { |
---|
183 | FileReader fr = new FileReader(eliInputFile) |
---|
184 | JsonReader jr = Json.createReader(fr) |
---|
185 | eliEntries = jr.readObject().get("features") |
---|
186 | jr.close() |
---|
187 | |
---|
188 | for (def e : eliEntries) { |
---|
189 | def url = getUrlStripped(e) |
---|
190 | if (url.contains("{z}")) { |
---|
191 | myprintln "+++ ELI-URL uses {z} instead of {zoom}: "+url |
---|
192 | url = url.replace("{z}","{zoom}") |
---|
193 | } |
---|
194 | if (eliUrls.containsKey(url)) { |
---|
195 | myprintln "+++ ELI-URL is not unique: "+url |
---|
196 | } else { |
---|
197 | eliUrls.put(url, e) |
---|
198 | } |
---|
199 | } |
---|
200 | myprintln "*** Loaded ${eliEntries.size()} entries (ELI). ***" |
---|
201 | } |
---|
202 | String cdata(def s, boolean escape = false) { |
---|
203 | if(escape) { |
---|
204 | return s.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">") |
---|
205 | } else if(s =~ /[<>&]/) |
---|
206 | return "<![CDATA[$s]]>" |
---|
207 | return s |
---|
208 | } |
---|
209 | |
---|
210 | String maininfo(def entry, String offset) { |
---|
211 | String t = getType(entry) |
---|
212 | String res = offset + "<type>$t</type>\n" |
---|
213 | res += offset + "<url>${cdata(getUrl(entry))}</url>\n" |
---|
214 | if(getMinZoom(entry) != null) |
---|
215 | res += offset + "<min-zoom>${getMinZoom(entry)}</min-zoom>\n" |
---|
216 | if(getMaxZoom(entry) != null) |
---|
217 | res += offset + "<max-zoom>${getMaxZoom(entry)}</max-zoom>\n" |
---|
218 | if (t == "wms") { |
---|
219 | def p = getProjections(entry) |
---|
220 | if (p) { |
---|
221 | res += offset + "<projections>\n" |
---|
222 | for (def c : p) |
---|
223 | res += offset + " <code>$c</code>\n" |
---|
224 | res += offset + "</projections>\n" |
---|
225 | } |
---|
226 | } |
---|
227 | return res |
---|
228 | } |
---|
229 | |
---|
230 | void printentries(def entries, def stream) { |
---|
231 | DecimalFormat df = new DecimalFormat("#.#######") |
---|
232 | df.setRoundingMode(java.math.RoundingMode.CEILING) |
---|
233 | stream.write "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" |
---|
234 | stream.write "<imagery xmlns=\"http://josm.openstreetmap.de/maps-1.0\">\n" |
---|
235 | for (def e : entries) { |
---|
236 | def best = "eli-best".equals(getQuality(e)) |
---|
237 | stream.write " <entry"+(best ? " eli-best=\"true\"" : "" )+">\n" |
---|
238 | stream.write " <name>${cdata(getName(e), true)}</name>\n" |
---|
239 | stream.write " <id>${getId(e)}</id>\n" |
---|
240 | def t |
---|
241 | if((t = getDate(e))) |
---|
242 | stream.write " <date>$t</date>\n" |
---|
243 | if((t = getCountryCode(e))) |
---|
244 | stream.write " <country-code>$t</country-code>\n" |
---|
245 | if((getDefault(e))) |
---|
246 | stream.write " <default>true</default>\n" |
---|
247 | stream.write maininfo(e, " ") |
---|
248 | if((t = getAttributionText(e))) |
---|
249 | stream.write " <attribution-text mandatory=\"true\">${cdata(t, true)}</attribution-text>\n" |
---|
250 | if((t = getAttributionUrl(e))) |
---|
251 | stream.write " <attribution-url>${cdata(t)}</attribution-url>\n" |
---|
252 | if((t = getLogoImage(e))) |
---|
253 | stream.write " <logo-image>${cdata(t, true)}</logo-image>\n" |
---|
254 | if((t = getLogoUrl(e))) |
---|
255 | stream.write " <logo-url>${cdata(t)}</logo-url>\n" |
---|
256 | if((t = getTermsOfUseText(e))) |
---|
257 | stream.write " <terms-of-use-text>${cdata(t, true)}</terms-of-use-text>\n" |
---|
258 | if((t = getTermsOfUseUrl(e))) |
---|
259 | stream.write " <terms-of-use-url>${cdata(t)}</terms-of-use-url>\n" |
---|
260 | if((t = getPermissionReferenceUrl(e))) |
---|
261 | stream.write " <permission-ref>${cdata(t)}</permission-ref>\n" |
---|
262 | if((getValidGeoreference(e))) |
---|
263 | stream.write " <valid-georeference>true</valid-georeference>\n" |
---|
264 | if((t = getIcon(e))) |
---|
265 | stream.write " <icon>${cdata(t)}</icon>\n" |
---|
266 | for (def d : getDescriptions(e)) { |
---|
267 | stream.write " <description lang=\"${d.getKey()}\">${d.getValue()}</description>\n" |
---|
268 | } |
---|
269 | for (def m : getMirrors(e)) { |
---|
270 | stream.write " <mirror>\n"+maininfo(m, " ")+" </mirror>\n" |
---|
271 | } |
---|
272 | def minlat = 1000 |
---|
273 | def minlon = 1000 |
---|
274 | def maxlat = -1000 |
---|
275 | def maxlon = -1000 |
---|
276 | def shapes = "" |
---|
277 | def sep = "\n " |
---|
278 | for(def s: getShapes(e)) { |
---|
279 | shapes += " <shape>" |
---|
280 | def i = 0 |
---|
281 | for(def p: s.getPoints()) { |
---|
282 | def lat = p.getLat() |
---|
283 | def lon = p.getLon() |
---|
284 | if(lat > maxlat) maxlat = lat |
---|
285 | if(lon > maxlon) maxlon = lon |
---|
286 | if(lat < minlat) minlat = lat |
---|
287 | if(lon < minlon) minlon = lon |
---|
288 | if(!(i++%3)) { |
---|
289 | shapes += sep + " " |
---|
290 | } |
---|
291 | shapes += "<point lat='${df.format(lat)}' lon='${df.format(lon)}'/>" |
---|
292 | } |
---|
293 | shapes += sep + "</shape>\n" |
---|
294 | } |
---|
295 | if(shapes) { |
---|
296 | stream.write " <bounds min-lat='${df.format(minlat)}' min-lon='${df.format(minlon)}' max-lat='${df.format(maxlat)}' max-lon='${df.format(maxlon)}'>\n" |
---|
297 | stream.write shapes + " </bounds>\n" |
---|
298 | } |
---|
299 | stream.write " </entry>\n" |
---|
300 | } |
---|
301 | stream.write "</imagery>\n" |
---|
302 | stream.close() |
---|
303 | } |
---|
304 | |
---|
305 | void loadJosmEntries() { |
---|
306 | def reader = new ImageryReader(josmInputFile) |
---|
307 | josmEntries = reader.parse() |
---|
308 | |
---|
309 | for (def e : josmEntries) { |
---|
310 | def url = getUrlStripped(e) |
---|
311 | if (url.contains("{z}")) { |
---|
312 | myprintln "+++ JOSM-URL uses {z} instead of {zoom}: "+url |
---|
313 | url = url.replace("{z}","{zoom}") |
---|
314 | } |
---|
315 | if (josmUrls.containsKey(url)) { |
---|
316 | myprintln "+++ JOSM-URL is not unique: "+url |
---|
317 | } else { |
---|
318 | josmUrls.put(url, e) |
---|
319 | } |
---|
320 | for (def m : e.getMirrors()) { |
---|
321 | url = getUrlStripped(m) |
---|
322 | m.origName = m.getOriginalName().replaceAll(" mirror server( \\d+)?","") |
---|
323 | if (josmUrls.containsKey(url)) { |
---|
324 | myprintln "+++ JOSM-Mirror-URL is not unique: "+url |
---|
325 | } else { |
---|
326 | josmUrls.put(url, m) |
---|
327 | josmMirrors.put(url, m) |
---|
328 | } |
---|
329 | } |
---|
330 | } |
---|
331 | myprintln "*** Loaded ${josmEntries.size()} entries (JOSM). ***" |
---|
332 | } |
---|
333 | |
---|
334 | List inOneButNotTheOther(Map m1, Map m2, String code, String https) { |
---|
335 | def l = [] |
---|
336 | def k = new LinkedList<String>(m1.keySet()) |
---|
337 | for (def url : k) { |
---|
338 | if (!m2.containsKey(url)) { |
---|
339 | String urlhttps = url.replace("http:","https:") |
---|
340 | if(!https || !m2.containsKey(urlhttps)) |
---|
341 | { |
---|
342 | def name = getName(m1.get(url)) |
---|
343 | l += code+" "+getDescription(m1.get(url)) |
---|
344 | } |
---|
345 | else |
---|
346 | { |
---|
347 | l += https+" Missing https: "+getDescription(m1.get(url)) |
---|
348 | m1.put(urlhttps, m1.get(url)) |
---|
349 | m1.remove(url) |
---|
350 | } |
---|
351 | } |
---|
352 | } |
---|
353 | l.sort() |
---|
354 | } |
---|
355 | |
---|
356 | void checkInOneButNotTheOther() { |
---|
357 | def l1 = inOneButNotTheOther(eliUrls, josmUrls, "-", "+") |
---|
358 | myprintln "*** URLs found in ELI but not in JOSM (${l1.size()}): ***" |
---|
359 | if (!l1.isEmpty()) { |
---|
360 | for (def l : l1) { |
---|
361 | myprintln l |
---|
362 | } |
---|
363 | } |
---|
364 | |
---|
365 | def l2 = inOneButNotTheOther(josmUrls, eliUrls, "+", "") |
---|
366 | myprintln "*** URLs found in JOSM but not in ELI (${l2.size()}): ***" |
---|
367 | if (!l2.isEmpty()) { |
---|
368 | for (def l : l2) { |
---|
369 | myprintln l |
---|
370 | } |
---|
371 | } |
---|
372 | } |
---|
373 | |
---|
374 | void checkCommonEntries() { |
---|
375 | myprintln "*** Same URL, but different name: ***" |
---|
376 | for (def url : eliUrls.keySet()) { |
---|
377 | def e = eliUrls.get(url) |
---|
378 | if (!josmUrls.containsKey(url)) continue |
---|
379 | def j = josmUrls.get(url) |
---|
380 | def ename = getName(e).replace("'","\u2019") |
---|
381 | def jname = getName(j).replace("'","\u2019") |
---|
382 | if (!ename.equals(jname)) { |
---|
383 | myprintln "* Name differs ('${getName(e)}' != '${getName(j)}'): ${getUrl(j)}" |
---|
384 | } |
---|
385 | } |
---|
386 | |
---|
387 | myprintln "*** Same URL, but different Id: ***" |
---|
388 | for (def url : eliUrls.keySet()) { |
---|
389 | def e = eliUrls.get(url) |
---|
390 | if (!josmUrls.containsKey(url)) continue |
---|
391 | def j = josmUrls.get(url) |
---|
392 | def ename = getId(e) |
---|
393 | def jname = getId(j) |
---|
394 | if (!ename.equals(jname)) { |
---|
395 | myprintln "# Id differs ('${getId(e)}' != '${getId(j)}'): ${getUrl(j)}" |
---|
396 | } |
---|
397 | } |
---|
398 | |
---|
399 | myprintln "*** Same URL, but different type: ***" |
---|
400 | for (def url : eliUrls.keySet()) { |
---|
401 | def e = eliUrls.get(url) |
---|
402 | if (!josmUrls.containsKey(url)) continue |
---|
403 | def j = josmUrls.get(url) |
---|
404 | if (!getType(e).equals(getType(j))) { |
---|
405 | myprintln "* Type differs (${getType(e)} != ${getType(j)}): ${getName(j)} - ${getUrl(j)}" |
---|
406 | } |
---|
407 | } |
---|
408 | |
---|
409 | myprintln "*** Same URL, but different zoom bounds: ***" |
---|
410 | for (def url : eliUrls.keySet()) { |
---|
411 | def e = eliUrls.get(url) |
---|
412 | if (!josmUrls.containsKey(url)) continue |
---|
413 | def j = josmUrls.get(url) |
---|
414 | |
---|
415 | Integer eMinZoom = getMinZoom(e) |
---|
416 | Integer jMinZoom = getMinZoom(j) |
---|
417 | if (eMinZoom != jMinZoom && !(eMinZoom == 0 && jMinZoom == null)) { |
---|
418 | myprintln "* Minzoom differs (${eMinZoom} != ${jMinZoom}): ${getDescription(j)}" |
---|
419 | } |
---|
420 | Integer eMaxZoom = getMaxZoom(e) |
---|
421 | Integer jMaxZoom = getMaxZoom(j) |
---|
422 | if (eMaxZoom != jMaxZoom) { |
---|
423 | myprintln "* Maxzoom differs (${eMaxZoom} != ${jMaxZoom}): ${getDescription(j)}" |
---|
424 | } |
---|
425 | } |
---|
426 | |
---|
427 | myprintln "*** Same URL, but different country code: ***" |
---|
428 | for (def url : eliUrls.keySet()) { |
---|
429 | def e = eliUrls.get(url) |
---|
430 | if (!josmUrls.containsKey(url)) continue |
---|
431 | def j = josmUrls.get(url) |
---|
432 | if (!getCountryCode(e).equals(getCountryCode(j))) { |
---|
433 | myprintln "* Country code differs (${getCountryCode(e)} != ${getCountryCode(j)}): ${getDescription(j)}" |
---|
434 | } |
---|
435 | } |
---|
436 | myprintln "*** Same URL, but different quality: ***" |
---|
437 | for (def url : eliUrls.keySet()) { |
---|
438 | def e = eliUrls.get(url) |
---|
439 | if (!josmUrls.containsKey(url)) { |
---|
440 | def q = getQuality(e) |
---|
441 | if("eli-best".equals(q)) { |
---|
442 | myprintln "- Quality best entry not in JOSM for ${getDescription(e)}" |
---|
443 | } |
---|
444 | continue |
---|
445 | } |
---|
446 | def j = josmUrls.get(url) |
---|
447 | if (!getQuality(e).equals(getQuality(j))) { |
---|
448 | myprintln "* Quality differs (${getQuality(e)} != ${getQuality(j)}): ${getDescription(j)}" |
---|
449 | } |
---|
450 | } |
---|
451 | myprintln "*** Same URL, but different dates: ***" |
---|
452 | for (def url : eliUrls.keySet()) { |
---|
453 | def ed = getDate(eliUrls.get(url)) |
---|
454 | if (!josmUrls.containsKey(url)) continue |
---|
455 | def j = josmUrls.get(url) |
---|
456 | def jd = getDate(j) |
---|
457 | // The forms 2015;- or -;2015 or 2015;2015 are handled equal to 2015 |
---|
458 | String ef = ed.replaceAll("\\A-;","").replaceAll(";-\\z","").replaceAll("\\A([0-9-]+);\\1\\z","\$1") |
---|
459 | // ELI has a strange and inconsistent used end_date definition, so we try again with subtraction by one |
---|
460 | String ed2 = ed |
---|
461 | def reg = (ed =~ /^(.*;)(\d\d\d\d)(-(\d\d)(-(\d\d))?)?$/) |
---|
462 | if(reg != null && reg.count == 1) { |
---|
463 | Calendar cal = Calendar.getInstance() |
---|
464 | 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) |
---|
465 | cal.add(Calendar.DAY_OF_MONTH, -1) |
---|
466 | ed2 = reg[0][1] + cal.get(Calendar.YEAR) |
---|
467 | if (reg[0][4] != null) |
---|
468 | ed2 += "-" + String.format("%02d", cal.get(Calendar.MONTH)+1) |
---|
469 | if (reg[0][6] != null) |
---|
470 | ed2 += "-" + String.format("%02d", cal.get(Calendar.DAY_OF_MONTH)) |
---|
471 | } |
---|
472 | String ef2 = ed2.replaceAll("\\A-;","").replaceAll(";-\\z","").replaceAll("\\A([0-9-]+);\\1\\z","\$1") |
---|
473 | if (!ed.equals(jd) && !ef.equals(jd) && !ed2.equals(jd) && !ef2.equals(jd)) { |
---|
474 | String t = "'${ed}'" |
---|
475 | if (!ed.equals(ef)) { |
---|
476 | t += " or '${ef}'" |
---|
477 | } |
---|
478 | if (jd.isEmpty()) { |
---|
479 | myprintln "- Missing JOSM date (${t}): ${getDescription(j)}" |
---|
480 | } else if (!ed.isEmpty()) { |
---|
481 | myprintln "* Date differs ('${t}' != '${jd}'): ${getDescription(j)}" |
---|
482 | } else if (!options.nomissingeli) { |
---|
483 | myprintln "+ Missing ELI date ('${jd}'): ${getDescription(j)}" |
---|
484 | } |
---|
485 | } |
---|
486 | } |
---|
487 | myprintln "*** Same URL, but different information: ***" |
---|
488 | for (def url : eliUrls.keySet()) { |
---|
489 | if (!josmUrls.containsKey(url)) continue |
---|
490 | def e = eliUrls.get(url) |
---|
491 | def j = josmUrls.get(url) |
---|
492 | |
---|
493 | def et = getDescriptions(e) |
---|
494 | def jt = getDescriptions(j) |
---|
495 | et = (et.size() > 0) ? et["en"] : "" |
---|
496 | jt = (jt.size() > 0) ? jt["en"] : "" |
---|
497 | if (!et.equals(jt)) { |
---|
498 | if (!jt) { |
---|
499 | myprintln "- Missing JOSM description (${et}): ${getDescription(j)}" |
---|
500 | } else if (et) { |
---|
501 | myprintln "* Description differs ('${et}' != '${jt}'): ${getDescription(j)}" |
---|
502 | } else if (!options.nomissingeli) { |
---|
503 | myprintln "+ Missing ELI description ('${jt}'): ${getDescription(j)}" |
---|
504 | } |
---|
505 | } |
---|
506 | |
---|
507 | et = getPermissionReferenceUrl(e) |
---|
508 | jt = getPermissionReferenceUrl(j) |
---|
509 | if (!jt) jt = getTermsOfUseUrl(j) |
---|
510 | if (!et.equals(jt)) { |
---|
511 | if (!jt) { |
---|
512 | myprintln "- Missing JOSM license URL (${et}): ${getDescription(j)}" |
---|
513 | } else if (et) { |
---|
514 | myprintln "* License URL differs ('${et}' != '${jt}'): ${getDescription(j)}" |
---|
515 | } else if (!options.nomissingeli) { |
---|
516 | myprintln "+ Missing ELI license URL ('${jt}'): ${getDescription(j)}" |
---|
517 | } |
---|
518 | } |
---|
519 | |
---|
520 | et = getAttributionUrl(e) |
---|
521 | jt = getAttributionUrl(j) |
---|
522 | if (!et.equals(jt)) { |
---|
523 | if (!jt) { |
---|
524 | myprintln "- Missing JOSM attribution URL (${et}): ${getDescription(j)}" |
---|
525 | } else if (et) { |
---|
526 | def ethttps = et.replace("http:","https:") |
---|
527 | if(jt.equals(ethttps)) { |
---|
528 | myprintln "+ Attribution URL differs ('${et}' != '${jt}'): ${getDescription(j)}" |
---|
529 | } else { |
---|
530 | myprintln "* Attribution URL differs ('${et}' != '${jt}'): ${getDescription(j)}" |
---|
531 | } |
---|
532 | } else if (!options.nomissingeli) { |
---|
533 | myprintln "+ Missing ELI attribution URL ('${jt}'): ${getDescription(j)}" |
---|
534 | } |
---|
535 | } |
---|
536 | |
---|
537 | et = getAttributionText(e) |
---|
538 | jt = getAttributionText(j) |
---|
539 | if (!et.equals(jt)) { |
---|
540 | if (!jt) { |
---|
541 | myprintln "- Missing JOSM attribution text (${et}): ${getDescription(j)}" |
---|
542 | } else if (et) { |
---|
543 | myprintln "* Attribution text differs ('${et}' != '${jt}'): ${getDescription(j)}" |
---|
544 | } else if (!options.nomissingeli) { |
---|
545 | myprintln "+ Missing ELI attribution text ('${jt}'): ${getDescription(j)}" |
---|
546 | } |
---|
547 | } |
---|
548 | |
---|
549 | et = getProjections(e) |
---|
550 | jt = getProjections(j) |
---|
551 | if (et) { et = new LinkedList(et); Collections.sort(et); et = String.join(" ", et) } |
---|
552 | if (jt) { jt = new LinkedList(jt); Collections.sort(jt); jt = String.join(" ", jt) } |
---|
553 | if (!et.equals(jt)) { |
---|
554 | if (!jt) { |
---|
555 | myprintln "- Missing JOSM projections (${et}): ${getDescription(j)}" |
---|
556 | } else if (et) { |
---|
557 | myprintln "* Projections differ ('${et}' != '${jt}'): ${getDescription(j)}" |
---|
558 | } else if (!options.nomissingeli && !getType(e).equals("tms")) { |
---|
559 | myprintln "+ Missing ELI projections ('${jt}'): ${getDescription(j)}" |
---|
560 | } |
---|
561 | } |
---|
562 | |
---|
563 | et = getDefault(e) |
---|
564 | jt = getDefault(j) |
---|
565 | if (!et.equals(jt)) { |
---|
566 | if (!jt) { |
---|
567 | myprintln "- Missing JOSM default: ${getDescription(j)}" |
---|
568 | } else if (!options.nomissingeli) { |
---|
569 | myprintln "+ Missing ELI default: ${getDescription(j)}" |
---|
570 | } |
---|
571 | } |
---|
572 | } |
---|
573 | myprintln "*** Mismatching shapes: ***" |
---|
574 | for (def url : josmUrls.keySet()) { |
---|
575 | def j = josmUrls.get(url) |
---|
576 | def num = 1 |
---|
577 | for (def shape : getShapes(j)) { |
---|
578 | def p = shape.getPoints() |
---|
579 | if(!p[0].equals(p[p.size()-1])) { |
---|
580 | myprintln "+++ JOSM shape $num unclosed: ${getDescription(j)}" |
---|
581 | } |
---|
582 | for (def nump = 1; nump < p.size(); ++nump) { |
---|
583 | if (p[nump-1] == p[nump]) { |
---|
584 | myprintln "+++ JOSM shape $num double point at ${nump-1}: ${getDescription(j)}" |
---|
585 | } |
---|
586 | } |
---|
587 | ++num |
---|
588 | } |
---|
589 | } |
---|
590 | for (def url : eliUrls.keySet()) { |
---|
591 | def e = eliUrls.get(url) |
---|
592 | def num = 1 |
---|
593 | def s = getShapes(e) |
---|
594 | for (def shape : s) { |
---|
595 | def p = shape.getPoints() |
---|
596 | if(!p[0].equals(p[p.size()-1]) && !options.nomissingeli) { |
---|
597 | myprintln "+++ ELI shape $num unclosed: ${getDescription(e)}" |
---|
598 | } |
---|
599 | for (def nump = 1; nump < p.size(); ++nump) { |
---|
600 | if (p[nump-1] == p[nump]) { |
---|
601 | myprintln "+++ ELI shape $num double point at ${nump-1}: ${getDescription(e)}" |
---|
602 | } |
---|
603 | } |
---|
604 | ++num |
---|
605 | } |
---|
606 | if (!josmUrls.containsKey(url)) { |
---|
607 | continue |
---|
608 | } |
---|
609 | def j = josmUrls.get(url) |
---|
610 | def js = getShapes(j) |
---|
611 | if(!s.size() && js.size()) { |
---|
612 | if(!options.nomissingeli) { |
---|
613 | myprintln "+ No ELI shape: ${getDescription(j)}" |
---|
614 | } |
---|
615 | } else if(!js.size() && s.size()) { |
---|
616 | // don't report boundary like 5 point shapes as difference |
---|
617 | if (s.size() != 1 || s[0].getPoints().size() != 5) { |
---|
618 | myprintln "- No JOSM shape: ${getDescription(j)}" |
---|
619 | } |
---|
620 | } else if(s.size() != js.size()) { |
---|
621 | myprintln "* Different number of shapes (${s.size()} != ${js.size()}): ${getDescription(j)}" |
---|
622 | } else { |
---|
623 | for(def nums = 0; nums < s.size(); ++nums) { |
---|
624 | def ep = s[nums].getPoints() |
---|
625 | def jp = js[nums].getPoints() |
---|
626 | if(ep.size() != jp.size()) { |
---|
627 | myprintln "* Different number of points for shape ${nums+1} (${ep.size()} ! = ${jp.size()})): ${getDescription(j)}" |
---|
628 | } else { |
---|
629 | for(def nump = 0; nump < ep.size(); ++nump) { |
---|
630 | def ept = ep[nump] |
---|
631 | def jpt = jp[nump] |
---|
632 | if(Math.abs(ept.getLat()-jpt.getLat()) > 0.000001 || Math.abs(ept.getLon()-jpt.getLon()) > 0.000001) { |
---|
633 | myprintln "* Different coordinate for point ${nump+1} of shape ${nums+1}: ${getDescription(j)}" |
---|
634 | nump = ep.size() |
---|
635 | num = s.size() |
---|
636 | } |
---|
637 | } |
---|
638 | } |
---|
639 | } |
---|
640 | } |
---|
641 | } |
---|
642 | myprintln "*** Mismatching icons: ***" |
---|
643 | for (def url : eliUrls.keySet()) { |
---|
644 | def e = eliUrls.get(url) |
---|
645 | if (!josmUrls.containsKey(url)) { |
---|
646 | continue |
---|
647 | } |
---|
648 | def j = josmUrls.get(url) |
---|
649 | def ij = getIcon(j) |
---|
650 | def ie = getIcon(e) |
---|
651 | if(ij != null && ie == null) { |
---|
652 | if(!options.nomissingeli) { |
---|
653 | myprintln "+ No ELI icon: ${getDescription(j)}" |
---|
654 | } |
---|
655 | } else if(ij == null && ie != null) { |
---|
656 | myprintln "- No JOSM icon: ${getDescription(j)}" |
---|
657 | } else if(!ij.equals(ie)) { |
---|
658 | myprintln "* Different icons: ${getDescription(j)}" |
---|
659 | } |
---|
660 | } |
---|
661 | myprintln "*** Miscellaneous checks: ***" |
---|
662 | def josmIds = new HashMap<String, ImageryInfo>() |
---|
663 | for (def url : josmUrls.keySet()) { |
---|
664 | def j = josmUrls.get(url) |
---|
665 | def id = getId(j) |
---|
666 | if("wms".equals(getType(j)) && !getProjections(j)) { |
---|
667 | myprintln "* WMS without projections: ${getDescription(j)}" |
---|
668 | } |
---|
669 | if(josmMirrors.containsKey(url)) { |
---|
670 | continue |
---|
671 | } |
---|
672 | if(id == null) { |
---|
673 | myprintln "* No JOSM-ID: ${getDescription(j)}" |
---|
674 | } else if(josmIds.containsKey(id)) { |
---|
675 | myprintln "* JOSM-ID ${id} not unique: ${getDescription(j)}" |
---|
676 | } else { |
---|
677 | josmIds.put(id, j) |
---|
678 | } |
---|
679 | def d = getDate(j) |
---|
680 | if(!d.isEmpty()) { |
---|
681 | def reg = (d =~ /^(-|(\d\d\d\d)(-(\d\d)(-(\d\d))?)?)(;(-|(\d\d\d\d)(-(\d\d)(-(\d\d))?)?))?$/) |
---|
682 | if(reg == null || reg.count != 1) { |
---|
683 | myprintln "* JOSM-Date '${d}' is strange: ${getDescription(j)}" |
---|
684 | } else { |
---|
685 | try { |
---|
686 | def first = verifyDate(reg[0][2],reg[0][4],reg[0][6]) |
---|
687 | def second = verifyDate(reg[0][9],reg[0][11],reg[0][13]) |
---|
688 | if(second.compareTo(first) < 0) { |
---|
689 | myprintln "* JOSM-Date '${d}' is strange (second earlier than first): ${getDescription(j)}" |
---|
690 | } |
---|
691 | } |
---|
692 | catch (Exception e) { |
---|
693 | myprintln "* JOSM-Date '${d}' is strange (${e.getMessage()}): ${getDescription(j)}" |
---|
694 | } |
---|
695 | } |
---|
696 | } |
---|
697 | if(getAttributionUrl(j) && !getAttributionText(j)) { |
---|
698 | myprintln "* Attribution link without text: ${getDescription(j)}" |
---|
699 | } |
---|
700 | if(getLogoUrl(j) && !getLogoImage(j)) { |
---|
701 | myprintln "* Logo link without image: ${getDescription(j)}" |
---|
702 | } |
---|
703 | if(getTermsOfUseText(j) && !getTermsOfUseUrl(j)) { |
---|
704 | myprintln "* Terms of Use text without link: ${getDescription(j)}" |
---|
705 | } |
---|
706 | def js = getShapes(j) |
---|
707 | if(js.size()) { |
---|
708 | def minlat = 1000 |
---|
709 | def minlon = 1000 |
---|
710 | def maxlat = -1000 |
---|
711 | def maxlon = -1000 |
---|
712 | for(def s: js) { |
---|
713 | for(def p: s.getPoints()) { |
---|
714 | def lat = p.getLat() |
---|
715 | def lon = p.getLon() |
---|
716 | if(lat > maxlat) maxlat = lat |
---|
717 | if(lon > maxlon) maxlon = lon |
---|
718 | if(lat < minlat) minlat = lat |
---|
719 | if(lon < minlon) minlon = lon |
---|
720 | } |
---|
721 | } |
---|
722 | def b = j.getBounds() |
---|
723 | if(b.getMinLat() != minlat || b.getMinLon() != minlon || b.getMaxLat() != maxlat || b.getMaxLon() != maxlon) { |
---|
724 | 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)}" |
---|
725 | } |
---|
726 | } |
---|
727 | } |
---|
728 | } |
---|
729 | |
---|
730 | /** |
---|
731 | * Utility functions that allow uniform access for both ImageryInfo and JsonObject. |
---|
732 | */ |
---|
733 | static String getUrl(Object e) { |
---|
734 | if (e instanceof ImageryInfo) return e.url |
---|
735 | return e.get("properties").getString("url") |
---|
736 | } |
---|
737 | static String getUrlStripped(Object e) { |
---|
738 | return getUrl(e).replaceAll("\\?(apikey|access_token)=.*","") |
---|
739 | } |
---|
740 | static String getDate(Object e) { |
---|
741 | if (e instanceof ImageryInfo) return e.date ? e.date : "" |
---|
742 | def p = e.get("properties") |
---|
743 | def start = p.containsKey("start_date") ? p.getString("start_date") : "" |
---|
744 | def end = p.containsKey("end_date") ? p.getString("end_date") : "" |
---|
745 | if(!start.isEmpty() && !end.isEmpty()) |
---|
746 | return start+";"+end |
---|
747 | else if(!start.isEmpty()) |
---|
748 | return start+";-" |
---|
749 | else if(!end.isEmpty()) |
---|
750 | return "-;"+end |
---|
751 | return "" |
---|
752 | } |
---|
753 | static Date verifyDate(String year, String month, String day) { |
---|
754 | def date |
---|
755 | if(year == null) { |
---|
756 | date = "3000-01-01" |
---|
757 | } else { |
---|
758 | date = year + "-" + (month == null ? "01" : month) + "-" + (day == null ? "01" : day) |
---|
759 | } |
---|
760 | def df = new java.text.SimpleDateFormat("yyyy-MM-dd") |
---|
761 | df.setLenient(false) |
---|
762 | return df.parse(date) |
---|
763 | } |
---|
764 | static String getId(Object e) { |
---|
765 | if (e instanceof ImageryInfo) return e.getId() |
---|
766 | return e.get("properties").getString("id") |
---|
767 | } |
---|
768 | static String getName(Object e) { |
---|
769 | if (e instanceof ImageryInfo) return e.getOriginalName() |
---|
770 | return e.get("properties").getString("name") |
---|
771 | } |
---|
772 | static List<Object> getMirrors(Object e) { |
---|
773 | if (e instanceof ImageryInfo) return e.getMirrors() |
---|
774 | return [] |
---|
775 | } |
---|
776 | static List<Object> getProjections(Object e) { |
---|
777 | def r |
---|
778 | if (e instanceof ImageryInfo) { |
---|
779 | r = e.getServerProjections() |
---|
780 | } else { |
---|
781 | def s = e.get("properties").get("available_projections") |
---|
782 | if (s) { |
---|
783 | r = [] |
---|
784 | for (def p : s) |
---|
785 | r += p.getString() |
---|
786 | } |
---|
787 | } |
---|
788 | return r ? r : [] |
---|
789 | } |
---|
790 | static List<Shape> getShapes(Object e) { |
---|
791 | if (e instanceof ImageryInfo) { |
---|
792 | def bounds = e.getBounds() |
---|
793 | if(bounds != null) { |
---|
794 | return bounds.getShapes() |
---|
795 | } |
---|
796 | return [] |
---|
797 | } |
---|
798 | if(!e.isNull("geometry")) { |
---|
799 | def ex = e.get("geometry") |
---|
800 | if(ex != null && !ex.isNull("coordinates")) { |
---|
801 | def poly = ex.get("coordinates") |
---|
802 | List<Shape> l = [] |
---|
803 | for(def shapes: poly) { |
---|
804 | def s = new Shape() |
---|
805 | for(def point: shapes) { |
---|
806 | def lon = point[0].toString() |
---|
807 | def lat = point[1].toString() |
---|
808 | s.addPoint(lat, lon) |
---|
809 | } |
---|
810 | l.add(s) |
---|
811 | } |
---|
812 | return l |
---|
813 | } |
---|
814 | } |
---|
815 | return [] |
---|
816 | } |
---|
817 | static String getType(Object e) { |
---|
818 | if (e instanceof ImageryInfo) return e.getImageryType().getTypeString() |
---|
819 | return e.get("properties").getString("type") |
---|
820 | } |
---|
821 | static Integer getMinZoom(Object e) { |
---|
822 | if (e instanceof ImageryInfo) { |
---|
823 | if("wms".equals(getType(e)) && e.getName() =~ / mirror/) |
---|
824 | return null; |
---|
825 | int mz = e.getMinZoom() |
---|
826 | return mz == 0 ? null : mz |
---|
827 | } else { |
---|
828 | def num = e.get("properties").getJsonNumber("min_zoom") |
---|
829 | if (num == null) return null |
---|
830 | return num.intValue() |
---|
831 | } |
---|
832 | } |
---|
833 | static Integer getMaxZoom(Object e) { |
---|
834 | if (e instanceof ImageryInfo) { |
---|
835 | if("wms".equals(getType(e)) && e.getName() =~ / mirror/) |
---|
836 | return null; |
---|
837 | int mz = e.getMaxZoom() |
---|
838 | return mz == 0 ? null : mz |
---|
839 | } else { |
---|
840 | def num = e.get("properties").getJsonNumber("max_zoom") |
---|
841 | if (num == null) return null |
---|
842 | return num.intValue() |
---|
843 | } |
---|
844 | } |
---|
845 | static String getCountryCode(Object e) { |
---|
846 | if (e instanceof ImageryInfo) return "".equals(e.getCountryCode()) ? null : e.getCountryCode() |
---|
847 | return e.get("properties").getString("country_code", null) |
---|
848 | } |
---|
849 | static String getQuality(Object e) { |
---|
850 | if (e instanceof ImageryInfo) return e.isBestMarked() ? "eli-best" : null |
---|
851 | return (e.get("properties").containsKey("best") |
---|
852 | && e.get("properties").getBoolean("best")) ? "eli-best" : null |
---|
853 | } |
---|
854 | static String getIcon(Object e) { |
---|
855 | if (e instanceof ImageryInfo) return e.getIcon() |
---|
856 | return e.get("properties").getString("icon", null) |
---|
857 | } |
---|
858 | static String getAttributionText(Object e) { |
---|
859 | if (e instanceof ImageryInfo) return e.getAttributionText(0, null, null) |
---|
860 | try {return e.get("properties").get("attribution").getString("text", null)} catch (NullPointerException ex) {return null} |
---|
861 | } |
---|
862 | static String getAttributionUrl(Object e) { |
---|
863 | if (e instanceof ImageryInfo) return e.getAttributionLinkURL() |
---|
864 | try {return e.get("properties").get("attribution").getString("url", null)} catch (NullPointerException ex) {return null} |
---|
865 | } |
---|
866 | static String getTermsOfUseText(Object e) { |
---|
867 | if (e instanceof ImageryInfo) return e.getTermsOfUseText() |
---|
868 | return null |
---|
869 | } |
---|
870 | static String getTermsOfUseUrl(Object e) { |
---|
871 | if (e instanceof ImageryInfo) return e.getTermsOfUseURL() |
---|
872 | return null |
---|
873 | } |
---|
874 | static String getLogoImage(Object e) { |
---|
875 | if (e instanceof ImageryInfo) return e.getAttributionImageRaw() |
---|
876 | return null |
---|
877 | } |
---|
878 | static String getLogoUrl(Object e) { |
---|
879 | if (e instanceof ImageryInfo) return e.getAttributionImageURL() |
---|
880 | return null |
---|
881 | } |
---|
882 | static String getPermissionReferenceUrl(Object e) { |
---|
883 | if (e instanceof ImageryInfo) return e.getPermissionReferenceURL() |
---|
884 | return e.get("properties").getString("license_url", null) |
---|
885 | } |
---|
886 | static Map<String,String> getDescriptions(Object e) { |
---|
887 | Map<String,String> res = new HashMap<String, String>() |
---|
888 | if (e instanceof ImageryInfo) { |
---|
889 | String a = e.getDescription() |
---|
890 | if (a) res.put("en", a) |
---|
891 | } else { |
---|
892 | String a = e.get("properties").getString("description", null) |
---|
893 | if (a) res.put("en", a) |
---|
894 | } |
---|
895 | return res |
---|
896 | } |
---|
897 | static Boolean getValidGeoreference(Object e) { |
---|
898 | if (e instanceof ImageryInfo) return e.isGeoreferenceValid() |
---|
899 | return false |
---|
900 | } |
---|
901 | static Boolean getDefault(Object e) { |
---|
902 | if (e instanceof ImageryInfo) return e.isDefaultEntry() |
---|
903 | return e.get("properties").getBoolean("default", false) |
---|
904 | } |
---|
905 | String getDescription(Object o) { |
---|
906 | def url = getUrl(o) |
---|
907 | def cc = getCountryCode(o) |
---|
908 | if (cc == null) { |
---|
909 | def j = josmUrls.get(url) |
---|
910 | if (j != null) cc = getCountryCode(j) |
---|
911 | if (cc == null) { |
---|
912 | def e = eliUrls.get(url) |
---|
913 | if (e != null) cc = getCountryCode(e) |
---|
914 | } |
---|
915 | } |
---|
916 | if (cc == null) { |
---|
917 | cc = '' |
---|
918 | } else { |
---|
919 | cc = "[$cc] " |
---|
920 | } |
---|
921 | def d = cc + getName(o) + " - " + getUrl(o) |
---|
922 | if (options.shorten) { |
---|
923 | def MAXLEN = 140 |
---|
924 | if (d.length() > MAXLEN) d = d.substring(0, MAXLEN-1) + "..." |
---|
925 | } |
---|
926 | return d |
---|
927 | } |
---|
928 | } |
---|