Changeset 8586 in josm
- Timestamp:
- 2015-07-08T23:06:52+02:00 (9 years ago)
- Location:
- trunk
- Files:
-
- 4 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 } -
trunk/test/data/wmts/WMTSCapabilities-Wallonie.xml
r8569 r8586 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <Capabilities xmlns="http://www.opengis.net/wmts/1.0" 3 xmlns:ows="http://www.opengis.net/ows/1.1" 4 xmlns:xlink="http://www.w3.org/1999/xlink" 5 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 6 xmlns:gml="http://www.opengis.net/gml" 7 xsi:schemaLocation="http://www.opengis.net/wmts/1.0 http://schemas.opengis.net/wmts/1.0/wmtsGetCapabilities_response.xsd" 8 version="1.0.0"> 9 <!-- Service Identification --> <ows:ServiceIdentification> 10 <ows:Title>DONNEES_BASE_FOND_PLAN_ANNOTATIONS_2012_RW_NB</ows:Title> 11 <ows:ServiceType>OGC WMTS</ows:ServiceType> 12 <ows:ServiceTypeVersion>1.0.0</ows:ServiceTypeVersion> 13 </ows:ServiceIdentification> <!-- Operations Metadata --> <ows:OperationsMetadata> 14 <ows:Operation name="GetCapabilities"> 15 <ows:DCP> 16 <ows:HTTP> 17 <ows:Get xlink:href="http://geoservices.wallonie.be/arcgis/rest/services/DONNEES_BASE/FOND_PLAN_ANNOTATIONS_2012_RW_NB/MapServer/WMTS/1.0.0/WMTSCapabilities.xml"> 18 <ows:Constraint name="GetEncoding"> 19 <ows:AllowedValues> 20 <ows:Value>RESTful</ows:Value> 21 </ows:AllowedValues> 22 </ows:Constraint> 23 </ows:Get> 24 <!-- add KVP binding in 10.1 --> 25 <ows:Get xlink:href="http://geoservices.wallonie.be/arcgis/rest/services/DONNEES_BASE/FOND_PLAN_ANNOTATIONS_2012_RW_NB/MapServer/WMTS?"> 26 <ows:Constraint name="GetEncoding"> 27 <ows:AllowedValues> 28 <ows:Value>KVP</ows:Value> 29 </ows:AllowedValues> 30 </ows:Constraint> 31 </ows:Get> 32 </ows:HTTP> 33 </ows:DCP> 34 </ows:Operation> 35 <ows:Operation name="GetTile"> 36 <ows:DCP> 37 <ows:HTTP> 38 <ows:Get xlink:href="http://geoservices.wallonie.be/arcgis/rest/services/DONNEES_BASE/FOND_PLAN_ANNOTATIONS_2012_RW_NB/MapServer/WMTS/tile/1.0.0/"> 39 <ows:Constraint name="GetEncoding"> 40 <ows:AllowedValues> 41 <ows:Value>RESTful</ows:Value> 42 </ows:AllowedValues> 43 </ows:Constraint> 44 </ows:Get> 45 <ows:Get xlink:href="http://geoservices.wallonie.be/arcgis/rest/services/DONNEES_BASE/FOND_PLAN_ANNOTATIONS_2012_RW_NB/MapServer/WMTS?"> 46 <ows:Constraint name="GetEncoding"> 47 <ows:AllowedValues> 48 <ows:Value>KVP</ows:Value> 49 </ows:AllowedValues> 50 </ows:Constraint> 51 </ows:Get> 52 </ows:HTTP> 53 </ows:DCP> 54 </ows:Operation> 55 </ows:OperationsMetadata> <Contents> 56 <!--Layer--> <Layer> 57 <ows:Title>DONNEES_BASE_FOND_PLAN_ANNOTATIONS_2012_RW_NB</ows:Title> <ows:Identifier>DONNEES_BASE_FOND_PLAN_ANNOTATIONS_2012_RW_NB</ows:Identifier> 58 <ows:BoundingBox crs="urn:ogc:def:crs:EPSG::31370"> 59 <ows:LowerCorner>42300.92807390103 21237.786800000817</ows:LowerCorner> 60 <ows:UpperCorner>295130.32186220103 167836.14678540602</ows:UpperCorner> 61 </ows:BoundingBox> <ows:WGS84BoundingBox crs="urn:ogc:def:crs:OGC:2:84"> 62 <ows:LowerCorner>2.840548314430268 49.485372459967245</ows:LowerCorner> 63 <ows:UpperCorner>6.427849693016202 50.820959517561256</ows:UpperCorner> 64 </ows:WGS84BoundingBox> 65 <Style isDefault="true"> 66 <ows:Title>Default Style</ows:Title> 67 <ows:Identifier>default</ows:Identifier> 68 </Style> 69 <Format>image/png</Format> 70 <TileMatrixSetLink> 71 <TileMatrixSet>default028mm</TileMatrixSet> 72 </TileMatrixSetLink> 73 <ResourceURL format="image/png" resourceType="tile" template="http://geoservices.wallonie.be/arcgis/rest/services/DONNEES_BASE/FOND_PLAN_ANNOTATIONS_2012_RW_NB/MapServer/WMTS/tile/1.0.0/DONNEES_BASE_FOND_PLAN_ANNOTATIONS_2012_RW_NB/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png" /> 74 </Layer> <!--TileMatrixSet--> 75 <TileMatrixSet> 76 <ows:Title>TileMatrix using 0.28mm</ows:Title> 77 <ows:Abstract>The tile matrix set that has scale values calculated based on the dpi defined by OGC specification (dpi assumes 0.28mm as the physical distance of a pixel).</ows:Abstract> <ows:Identifier>default028mm</ows:Identifier> 78 <ows:SupportedCRS>urn:ogc:def:crs:EPSG::31370</ows:SupportedCRS> 79 <TileMatrix> 80 <ows:Identifier>0</ows:Identifier> 81 <ScaleDenominator>1417413.5491126343</ScaleDenominator> 82 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> <TileWidth>512</TileWidth> <TileHeight>512</TileHeight> 83 <MatrixWidth>178</MatrixWidth> <MatrixHeight>204</MatrixHeight> 84 </TileMatrix> 85 <TileMatrix> 86 <ows:Identifier>1</ows:Identifier> 87 <ScaleDenominator>1181177.957593862</ScaleDenominator> 88 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> <TileWidth>512</TileWidth> <TileHeight>512</TileHeight> 89 <MatrixWidth>214</MatrixWidth> <MatrixHeight>245</MatrixHeight> 90 </TileMatrix> 91 <TileMatrix> 92 <ows:Identifier>2</ows:Identifier> 93 <ScaleDenominator>944942.3660750897</ScaleDenominator> 94 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> <TileWidth>512</TileWidth> <TileHeight>512</TileHeight> 95 <MatrixWidth>267</MatrixWidth> <MatrixHeight>306</MatrixHeight> 96 </TileMatrix> 97 <TileMatrix> 98 <ows:Identifier>3</ows:Identifier> 99 <ScaleDenominator>708706.7745563171</ScaleDenominator> 100 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> <TileWidth>512</TileWidth> <TileHeight>512</TileHeight> 101 <MatrixWidth>356</MatrixWidth> <MatrixHeight>408</MatrixHeight> 102 </TileMatrix> 103 <TileMatrix> 104 <ows:Identifier>4</ows:Identifier> 105 <ScaleDenominator>472471.18303754483</ScaleDenominator> 106 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> <TileWidth>512</TileWidth> <TileHeight>512</TileHeight> 107 <MatrixWidth>534</MatrixWidth> <MatrixHeight>612</MatrixHeight> 108 </TileMatrix> 109 <TileMatrix> 110 <ows:Identifier>5</ows:Identifier> 111 <ScaleDenominator>236235.59151877242</ScaleDenominator> 112 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> <TileWidth>512</TileWidth> <TileHeight>512</TileHeight> 113 <MatrixWidth>1068</MatrixWidth> <MatrixHeight>1223</MatrixHeight> 114 </TileMatrix> 115 <TileMatrix> 116 <ows:Identifier>6</ows:Identifier> 117 <ScaleDenominator>94494.23660750895</ScaleDenominator> 118 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> <TileWidth>512</TileWidth> <TileHeight>512</TileHeight> 119 <MatrixWidth>2670</MatrixWidth> <MatrixHeight>3057</MatrixHeight> 120 </TileMatrix> 121 <TileMatrix> 122 <ows:Identifier>7</ows:Identifier> 123 <ScaleDenominator>70870.67745563173</ScaleDenominator> 124 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> <TileWidth>512</TileWidth> <TileHeight>512</TileHeight> 125 <MatrixWidth>3560</MatrixWidth> <MatrixHeight>4075</MatrixHeight> 126 </TileMatrix> 127 <TileMatrix> 128 <ows:Identifier>8</ows:Identifier> 129 <ScaleDenominator>47247.118303754476</ScaleDenominator> 130 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> <TileWidth>512</TileWidth> <TileHeight>512</TileHeight> 131 <MatrixWidth>5340</MatrixWidth> <MatrixHeight>6113</MatrixHeight> 132 </TileMatrix> 133 <TileMatrix> 134 <ows:Identifier>9</ows:Identifier> 135 <ScaleDenominator>23623.559151877238</ScaleDenominator> 136 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> <TileWidth>512</TileWidth> <TileHeight>512</TileHeight> 137 <MatrixWidth>10680</MatrixWidth> <MatrixHeight>12225</MatrixHeight> 138 </TileMatrix> 139 <TileMatrix> 140 <ows:Identifier>10</ows:Identifier> 141 <ScaleDenominator>14174.135491126344</ScaleDenominator> 142 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> <TileWidth>512</TileWidth> <TileHeight>512</TileHeight> 143 <MatrixWidth>17800</MatrixWidth> <MatrixHeight>20375</MatrixHeight> 144 </TileMatrix> 145 <TileMatrix> 146 <ows:Identifier>11</ows:Identifier> 147 <ScaleDenominator>9449.423660750896</ScaleDenominator> 148 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> <TileWidth>512</TileWidth> <TileHeight>512</TileHeight> 149 <MatrixWidth>26699</MatrixWidth> <MatrixHeight>30563</MatrixHeight> 150 </TileMatrix> 151 <TileMatrix> 152 <ows:Identifier>12</ows:Identifier> 153 <ScaleDenominator>4724.711830375448</ScaleDenominator> 154 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> <TileWidth>512</TileWidth> <TileHeight>512</TileHeight> 155 <MatrixWidth>53398</MatrixWidth> <MatrixHeight>61125</MatrixHeight> 156 </TileMatrix> 157 <TileMatrix> 158 <ows:Identifier>13</ows:Identifier> 159 <ScaleDenominator>2362.355915187724</ScaleDenominator> 160 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> <TileWidth>512</TileWidth> <TileHeight>512</TileHeight> 161 <MatrixWidth>106795</MatrixWidth> <MatrixHeight>122249</MatrixHeight> 162 </TileMatrix> 163 <TileMatrix> 164 <ows:Identifier>14</ows:Identifier> 165 <ScaleDenominator>944.9423660750896</ScaleDenominator> 166 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> <TileWidth>512</TileWidth> <TileHeight>512</TileHeight> 167 <MatrixWidth>266987</MatrixWidth> <MatrixHeight>305621</MatrixHeight> 168 </TileMatrix> 169 <TileMatrix> 170 <ows:Identifier>15</ows:Identifier> 171 <ScaleDenominator>472.4711830375448</ScaleDenominator> 172 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> <TileWidth>512</TileWidth> <TileHeight>512</TileHeight> 173 <MatrixWidth>533973</MatrixWidth> <MatrixHeight>611241</MatrixHeight> 174 </TileMatrix> 175 <TileMatrix> 176 <ows:Identifier>16</ows:Identifier> 177 <ScaleDenominator>236.2355915187724</ScaleDenominator> 178 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> <TileWidth>512</TileWidth> <TileHeight>512</TileHeight> 179 <MatrixWidth>1067946</MatrixWidth> <MatrixHeight>1222482</MatrixHeight> 180 </TileMatrix> 181 </TileMatrixSet> 182 </Contents> 183 <ServiceMetadataURL xlink:href="http://geoservices.wallonie.be/arcgis/rest/services/DONNEES_BASE/FOND_PLAN_ANNOTATIONS_2012_RW_NB/MapServer/WMTS/1.0.0/WMTSCapabilities.xml" /> </Capabilities> 3 xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xlink="http://www.w3.org/1999/xlink" 4 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" 5 xsi:schemaLocation="http://www.opengis.net/wmts/1.0 http://schemas.opengis.net/wmts/1.0/wmtsGetCapabilities_response.xsd" 6 version="1.0.0"> 7 <!-- Service Identification --> 8 <ows:ServiceIdentification> 9 <ows:Title>DONNEES_BASE_FOND_PLAN_ANNOTATIONS_2012_RW_NB</ows:Title> 10 <ows:ServiceType>OGC WMTS</ows:ServiceType> 11 <ows:ServiceTypeVersion>1.0.0</ows:ServiceTypeVersion> 12 </ows:ServiceIdentification> <!-- Operations Metadata --> 13 <ows:OperationsMetadata> 14 <ows:Operation name="GetCapabilities"> 15 <ows:DCP> 16 <ows:HTTP> 17 <ows:Get 18 xlink:href="http://geoservices.wallonie.be/arcgis/rest/services/DONNEES_BASE/FOND_PLAN_ANNOTATIONS_2012_RW_NB/MapServer/WMTS/1.0.0/WMTSCapabilities.xml"> 19 <ows:Constraint name="GetEncoding"> 20 <ows:AllowedValues> 21 <ows:Value>RESTful</ows:Value> 22 </ows:AllowedValues> 23 </ows:Constraint> 24 </ows:Get> 25 <!-- add KVP binding in 10.1 --> 26 <ows:Get 27 xlink:href="http://geoservices.wallonie.be/arcgis/rest/services/DONNEES_BASE/FOND_PLAN_ANNOTATIONS_2012_RW_NB/MapServer/WMTS?"> 28 <ows:Constraint name="GetEncoding"> 29 <ows:AllowedValues> 30 <ows:Value>KVP</ows:Value> 31 </ows:AllowedValues> 32 </ows:Constraint> 33 </ows:Get> 34 </ows:HTTP> 35 </ows:DCP> 36 </ows:Operation> 37 <ows:Operation name="GetTile"> 38 <ows:DCP> 39 <ows:HTTP> 40 <ows:Get 41 xlink:href="http://geoservices.wallonie.be/arcgis/rest/services/DONNEES_BASE/FOND_PLAN_ANNOTATIONS_2012_RW_NB/MapServer/WMTS/tile/1.0.0/"> 42 <ows:Constraint name="GetEncoding"> 43 <ows:AllowedValues> 44 <ows:Value>RESTful</ows:Value> 45 </ows:AllowedValues> 46 </ows:Constraint> 47 </ows:Get> 48 <ows:Get 49 xlink:href="http://geoservices.wallonie.be/arcgis/rest/services/DONNEES_BASE/FOND_PLAN_ANNOTATIONS_2012_RW_NB/MapServer/WMTS?"> 50 <ows:Constraint name="GetEncoding"> 51 <ows:AllowedValues> 52 <ows:Value>KVP</ows:Value> 53 </ows:AllowedValues> 54 </ows:Constraint> 55 </ows:Get> 56 </ows:HTTP> 57 </ows:DCP> 58 </ows:Operation> 59 </ows:OperationsMetadata> 60 <Contents> 61 <!--Layer --> 62 <Layer> 63 <ows:Title>DONNEES_BASE_FOND_PLAN_ANNOTATIONS_2012_RW_NB</ows:Title> 64 <ows:Identifier>DONNEES_BASE_FOND_PLAN_ANNOTATIONS_2012_RW_NB</ows:Identifier> 65 <ows:BoundingBox crs="urn:ogc:def:crs:EPSG::31370"> 66 <ows:LowerCorner>42300.92807390103 21237.786800000817</ows:LowerCorner> 67 <ows:UpperCorner>295130.32186220103 167836.14678540602</ows:UpperCorner> 68 </ows:BoundingBox> 69 <ows:WGS84BoundingBox crs="urn:ogc:def:crs:OGC:2:84"> 70 <ows:LowerCorner>2.840548314430268 49.485372459967245</ows:LowerCorner> 71 <ows:UpperCorner>6.427849693016202 50.820959517561256</ows:UpperCorner> 72 </ows:WGS84BoundingBox> 73 <Style isDefault="true"> 74 <ows:Title>Default Style</ows:Title> 75 <ows:Identifier>default</ows:Identifier> 76 </Style> 77 <Format>image/png</Format> 78 <TileMatrixSetLink> 79 <TileMatrixSet>default028mm</TileMatrixSet> 80 </TileMatrixSetLink> 81 <ResourceURL format="image/png" resourceType="tile" 82 template="http://geoservices.wallonie.be/arcgis/rest/services/DONNEES_BASE/FOND_PLAN_ANNOTATIONS_2012_RW_NB/MapServer/WMTS/tile/1.0.0/DONNEES_BASE_FOND_PLAN_ANNOTATIONS_2012_RW_NB/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png" /> 83 </Layer> <!--TileMatrixSet --> 84 <TileMatrixSet> 85 <ows:Title>TileMatrix using 0.28mm</ows:Title> 86 <ows:Abstract>The tile matrix set that has scale values calculated based on the dpi defined by OGC specification (dpi assumes 0.28mm as the physical distance of a pixel).</ows:Abstract> 87 <ows:Identifier>default028mm</ows:Identifier> 88 <ows:SupportedCRS>urn:ogc:def:crs:EPSG::31370</ows:SupportedCRS> 89 <TileMatrix> 90 <ows:Identifier>0</ows:Identifier> 91 <ScaleDenominator>1417413.5491126343</ScaleDenominator> 92 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> 93 <TileWidth>512</TileWidth> 94 <TileHeight>512</TileHeight> 95 <MatrixWidth>178</MatrixWidth> 96 <MatrixHeight>204</MatrixHeight> 97 </TileMatrix> 98 <TileMatrix> 99 <ows:Identifier>1</ows:Identifier> 100 <ScaleDenominator>1181177.957593862</ScaleDenominator> 101 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> 102 <TileWidth>512</TileWidth> 103 <TileHeight>512</TileHeight> 104 <MatrixWidth>214</MatrixWidth> 105 <MatrixHeight>245</MatrixHeight> 106 </TileMatrix> 107 <TileMatrix> 108 <ows:Identifier>2</ows:Identifier> 109 <ScaleDenominator>944942.3660750897</ScaleDenominator> 110 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> 111 <TileWidth>512</TileWidth> 112 <TileHeight>512</TileHeight> 113 <MatrixWidth>267</MatrixWidth> 114 <MatrixHeight>306</MatrixHeight> 115 </TileMatrix> 116 <TileMatrix> 117 <ows:Identifier>3</ows:Identifier> 118 <ScaleDenominator>708706.7745563171</ScaleDenominator> 119 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> 120 <TileWidth>512</TileWidth> 121 <TileHeight>512</TileHeight> 122 <MatrixWidth>356</MatrixWidth> 123 <MatrixHeight>408</MatrixHeight> 124 </TileMatrix> 125 <TileMatrix> 126 <ows:Identifier>4</ows:Identifier> 127 <ScaleDenominator>472471.18303754483</ScaleDenominator> 128 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> 129 <TileWidth>512</TileWidth> 130 <TileHeight>512</TileHeight> 131 <MatrixWidth>534</MatrixWidth> 132 <MatrixHeight>612</MatrixHeight> 133 </TileMatrix> 134 <TileMatrix> 135 <ows:Identifier>5</ows:Identifier> 136 <ScaleDenominator>236235.59151877242</ScaleDenominator> 137 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> 138 <TileWidth>512</TileWidth> 139 <TileHeight>512</TileHeight> 140 <MatrixWidth>1068</MatrixWidth> 141 <MatrixHeight>1223</MatrixHeight> 142 </TileMatrix> 143 <TileMatrix> 144 <ows:Identifier>6</ows:Identifier> 145 <ScaleDenominator>94494.23660750895</ScaleDenominator> 146 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> 147 <TileWidth>512</TileWidth> 148 <TileHeight>512</TileHeight> 149 <MatrixWidth>2670</MatrixWidth> 150 <MatrixHeight>3057</MatrixHeight> 151 </TileMatrix> 152 <TileMatrix> 153 <ows:Identifier>7</ows:Identifier> 154 <ScaleDenominator>70870.67745563173</ScaleDenominator> 155 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> 156 <TileWidth>512</TileWidth> 157 <TileHeight>512</TileHeight> 158 <MatrixWidth>3560</MatrixWidth> 159 <MatrixHeight>4075</MatrixHeight> 160 </TileMatrix> 161 <TileMatrix> 162 <ows:Identifier>8</ows:Identifier> 163 <ScaleDenominator>47247.118303754476</ScaleDenominator> 164 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> 165 <TileWidth>512</TileWidth> 166 <TileHeight>512</TileHeight> 167 <MatrixWidth>5340</MatrixWidth> 168 <MatrixHeight>6113</MatrixHeight> 169 </TileMatrix> 170 <TileMatrix> 171 <ows:Identifier>9</ows:Identifier> 172 <ScaleDenominator>23623.559151877238</ScaleDenominator> 173 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> 174 <TileWidth>512</TileWidth> 175 <TileHeight>512</TileHeight> 176 <MatrixWidth>10680</MatrixWidth> 177 <MatrixHeight>12225</MatrixHeight> 178 </TileMatrix> 179 <TileMatrix> 180 <ows:Identifier>10</ows:Identifier> 181 <ScaleDenominator>14174.135491126344</ScaleDenominator> 182 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> 183 <TileWidth>512</TileWidth> 184 <TileHeight>512</TileHeight> 185 <MatrixWidth>17800</MatrixWidth> 186 <MatrixHeight>20375</MatrixHeight> 187 </TileMatrix> 188 <TileMatrix> 189 <ows:Identifier>11</ows:Identifier> 190 <ScaleDenominator>9449.423660750896</ScaleDenominator> 191 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> 192 <TileWidth>512</TileWidth> 193 <TileHeight>512</TileHeight> 194 <MatrixWidth>26699</MatrixWidth> 195 <MatrixHeight>30563</MatrixHeight> 196 </TileMatrix> 197 <TileMatrix> 198 <ows:Identifier>12</ows:Identifier> 199 <ScaleDenominator>4724.711830375448</ScaleDenominator> 200 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> 201 <TileWidth>512</TileWidth> 202 <TileHeight>512</TileHeight> 203 <MatrixWidth>53398</MatrixWidth> 204 <MatrixHeight>61125</MatrixHeight> 205 </TileMatrix> 206 <TileMatrix> 207 <ows:Identifier>13</ows:Identifier> 208 <ScaleDenominator>2362.355915187724</ScaleDenominator> 209 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> 210 <TileWidth>512</TileWidth> 211 <TileHeight>512</TileHeight> 212 <MatrixWidth>106795</MatrixWidth> 213 <MatrixHeight>122249</MatrixHeight> 214 </TileMatrix> 215 <TileMatrix> 216 <ows:Identifier>14</ows:Identifier> 217 <ScaleDenominator>944.9423660750896</ScaleDenominator> 218 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> 219 <TileWidth>512</TileWidth> 220 <TileHeight>512</TileHeight> 221 <MatrixWidth>266987</MatrixWidth> 222 <MatrixHeight>305621</MatrixHeight> 223 </TileMatrix> 224 <TileMatrix> 225 <ows:Identifier>15</ows:Identifier> 226 <ScaleDenominator>472.4711830375448</ScaleDenominator> 227 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> 228 <TileWidth>512</TileWidth> 229 <TileHeight>512</TileHeight> 230 <MatrixWidth>533973</MatrixWidth> 231 <MatrixHeight>611241</MatrixHeight> 232 </TileMatrix> 233 <TileMatrix> 234 <ows:Identifier>16</ows:Identifier> 235 <ScaleDenominator>236.2355915187724</ScaleDenominator> 236 <TopLeftCorner>-3.58727E7 4.14227E7</TopLeftCorner> 237 <TileWidth>512</TileWidth> 238 <TileHeight>512</TileHeight> 239 <MatrixWidth>1067946</MatrixWidth> 240 <MatrixHeight>1222482</MatrixHeight> 241 </TileMatrix> 242 </TileMatrixSet> 243 </Contents> 244 <ServiceMetadataURL 245 xlink:href="http://geoservices.wallonie.be/arcgis/rest/services/DONNEES_BASE/FOND_PLAN_ANNOTATIONS_2012_RW_NB/MapServer/WMTS/1.0.0/WMTSCapabilities.xml" /> 246 </Capabilities> -
trunk/test/unit/org/openstreetmap/josm/data/imagery/WMTSTileSourceTest.java
r8585 r8586 11 11 import org.junit.BeforeClass; 12 12 import org.junit.Test; 13 import org.openstreetmap.gui.jmapviewer.TileXY;14 13 import org.openstreetmap.gui.jmapviewer.tilesources.TemplatedTMSTileSource; 15 14 import org.openstreetmap.josm.JOSMFixture; … … 70 69 assertEquals("TileXMax", 2, testSource.getTileXMax(2)); 71 70 assertEquals("TileYMax", 2, testSource.getTileYMax(2)); 72 assertEquals("TileXMax", 5, testSource.getTileXMax(3));71 assertEquals("TileXMax", 4, testSource.getTileXMax(3)); 73 72 assertEquals("TileYMax", 4, testSource.getTileYMax(3)); 74 73 … … 79 78 Main.setProjection(Projections.getProjectionByCode("EPSG:31370")); 80 79 WMTSTileSource testSource = new WMTSTileSource(testImageryWALLONIE); 80 assertEquals("http://geoservices.wallonie.be/arcgis/rest/services/DONNEES_BASE/FOND_PLAN_ANNOTATIONS_2012_RW_NB/" 81 + "MapServer/WMTS/tile/1.0.0/DONNEES_BASE_FOND_PLAN_ANNOTATIONS_2012_RW_NB/default/default028mm/5/1219/1063.png", 82 testSource.getTileUrl(6, 1063, 1219)); 83 84 // +bounds=2.54,49.51,6.4,51.5 81 85 Bounds wallonieBounds = new Bounds( 82 86 new LatLon(49.485372459967245, 2.840548314430268), 83 87 new LatLon(50.820959517561256, 6.427849693016202) 84 88 ); 85 verifyBounds(wallonieBounds, testSource, 10, 20324, 17724); 89 verifyBounds(wallonieBounds, testSource, 6, 1063, 1219); 90 verifyBounds(wallonieBounds, testSource, 11, 17724, 20324); 91 LatLon ll = new LatLon(testSource.tileXYToLatLon(1063, 1219, 6)); 86 92 87 93 } 88 94 89 95 private void verifyBounds(Bounds bounds, WMTSTileSource testSource, int z, int x, int y) { 90 LatLon ret = new LatLon(testSource.tileXYToLatLon( y, y, z));96 LatLon ret = new LatLon(testSource.tileXYToLatLon(x, y, z)); 91 97 assertTrue(ret.toDisplayString() + " doesn't lie within: " + bounds.toString(), bounds.contains(ret)); 98 int tileXmax = testSource.getTileXMax(z); 99 int tileYmax = testSource.getTileYMax(z); 100 assertTrue("tile x: " + x + " is greater than allowed max: " + tileXmax, tileXmax >= x); 101 assertTrue("tile y: " + y + " is greater than allowed max: " + tileYmax, tileYmax >= y); 92 102 } 93 103 … … 96 106 Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); 97 107 WMTSTileSource testSource = new WMTSTileSource(testImageryWIEN); 98 int zoomOffset = 10; 99 100 // Linz - 11/1105/709.png 108 int zoomOffset = 9; 109 101 110 verifyMercatorTile(testSource, 0, 0, 1, zoomOffset); 102 111 verifyMercatorTile(testSource, 1105, 709, 2, zoomOffset); … … 106 115 verifyMercatorTile(testSource, 1, 1, 2, zoomOffset); 107 116 108 109 LatLon ll = new LatLon(testSource.tileXYToLatLon(500, 500, 1));110 111 TileXY xy = testSource.latLonToTileXY(new LatLon(48.21, 14.24).toCoordinate(), 1);112 assertTrue("X index is negative: " + xy.getXIndex(), xy.getXIndex() > 0);113 assertTrue(xy.getYIndex() > 0);114 117 for (int x = 0; x < 4; x++) { 115 118 for (int y = 0; y < 4; y++) { … … 119 122 for (int x = 0; x < 8; x++) { 120 123 for (int y = 0; y < 4; y++) { 121 verifyMercatorTile(testSource, x, y, zoomOffset); 122 } 123 } 124 125 verifyMercatorTile(testSource, 2 << 9 - 1, 2 << 8 - 1, zoomOffset); 126 127 assertEquals("TileXMax", 1, testSource.getTileXMax(1)); 128 assertEquals("TileYMax", 1, testSource.getTileYMax(1)); 129 assertEquals("TileXMax", 2, testSource.getTileXMax(2)); 130 assertEquals("TileYMax", 2, testSource.getTileYMax(2)); 131 assertEquals("TileXMax", 4, testSource.getTileXMax(3)); 132 assertEquals("TileYMax", 4, testSource.getTileYMax(3)); 124 verifyMercatorTile(testSource, x, y, 4, zoomOffset); 125 } 126 } 127 128 verifyMercatorTile(testSource, 2 << 9 - 1, 2 << 8 - 1, 2, zoomOffset); 129 130 verifyMercatorMax(testSource, 1, zoomOffset); 131 verifyMercatorMax(testSource, 2, zoomOffset); 132 verifyMercatorMax(testSource, 3, zoomOffset); 133 } 134 135 private void verifyMercatorMax(WMTSTileSource testSource, int zoom, int zoomOffset) { 136 TemplatedTMSTileSource verifier = new TemplatedTMSTileSource(testImageryTMS); 137 int result = testSource.getTileXMax(zoom); 138 int expected = verifier.getTileXMax(zoom + zoomOffset); 139 assertTrue("TileXMax expected: " + expected + " got: " + result, Math.abs(result - expected) < 5); 140 result = testSource.getTileYMax(zoom); 141 expected = verifier.getTileYMax(zoom + zoomOffset); 142 assertTrue("TileYMax expected: " + expected + " got: " + result, Math.abs(result - expected) < 5); 133 143 } 134 144 … … 141 151 verifyTile(new LatLon(51.1268639, 16.8731360), testSource, 1, 1, 2); 142 152 143 assertEquals("TileXMax", 37, testSource.getTileXMax(1));144 assertEquals("TileYMax", 1 9, testSource.getTileYMax(1));145 assertEquals("TileXMax", 74, testSource.getTileXMax(2));146 assertEquals("TileYMax", 37, testSource.getTileYMax(2));147 assertEquals("TileXMax", 148, testSource.getTileXMax(3));148 assertEquals("TileYMax", 74, testSource.getTileYMax(3));153 assertEquals("TileXMax", 2, testSource.getTileXMax(1)); 154 assertEquals("TileYMax", 1, testSource.getTileYMax(1)); 155 assertEquals("TileXMax", 3, testSource.getTileXMax(2)); 156 assertEquals("TileYMax", 2, testSource.getTileYMax(2)); 157 assertEquals("TileXMax", 6, testSource.getTileXMax(3)); 158 assertEquals("TileYMax", 4, testSource.getTileYMax(3)); 149 159 assertEquals( 150 160 "http://mapy.geoportal.gov.pl/wss/service/WMTS/guest/wmts/TOPO?SERVICE=WMTS&REQUEST=GetTile&" 151 + "VERSION=1.0.0&LAYER=MAPA TOPOGRAFICZNA&STYLE= &FORMAT=image/jpeg&tileMatrixSet=EPSG:4326&"161 + "VERSION=1.0.0&LAYER=MAPA TOPOGRAFICZNA&STYLE=default&FORMAT=image/jpeg&tileMatrixSet=EPSG:4326&" 152 162 + "tileMatrix=EPSG:4326:0&tileRow=1&tileCol=1", 153 163 testSource.getTileUrl(1, 1, 1)); … … 159 169 WMTSTileSource testSource = new WMTSTileSource(testImageryORTO_PL); 160 170 verifyTile(new LatLon(53.5993712684958, 19.560669777688176), testSource, 12412, 3941, 14); 161 162 171 verifyTile(new LatLon(49.783096954497786, 22.79034127751704), testSource, 17714, 10206, 14); 163 172 } … … 187 196 LatLon result = new LatLon(testSource.tileXYToLatLon(x, y, z)); 188 197 LatLon expected = new LatLon(verifier.tileXYToLatLon(x, y, z + zoomOffset)); 189 System.out.println(z + "/" + x + "/" + y + " - result: " + result.toDisplayString() + " osmMercator: " + expected.toDisplayString());198 //System.out.println(z + "/" + x + "/" + y + " - result: " + result.toDisplayString() + " osmMercator: " + expected.toDisplayString()); 190 199 assertEquals("Longitude" , expected.lon(), result.lon(), 1e-04); 191 200 assertEquals("Latitude", expected.lat(), result.lat(), 1e-04); 192 //assertTrue("result: " + result.toDisplayString() + " osmMercator: " + expected.toDisplayString(), result.equalsEpsilon(expected));193 // LatLon tileCenter = new Bounds(result, new LatLon(testSource.tileXYToLatLon(x+1, y+1, z))).getCenter();194 // TileXY backwardsResult = testSource.latLonToTileXY(tileCenter.toCoordinate(), z);195 //assertEquals(x, backwardsResult.getXIndex());196 //assertEquals(y, backwardsResult.getYIndex());197 201 } 198 202 }
Note:
See TracChangeset
for help on using the changeset viewer.