- Timestamp:
- 2015-07-08T23:06:52+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java
r8585 r8586 80 80 int tileWidth; 81 81 int tileHeight; 82 public int matrixWidth = -1; 83 public int matrixHeight = -1; 82 84 } 83 85 … … 99 101 Map<String, TileMatrixSet> tileMatrixSetByCRS = new ConcurrentHashMap<>(); 100 102 public String baseUrl; 103 public String style; 101 104 } 102 105 … … 163 166 private double crsScale; 164 167 private TransferMode transferMode; 165 private String style = "";166 168 167 169 /** … … 248 250 layer.name = getStringByXpath(layerNode, "Identifier"); 249 251 layer.baseUrl = getStringByXpath(layerNode, "ResourceURL[@resourceType='tile']/@template"); 252 layer.style = getStringByXpath(layerNode, "Style[@isDefault='true']/Identifier"); 253 if (layer.style == null) { 254 layer.style = ""; 255 } 250 256 NodeList tileMatrixSetLinks = getByXpath(layerNode, "TileMatrixSetLink"); 251 257 for (int tileMatrixId = 0; tileMatrixId < tileMatrixSetLinks.getLength(); tileMatrixId++) { … … 287 293 tileMatrix.tileHeight = Integer.parseInt(getStringByXpath(tileMatrixNode, "TileHeight")); 288 294 tileMatrix.tileWidth = Integer.parseInt(getStringByXpath(tileMatrixNode, "TileHeight")); 295 tileMatrix.matrixWidth = getOptionalIntegerByXpath(tileMatrixNode, "MatrixWidth"); 296 tileMatrix.matrixHeight = getOptionalIntegerByXpath(tileMatrixNode, "MatrixHeight"); 289 297 if (tileMatrix.tileHeight != tileMatrix.tileWidth) { 290 298 throw new AssertionError(tr("Only square tiles are supported. {0}x{1} returned by server for TileMatrix identifier {2}", … … 304 312 } 305 313 return crsIdentifier; 314 } 315 316 private int getOptionalIntegerByXpath(Node document, String xpathQuery) throws XPathExpressionException { 317 String ret = getStringByXpath(document, xpathQuery); 318 if (ret == null || "".equals(ret)) { 319 return -1; 320 } 321 return Integer.parseInt(ret); 306 322 } 307 323 … … 384 400 .replaceAll("\\{TileRow\\}", Integer.toString(tiley)) 385 401 .replaceAll("\\{TileCol\\}", Integer.toString(tilex)) 386 .replaceAll("\\{Style\\}", this. style);402 .replaceAll("\\{Style\\}", this.currentLayer.style); 387 403 } 388 404 … … 595 611 return 0; 596 612 } 613 614 if (matrix.matrixHeight != -1) { 615 return matrix.matrixHeight; 616 } 617 597 618 double scale = matrix.scaleDenominator * this.crsScale; 598 Bounds bounds = Main.getProjection().getWorldBoundsLatLon();619 Bounds bounds = proj.getWorldBoundsLatLon(); 599 620 EastNorth min = proj.latlon2eastNorth(bounds.getMin()); 600 621 EastNorth max = proj.latlon2eastNorth(bounds.getMax()); … … 607 628 return 0; 608 629 } 630 if (matrix.matrixWidth != -1) { 631 return matrix.matrixWidth; 632 } 633 609 634 double scale = matrix.scaleDenominator * this.crsScale; 610 Bounds bounds = Main.getProjection().getWorldBoundsLatLon();635 Bounds bounds = proj.getWorldBoundsLatLon(); 611 636 EastNorth min = proj.latlon2eastNorth(bounds.getMin()); 612 637 EastNorth max = proj.latlon2eastNorth(bounds.getMax()); -
trunk/src/org/openstreetmap/josm/gui/layer/WMTSLayer.java
r8584 r8586 5 5 import java.util.Map; 6 6 7 import org.openstreetmap.gui.jmapviewer.TileXY; 7 8 import org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate; 8 9 import org.openstreetmap.gui.jmapviewer.interfaces.TileLoader; … … 81 82 */ 82 83 private double getTileToScreenRatio(int zoom) { 83 ICoordinate north = tileSource.tileXYToLatLon(0, 0, zoom);84 ICoordinate south = tileSource.tileXYToLatLon(0, 1, zoom);85 86 84 MapView mv = Main.map.mapView; 87 85 LatLon topLeft = mv.getLatLon(0, 0); 88 86 LatLon botLeft = mv.getLatLon(0, tileSource.getTileSize()); 87 88 TileXY topLeftTile = tileSource.latLonToTileXY(topLeft.toCoordinate(), zoom); 89 90 ICoordinate north = tileSource.tileXYToLatLon(topLeftTile.getXIndex(), topLeftTile.getYIndex(), zoom); 91 ICoordinate south = tileSource.tileXYToLatLon(topLeftTile.getXIndex(), topLeftTile.getYIndex() + 1, zoom); 89 92 90 93 return Math.abs((north.getLat() - south.getLat()) / (topLeft.lat() - botLeft.lat())); … … 95 98 if (!Main.isDisplayingMapView()) return 1; 96 99 97 for (int i = getMinZoomLvl() ; i <= getMaxZoomLvl(); i++) {100 for (int i = getMinZoomLvl() + 1; i <= getMaxZoomLvl(); i++) { 98 101 double ret = getTileToScreenRatio(i); 99 102 if (ret < 1) { 100 return i ;103 return i - 1; 101 104 } 102 105 }
Note:
See TracChangeset
for help on using the changeset viewer.