Changeset 9505 in josm for trunk/scripts/sync_editor_imagery_index.groovy
- Timestamp:
- 2016-01-17T16:55:23+01:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/scripts/sync_editor_imagery_index.groovy
r9340 r9505 33 33 List<ImageryInfo> josmEntries; 34 34 JsonArray eiiEntries; 35 36 final static def EII_KNOWN_DUPLICATES = ["http://geolittoral.application.equipement.gouv.fr/wms/metropole?FORMAT=image/jpeg&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetMap&Layers=ortholittorale&SRS={proj}&WIDTH={width}&HEIGHT={height}&BBOX={bbox}"]37 final static def JOSM_KNOWN_DUPLICATES = ["http://geolittoral.application.equipement.gouv.fr/wms/metropole?FORMAT=image/jpeg&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetMap&Layers=ortholittorale&SRS={proj}&WIDTH={width}&HEIGHT={height}&BBOX={bbox}"]38 35 39 36 def eiiUrls = new HashMap<String, JsonObject>() … … 42 39 static String eiiInputFile = 'imagery.json' 43 40 static String josmInputFile = 'maps.xml' 44 41 static FileWriter outputFile = null 42 static BufferedWriter outputStream = null 43 static int skipCount = 0; 44 static def skipEntries = [:] 45 45 46 static def options 46 47 … … 51 52 parse_command_line_arguments(args) 52 53 def script = new sync_editor_imagery_index() 54 script.loadSkip() 53 55 script.loadJosmEntries() 54 println "*** Loaded ${script.josmEntries.size()} entries (JOSM). ***"55 56 script.loadEIIEntries() 56 println "*** Loaded ${script.eiiEntries.size()} entries (EII). ***"57 57 script.checkInOneButNotTheOther() 58 58 script.checkCommonEntries() 59 if(outputStream != null) { 60 outputStream.close(); 61 } 62 if(outputFile != null) { 63 outputFile.close(); 64 } 59 65 } 60 66 … … 64 70 static void parse_command_line_arguments(args) { 65 71 def cli = new CliBuilder() 66 cli._(longOpt:'eii_input', args:1, argName:"eii_input", "Input file for the editor imagery index (json). Default is $eiiInputFile (current directory).") 67 cli._(longOpt:'josm_input', args:1, argName:"josm_input", "Input file for the JOSM imagery list (xml). Default is $josmInputFile (current directory).") 72 cli.o(longOpt:'output', args:1, argName: "output", "Output file, - prints to stdout (default: -)") 73 cli.e(longOpt:'eii_input', args:1, argName:"eii_input", "Input file for the editor imagery index (json). Default is $eiiInputFile (current directory).") 74 cli.j(longOpt:'josm_input', args:1, argName:"josm_input", "Input file for the JOSM imagery list (xml). Default is $josmInputFile (current directory).") 68 75 cli.s(longOpt:'shorten', "shorten the output, so it is easier to read in a console window") 76 cli.n(longOpt:'noskip', argName:"noskip", "don't skip known entries") 77 cli.m(longOpt:'nomissingeii', argName:"nomissingeii", "don't show missing editor imagery index entries") 69 78 cli.h(longOpt:'help', "show this help") 70 79 options = cli.parse(args) … … 80 89 josmInputFile = options.josm_input 81 90 } 82 } 83 91 if (options.output && options.output != "-") { 92 outputFile = new FileWriter(options.output) 93 outputStream = new BufferedWriter(outputFile) 94 } 95 } 96 97 void loadSkip() { 98 if (options.noskip) 99 return; 100 skipEntries["+++ EII-URL is not unique: http://geolittoral.application.equipement.gouv.fr/wms/metropole?FORMAT=image/jpeg&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetMap&Layers=ortholittorale&SRS={proj}&WIDTH={width}&HEIGHT={height}&BBOX={bbox}"] = 1 101 skipEntries[" name differs: http://wms.openstreetmap.fr/tms/1.0.0/tours_2013/{zoom}/{x}/{y}"] = 3 102 skipEntries[" name differs: http://wms.openstreetmap.fr/tms/1.0.0/tours/{zoom}/{x}/{y}"] = 3 103 skipEntries[" name differs: https://secure.erlangen.de/arcgiser/services/Luftbilder2011/MapServer/WmsServer?FORMAT=image/bmp&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetMap&LAYERS=Erlangen_ratio10_5cm_gk4.jp2&STYLES=&SRS={proj}&WIDTH={width}&HEIGHT={height}&BBOX={bbox}"] = 3 104 skipEntries[" name differs: http://wms.openstreetmap.fr/tms/1.0.0/iomhaiti/{zoom}/{x}/{y}"] = 3 105 skipEntries[" name differs: http://{switch:a,b,c}.layers.openstreetmap.fr/bano/{zoom}/{x}/{y}.png"] = 3 106 skipEntries[" name differs: http://ooc.openstreetmap.org/os1/{zoom}/{x}/{y}.jpg"] = 3 107 skipEntries[" name differs: http://www.gisnet.lv/cgi-bin/osm_latvia?FORMAT=image/jpeg&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetMap&Layers=piekraste&SRS={proj}&WIDTH={width}&height={height}&BBOX={bbox}"] = 3 108 skipEntries[" name differs: http://tms.cadastre.openstreetmap.fr/*/tout/{z}/{x}/{y}.png"] = 3 109 skipEntries[" name differs: http://{switch:a,b,c}.tiles.mapbox.com/v4/enf.e0b8291e/{zoom}/{x}/{y}.png?access_token=pk.eyJ1Ijoib3BlbnN0cmVldG1hcCIsImEiOiJhNVlHd29ZIn0.ti6wATGDWOmCnCYen-Ip7Q"] = 3 110 skipEntries[" name differs: http://geo.nls.uk/mapdata2/os/25_inch/scotland_1/{zoom}/{x}/{y}.png"] = 3 111 skipEntries[" name differs: http://geo.nls.uk/mapdata3/os/6_inch_gb_1900/{zoom}/{x}/{y}.png"] = 3 112 skipEntries[" maxzoom differs: [DE] Bavaria (2 m) - http://geodaten.bayern.de/ogc/ogc_dop200_oa.cgi?FORMAT=image/jpeg&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetMap&Layers=adv_dop200c&SRS={proj}&WIDTH={width}&HEIGHT={height}&BBOX={bbox}"] = 3 113 skipEntries[" minzoom differs: [AU] LPI NSW Administrative Boundaries County - http://maps.six.nsw.gov.au/arcgis/services/public/NSW_Administrative_Boundaries/MapServer/WMSServer?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&CRS={proj}&BBOX={bbox}&WIDTH={width}&HEIGHT={height}&LAYERS=County&STYLES=&FORMAT=image/png32&DPI=96&MAP_RESOLUTION=96&FORMAT_OPTIONS=dpi:96&TRANSPARENT=TRUE"] = 3 114 skipEntries[" minzoom differs: [AU] LPI NSW Administrative Boundaries NPWS Reserve - http://maps.six.nsw.gov.au/arcgis/services/public/NSW_Administrative_Boundaries/MapServer/WMSServer?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&CRS={proj}&BBOX={bbox}&WIDTH={width}&HEIGHT={height}&LAYERS=NPWSReserve&STYLES=&FORMAT=image/png32&DPI=96&MAP_RESOLUTION=96&FORMAT_OPTIONS=dpi:96&TRANSPARENT=TRUE"] = 3 115 skipEntries[" minzoom differs: [AU] LPI NSW Administrative Boundaries Parish - http://maps.six.nsw.gov.au/arcgis/services/public/NSW_Administrative_Boundaries/MapServer/WMSServer?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&CRS={proj}&BBOX={bbox}&WIDTH={width}&HEIGHT={height}&LAYERS=Parish&STYLES=&FORMAT=image/png32&DPI=96&MAP_RESOLUTION=96&FORMAT_OPTIONS=dpi:96&TRANSPARENT=TRUE"] = 3 116 skipEntries[" minzoom differs: [AU] LPI NSW Administrative Boundaries Suburb - http://maps.six.nsw.gov.au/arcgis/services/public/NSW_Administrative_Boundaries/MapServer/WMSServer?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&CRS={proj}&BBOX={bbox}&WIDTH={width}&HEIGHT={height}&LAYERS=Suburb&STYLES=&FORMAT=image/png32&DPI=96&MAP_RESOLUTION=96&FORMAT_OPTIONS=dpi:96&TRANSPARENT=TRUE"] = 3 117 skipEntries[" minzoom differs: [AU] LPI NSW Imagery - http://maps.six.nsw.gov.au/arcgis/rest/services/public/NSW_Imagery/MapServer/tile/{zoom}/{y}/{x}"] = 3 118 skipEntries[" minzoom differs: [AU] LPI NSW Topographic Map - http://maps.six.nsw.gov.au/arcgis/rest/services/public/NSW_Topo_Map/MapServer/tile/{zoom}/{y}/{x}"] = 3 119 skipEntries[" minzoom differs: [AU] LPI NSW Administrative Boundaries State Forest - http://maps.six.nsw.gov.au/arcgis/services/public/NSW_Administrative_Boundaries/MapServer/WMSServer?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&CRS={proj}&BBOX={bbox}&WIDTH={width}&HEIGHT={height}&LAYERS=StateForest&STYLES=&FORMAT=image/png32&DPI=96&MAP_RESOLUTION=96&FORMAT_OPTIONS=dpi:96&TRANSPARENT=TRUE"] = 3 120 skipEntries[" minzoom differs: [AU] LPI NSW Administrative Boundaries LGA - http://maps.six.nsw.gov.au/arcgis/services/public/NSW_Administrative_Boundaries/MapServer/WMSServer?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&CRS={proj}&BBOX={bbox}&WIDTH={width}&HEIGHT={height}&LAYERS=LocalGovernmentArea&STYLES=&FORMAT=image/png32&DPI=96&MAP_RESOLUTION=96&FORMAT_OPTIONS=dpi:96&TRANSPARENT=TRUE"] = 3 121 skipEntries[" minzoom differs: [AU] LPI NSW Base Map - http://maps.six.nsw.gov.au/arcgis/rest/services/public/NSW_Base_Map/MapServer/tile/{zoom}/{y}/{x}"] = 3 122 } 123 124 void myprintln(String s) { 125 if(skipEntries.containsKey(s)) { 126 skipCount = skipEntries.get(s) 127 } 128 if(skipCount) { 129 skipCount -= 1; 130 return 131 } 132 if(outputStream != null) { 133 outputStream.write(s); 134 outputStream.newLine(); 135 } else { 136 println s; 137 } 138 } 139 84 140 void loadEIIEntries() { 85 141 FileReader fr = new FileReader(eiiInputFile) … … 90 146 for (def e : eiiEntries) { 91 147 def url = getUrl(e) 92 if (eiiUrls.containsKey(url) && !EII_KNOWN_DUPLICATES.contains(url)) 93 throw new Exception("URL is not unique: "+url) 94 eiiUrls.put(url, e) 95 } 148 if (eiiUrls.containsKey(url)) { 149 myprintln "+++ EII-URL is not unique: "+url 150 } else { 151 eiiUrls.put(url, e) 152 } 153 } 154 myprintln "*** Loaded ${eiiEntries.size()} entries (EII). ***" 96 155 } 97 156 … … 102 161 for (def e : josmEntries) { 103 162 def url = getUrl(e) 104 if (josmUrls.containsKey(url) && !JOSM_KNOWN_DUPLICATES.contains(url)) { 105 throw new Exception("URL is not unique: "+url) 106 } 107 josmUrls.put(url, e) 108 } 163 if (josmUrls.containsKey(url)) { 164 myprintln "+++ JOSM-URL is not unique: "+url 165 } else { 166 josmUrls.put(url, e) 167 } 168 } 169 myprintln "*** Loaded ${josmEntries.size()} entries (JOSM). ***" 109 170 } 110 171 … … 122 183 void checkInOneButNotTheOther() { 123 184 def l1 = inOneButNotTheOther(eiiUrls, josmUrls) 124 println "*** URLs found in EII but not in JOSM (${l1.size()}): ***"185 myprintln "*** URLs found in EII but not in JOSM (${l1.size()}): ***" 125 186 if (l1.isEmpty()) { 126 println " -" 127 } else { 128 println Utils.join("\n", l1) 129 } 130 187 myprintln " -" 188 } else { 189 myprintln Utils.join("\n", l1) 190 } 191 192 if (options.nomissingeii) 193 return 131 194 def l2 = inOneButNotTheOther(josmUrls, eiiUrls) 132 println "*** URLs found in JOSM but not in EII (${l2.size()}): ***"195 myprintln "*** URLs found in JOSM but not in EII (${l2.size()}): ***" 133 196 if (l2.isEmpty()) { 134 println " -"135 } else { 136 println Utils.join("\n", l2)197 myprintln " -" 198 } else { 199 myprintln Utils.join("\n", l2) 137 200 } 138 201 } 139 202 140 203 void checkCommonEntries() { 141 println "*** Same URL, but different name: ***"204 myprintln "*** Same URL, but different name: ***" 142 205 for (def url : eiiUrls.keySet()) { 143 206 def e = eiiUrls.get(url) … … 145 208 def j = josmUrls.get(url) 146 209 if (!getName(e).equals(getName(j))) { 147 println " name differs: $url"148 println " (IEE): ${getName(e)}"149 println " (JOSM): ${getName(j)}"150 } 151 } 152 153 println "*** Same URL, but different type: ***"210 myprintln " name differs: $url" 211 myprintln " (IEE): ${getName(e)}" 212 myprintln " (JOSM): ${getName(j)}" 213 } 214 } 215 216 myprintln "*** Same URL, but different type: ***" 154 217 for (def url : eiiUrls.keySet()) { 155 218 def e = eiiUrls.get(url) … … 157 220 def j = josmUrls.get(url) 158 221 if (!getType(e).equals(getType(j))) { 159 println " type differs: ${getName(j)} - $url"160 println " (IEE): ${getType(e)}"161 println " (JOSM): ${getType(j)}"162 } 163 } 164 165 println "*** Same URL, but different zoom bounds: ***"222 myprintln " type differs: ${getName(j)} - $url" 223 myprintln " (IEE): ${getType(e)}" 224 myprintln " (JOSM): ${getType(j)}" 225 } 226 } 227 228 myprintln "*** Same URL, but different zoom bounds: ***" 166 229 for (def url : eiiUrls.keySet()) { 167 230 def e = eiiUrls.get(url) … … 172 235 Integer jMinZoom = getMinZoom(j) 173 236 if (eMinZoom != jMinZoom) { 174 println " minzoom differs: ${getDescription(j)}"175 println " (IEE): ${eMinZoom}"176 println " (JOSM): ${jMinZoom}"237 myprintln " minzoom differs: ${getDescription(j)}" 238 myprintln " (IEE): ${eMinZoom}" 239 myprintln " (JOSM): ${jMinZoom}" 177 240 } 178 241 Integer eMaxZoom = getMaxZoom(e) 179 242 Integer jMaxZoom = getMaxZoom(j) 180 243 if (eMaxZoom != jMaxZoom) { 181 println " maxzoom differs: ${getDescription(j)}"182 println " (IEE): ${eMaxZoom}"183 println " (JOSM): ${jMaxZoom}"184 } 185 } 186 187 println "*** Same URL, but different country code: ***"244 myprintln " maxzoom differs: ${getDescription(j)}" 245 myprintln " (IEE): ${eMaxZoom}" 246 myprintln " (JOSM): ${jMaxZoom}" 247 } 248 } 249 250 myprintln "*** Same URL, but different country code: ***" 188 251 for (def url : eiiUrls.keySet()) { 189 252 def e = eiiUrls.get(url) … … 191 254 def j = josmUrls.get(url) 192 255 if (!getCountryCode(e).equals(getCountryCode(j))) { 193 println " country code differs: ${getDescription(j)}" 194 println " (IEE): ${getCountryCode(e)}" 195 println " (JOSM): ${getCountryCode(j)}" 256 myprintln " country code differs: ${getDescription(j)}" 257 myprintln " (IEE): ${getCountryCode(e)}" 258 myprintln " (JOSM): ${getCountryCode(j)}" 259 } 260 } 261 myprintln "*** Same URL, but different quality: ***" 262 for (def url : eiiUrls.keySet()) { 263 def e = eiiUrls.get(url) 264 if (!josmUrls.containsKey(url)) continue 265 def j = josmUrls.get(url) 266 if (!getQuality(e).equals(getQuality(j))) { 267 myprintln " quality differs: ${getDescription(j)}" 268 myprintln " (IEE): ${getQuality(e)}" 269 myprintln " (JOSM): ${getQuality(j)}" 196 270 } 197 271 } … … 241 315 return e.getString("country_code", null) 242 316 } 317 static String getQuality(Object e) { 318 //if (e instanceof ImageryInfo) return "".equals(e.getQuality()) ? null : e.getQuality() 319 if (e instanceof ImageryInfo) return null 320 return e.get("best") ? "best" : null 321 } 243 322 String getDescription(Object o) { 244 323 def url = getUrl(o)
Note:
See TracChangeset
for help on using the changeset viewer.