Ignore:
Timestamp:
2015-07-08T23:06:52+02:00 (9 years ago)
Author:
wiktorn
Message:
  • (WMTS) Added Style support
  • (WMTS) Added MatrixHeight and MatrixWidth support
  • (WMTS) Corrected best zoom calcu

Closes: #10623 - Walonnie WMTS finally works.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java

    r8585 r8586  
    8080        int tileWidth;
    8181        int tileHeight;
     82        public int matrixWidth = -1;
     83        public int matrixHeight = -1;
    8284    }
    8385
     
    99101        Map<String, TileMatrixSet> tileMatrixSetByCRS = new ConcurrentHashMap<>();
    100102        public String baseUrl;
     103        public String style;
    101104    }
    102105
     
    163166    private double crsScale;
    164167    private TransferMode transferMode;
    165     private String style = "";
    166168
    167169    /**
     
    248250            layer.name = getStringByXpath(layerNode, "Identifier");
    249251            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            }
    250256            NodeList tileMatrixSetLinks = getByXpath(layerNode, "TileMatrixSetLink");
    251257            for (int tileMatrixId = 0; tileMatrixId < tileMatrixSetLinks.getLength(); tileMatrixId++) {
     
    287293                tileMatrix.tileHeight = Integer.parseInt(getStringByXpath(tileMatrixNode, "TileHeight"));
    288294                tileMatrix.tileWidth = Integer.parseInt(getStringByXpath(tileMatrixNode, "TileHeight"));
     295                tileMatrix.matrixWidth = getOptionalIntegerByXpath(tileMatrixNode, "MatrixWidth");
     296                tileMatrix.matrixHeight = getOptionalIntegerByXpath(tileMatrixNode, "MatrixHeight");
    289297                if (tileMatrix.tileHeight != tileMatrix.tileWidth) {
    290298                    throw new AssertionError(tr("Only square tiles are supported. {0}x{1} returned by server for TileMatrix identifier {2}",
     
    304312        }
    305313        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);
    306322    }
    307323
     
    384400                .replaceAll("\\{TileRow\\}", Integer.toString(tiley))
    385401                .replaceAll("\\{TileCol\\}", Integer.toString(tilex))
    386                 .replaceAll("\\{Style\\}", this.style);
     402                .replaceAll("\\{Style\\}", this.currentLayer.style);
    387403    }
    388404
     
    595611            return 0;
    596612        }
     613
     614        if (matrix.matrixHeight != -1) {
     615            return matrix.matrixHeight;
     616        }
     617
    597618        double scale = matrix.scaleDenominator * this.crsScale;
    598         Bounds bounds = Main.getProjection().getWorldBoundsLatLon();
     619        Bounds bounds = proj.getWorldBoundsLatLon();
    599620        EastNorth min = proj.latlon2eastNorth(bounds.getMin());
    600621        EastNorth max = proj.latlon2eastNorth(bounds.getMax());
     
    607628            return 0;
    608629        }
     630        if (matrix.matrixWidth != -1) {
     631            return matrix.matrixWidth;
     632        }
     633
    609634        double scale = matrix.scaleDenominator * this.crsScale;
    610         Bounds bounds = Main.getProjection().getWorldBoundsLatLon();
     635        Bounds bounds = proj.getWorldBoundsLatLon();
    611636        EastNorth min = proj.latlon2eastNorth(bounds.getMin());
    612637        EastNorth max = proj.latlon2eastNorth(bounds.getMax());
Note: See TracChangeset for help on using the changeset viewer.