Changeset 9658 in josm for trunk/src/org/openstreetmap/josm/io
- Timestamp:
- 2016-01-27T22:27:54+01:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/imagery/ImageryReader.java
r9619 r9658 40 40 ENTRY, // inside an entry 41 41 ENTRY_ATTRIBUTE, // note we are inside an entry attribute to collect the character data 42 PROJECTIONS, 42 PROJECTIONS, // inside projections block of an entry 43 MIRROR, // inside an mirror entry 44 MIRROR_ATTRIBUTE, // note we are inside an mirror attribute to collect the character data 45 MIRROR_PROJECTIONS, // inside projections block of an mirror entry 43 46 CODE, 44 47 BOUNDS, … … 89 92 90 93 private ImageryInfo entry; 94 /** In case of mirror parsing this contains the mirror entry */ 95 private ImageryInfo mirrorEntry; 91 96 private ImageryBounds bounds; 92 97 private Shape shape; … … 130 135 noTileChecksums = new HashMap<>(); 131 136 metadataHeaders = new HashMap<>(); 137 } 138 break; 139 case MIRROR: 140 if (Arrays.asList(new String[] { 141 "type", 142 "url", 143 "min-zoom", 144 "max-zoom", 145 "tile-size", 146 }).contains(qName)) { 147 newState = State.MIRROR_ATTRIBUTE; 148 lang = atts.getValue("lang"); 149 } else if ("projections".equals(qName)) { 150 projections = new ArrayList<>(); 151 newState = State.MIRROR_PROJECTIONS; 132 152 } 133 153 break; … … 171 191 projections = new ArrayList<>(); 172 192 newState = State.PROJECTIONS; 193 } else if ("mirror".equals(qName)) { 194 projections = new ArrayList<>(); 195 newState = State.MIRROR; 196 mirrorEntry = new ImageryInfo(); 173 197 } else if ("no-tile-header".equals(qName)) { 174 198 String name = atts.getValue("name"); … … 214 238 break; 215 239 case PROJECTIONS: 240 case MIRROR_PROJECTIONS: 216 241 if ("code".equals(qName)) { 217 242 newState = State.CODE; … … 259 284 } 260 285 break; 286 case MIRROR: 287 if ("mirror".equals(qName)) { 288 if (mirrorEntry != null) { 289 entry.addMirror(mirrorEntry); 290 mirrorEntry = null; 291 } 292 } 293 break; 294 case MIRROR_ATTRIBUTE: 295 if (mirrorEntry != null) { 296 switch(qName) { 297 case "type": 298 boolean found = false; 299 for (ImageryType type : ImageryType.values()) { 300 if (Objects.equals(accumulator.toString(), type.getTypeString())) { 301 mirrorEntry.setImageryType(type); 302 found = true; 303 break; 304 } 305 } 306 if (!found) { 307 mirrorEntry = null; 308 } 309 break; 310 case "url": 311 mirrorEntry.setUrl(accumulator.toString()); 312 break; 313 case "min-zoom": 314 case "max-zoom": 315 Integer val = null; 316 try { 317 val = Integer.valueOf(accumulator.toString()); 318 } catch (NumberFormatException e) { 319 val = null; 320 } 321 if (val == null) { 322 mirrorEntry = null; 323 } else { 324 if ("min-zoom".equals(qName)) { 325 mirrorEntry.setDefaultMinZoom(val); 326 } else { 327 mirrorEntry.setDefaultMaxZoom(val); 328 } 329 } 330 break; 331 case "tile-size": 332 Integer tileSize = null; 333 try { 334 tileSize = Integer.valueOf(accumulator.toString()); 335 } catch (NumberFormatException e) { 336 tileSize = null; 337 } 338 if (tileSize == null) { 339 mirrorEntry = null; 340 } else { 341 entry.setTileSize(tileSize.intValue()); 342 } 343 break; 344 } 345 } 346 break; 261 347 case ENTRY_ATTRIBUTE: 262 348 switch(qName) { … … 379 465 projections = null; 380 466 break; 467 case MIRROR_PROJECTIONS: 468 mirrorEntry.setServerProjections(projections); 469 projections = null; 470 break; 471 /* nothing to do for these or the unknown type: 381 472 case NO_TILE: 382 break; 383 473 case NO_TILESUM: 474 case METADATA: 475 case UNKNOWN: 476 break; 477 */ 384 478 } 385 479 }
Note:
See TracChangeset
for help on using the changeset viewer.
