- Timestamp:
- 2016-02-09T16:14:28+01:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java
r9664 r9768 13 13 import java.util.ArrayList; 14 14 import java.util.Collection; 15 import java.util.Collections; 15 16 import java.util.Comparator; 16 17 import java.util.HashSet; 18 import java.util.List; 17 19 import java.util.Map; 18 20 import java.util.Set; … … 80 82 } 81 83 82 private static class TileMatrixSet {84 private static class TileMatrixSetBuilder { 83 85 SortedSet<TileMatrix> tileMatrix = new TreeSet<>(new Comparator<TileMatrix>() { 84 86 @Override … … 91 93 private String identifier; 92 94 95 TileMatrixSet build() { 96 return new TileMatrixSet(this); 97 } 98 } 99 100 private static class TileMatrixSet { 101 102 private final List<TileMatrix> tileMatrix; 103 private final String crs; 104 private final String identifier; 105 93 106 TileMatrixSet(TileMatrixSet tileMatrixSet) { 94 107 if (tileMatrixSet != null) { 95 tileMatrix = new TreeSet<>(tileMatrixSet.tileMatrix);108 tileMatrix = new ArrayList<>(tileMatrixSet.tileMatrix); 96 109 crs = tileMatrixSet.crs; 97 110 identifier = tileMatrixSet.identifier; 98 } 99 } 100 101 TileMatrixSet() { 111 } else { 112 tileMatrix = Collections.emptyList(); 113 crs = null; 114 identifier = null; 115 } 116 } 117 118 TileMatrixSet(TileMatrixSetBuilder builder) { 119 tileMatrix = new ArrayList<>(builder.tileMatrix); 120 crs = builder.crs; 121 identifier = builder.identifier; 102 122 } 103 123 … … 405 425 */ 406 426 private static TileMatrixSet parseTileMatrixSet(XMLStreamReader reader) throws XMLStreamException { 407 TileMatrixSet matrixSet = new TileMatrixSet();427 TileMatrixSetBuilder matrixSet = new TileMatrixSetBuilder(); 408 428 for (int event = reader.getEventType(); 409 429 reader.hasNext() && !(event == XMLStreamReader.END_ELEMENT && new QName(WMTS_NS_URL, "TileMatrixSet").equals(reader.getName())); … … 421 441 } 422 442 } 423 return matrixSet ;443 return matrixSet.build(); 424 444 } 425 445 … … 637 657 Collection<Layer> layers = getLayers(null, Main.getProjection().toCode()); 638 658 if (!layers.isEmpty()) { 639 return layers.iterator().next().tileMatrixSet.tileMatrix. first().tileHeight;659 return layers.iterator().next().tileMatrixSet.tileMatrix.get(0).tileHeight; 640 660 } 641 661 // if no layers is found, fallback to default mercator tile size. Maybe it will work … … 694 714 return null; 695 715 } 696 return this.currentTileMatrixSet.tileMatrix. toArray(new TileMatrix[]{})[zoom - 1];716 return this.currentTileMatrixSet.tileMatrix.get(zoom - 1); 697 717 } 698 718
Note:
See TracChangeset
for help on using the changeset viewer.