Class WMTSTileSource

  • All Implemented Interfaces:
    org.openstreetmap.gui.jmapviewer.interfaces.Attributed, org.openstreetmap.gui.jmapviewer.interfaces.TemplatedTileSource, org.openstreetmap.gui.jmapviewer.interfaces.TileSource

    public class WMTSTileSource
    extends org.openstreetmap.gui.jmapviewer.tilesources.AbstractTMSTileSource
    implements org.openstreetmap.gui.jmapviewer.interfaces.TemplatedTileSource
    Tile Source handling WMTS providers
    Since:
    8526
    • Method Detail

      • userSelectLayer

        public DefaultLayer userSelectLayer()
        Creates a dialog based on this tile source with all available layers and returns the name of selected layer
        Returns:
        Name of selected layer
      • getCapabilities

        public static WMTSCapabilities getCapabilities​(java.lang.String url,
                                                       java.util.Map<java.lang.String,​java.lang.String> headers)
                                                throws java.io.IOException,
                                                       WMTSTileSource.WMTSGetCapabilitiesException
        Call remote server and parse response to WMTSCapabilities object
        Parameters:
        url - of the getCapabilities document
        headers - HTTP headers to set when calling getCapabilities url
        Returns:
        capabilities
        Throws:
        java.io.IOException - in case of any I/O error
        WMTSTileSource.WMTSGetCapabilitiesException - when document didn't contain any layers
        java.lang.IllegalArgumentException - in case of any other error
      • parseContents

        private static java.util.Collection<WMTSTileSource.LayerparseContents​(javax.xml.stream.XMLStreamReader reader)
                                                                         throws javax.xml.stream.XMLStreamException
        Parse Contents tag. Returns when reader reaches Contents closing tag
        Parameters:
        reader - StAX reader instance
        Returns:
        collection of layers within contents with properly linked TileMatrixSets
        Throws:
        javax.xml.stream.XMLStreamException - See XMLStreamReader
      • parseLayer

        private static WMTSTileSource.Layer parseLayer​(javax.xml.stream.XMLStreamReader reader)
                                                throws javax.xml.stream.XMLStreamException
        Parse Layer tag. Returns when reader will reach Layer closing tag
        Parameters:
        reader - StAX reader instance
        Returns:
        Layer object, with tileMatrixSetLinks and no tileMatrixSet attribute set.
        Throws:
        javax.xml.stream.XMLStreamException - See XMLStreamReader
      • parseDimension

        private static WMTSTileSource.Dimension parseDimension​(javax.xml.stream.XMLStreamReader reader)
                                                        throws javax.xml.stream.XMLStreamException
        Gets Dimension value. Returns when reader is on Dimension closing tag
        Parameters:
        reader - StAX reader instance
        Returns:
        dimension
        Throws:
        javax.xml.stream.XMLStreamException - See XMLStreamReader
      • parseTileMatrixSetLink

        private static java.lang.String parseTileMatrixSetLink​(javax.xml.stream.XMLStreamReader reader)
                                                        throws javax.xml.stream.XMLStreamException
        Gets TileMatrixSetLink value. Returns when reader is on TileMatrixSetLink closing tag
        Parameters:
        reader - StAX reader instance
        Returns:
        TileMatrixSetLink identifier
        Throws:
        javax.xml.stream.XMLStreamException - See XMLStreamReader
      • parseTileMatrixSet

        private static WMTSTileSource.TileMatrixSet parseTileMatrixSet​(javax.xml.stream.XMLStreamReader reader)
                                                                throws javax.xml.stream.XMLStreamException
        Parses TileMatrixSet section. Returns when reader is on TileMatrixSet closing tag
        Parameters:
        reader - StAX reader instance
        Returns:
        TileMatrixSet object
        Throws:
        javax.xml.stream.XMLStreamException - See XMLStreamReader
      • parseTileMatrix

        private static WMTSTileSource.TileMatrix parseTileMatrix​(javax.xml.stream.XMLStreamReader reader,
                                                                 java.lang.String matrixCrs)
                                                          throws javax.xml.stream.XMLStreamException
        Parses TileMatrix section. Returns when reader is on TileMatrix closing tag.
        Parameters:
        reader - StAX reader instance
        matrixCrs - projection used by this matrix
        Returns:
        TileMatrix object
        Throws:
        javax.xml.stream.XMLStreamException - See XMLStreamReader
      • parseCoor

        private static <T> T parseCoor​(java.lang.String coor,
                                       boolean switchXY,
                                       java.util.function.BiFunction<java.lang.String,​java.lang.String,​T> function)
      • parseLatLon

        private static LatLon parseLatLon​(java.lang.String coor,
                                          boolean switchXY)
      • parseBoundingBox

        private static BBox parseBoundingBox​(javax.xml.stream.XMLStreamReader reader)
                                      throws javax.xml.stream.XMLStreamException
        Parses WGS84BoundingBox section. Returns when reader is on WGS84BoundingBox closing tag.
        Parameters:
        reader - StAX reader instance
        Returns:
        WGS84 bounding box
        Throws:
        javax.xml.stream.XMLStreamException - See XMLStreamReader
      • parseOperationMetadata

        private static WMTSCapabilities parseOperationMetadata​(javax.xml.stream.XMLStreamReader reader)
                                                        throws javax.xml.stream.XMLStreamException
        Parses OperationMetadata section. Returns when reader is on OperationsMetadata closing tag. return WMTSCapabilities with baseUrl and transferMode
        Parameters:
        reader - StAX reader instance
        Returns:
        WMTSCapabilities with baseUrl and transferMode set
        Throws:
        javax.xml.stream.XMLStreamException - See XMLStreamReader
      • initProjection

        public void initProjection​(Projection proj)
        Initializes projection for this TileSource with projection
        Parameters:
        proj - projection to be used by this TileSource
      • getTileSize

        public int getTileSize()
        Specified by:
        getTileSize in interface org.openstreetmap.gui.jmapviewer.interfaces.TileSource
        Overrides:
        getTileSize in class org.openstreetmap.gui.jmapviewer.tilesources.AbstractTMSTileSource
      • getTileUrl

        public java.lang.String getTileUrl​(int zoom,
                                           int tilex,
                                           int tiley)
        Specified by:
        getTileUrl in interface org.openstreetmap.gui.jmapviewer.interfaces.TileSource
        Overrides:
        getTileUrl in class org.openstreetmap.gui.jmapviewer.tilesources.AbstractTMSTileSource
      • getTileMatrix

        private WMTSTileSource.TileMatrix getTileMatrix​(int zoom)
        Returns TileMatrix that's working on given zoom level
        Parameters:
        zoom - zoom level
        Returns:
        TileMatrix that's working on this zoom level
      • getDistance

        public double getDistance​(double lat1,
                                  double lon1,
                                  double lat2,
                                  double lon2)
        Specified by:
        getDistance in interface org.openstreetmap.gui.jmapviewer.interfaces.TileSource
      • tileXYToLatLon

        public org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate tileXYToLatLon​(int x,
                                                                                      int y,
                                                                                      int zoom)
        Specified by:
        tileXYToLatLon in interface org.openstreetmap.gui.jmapviewer.interfaces.TileSource
      • latLonToTileXY

        public org.openstreetmap.gui.jmapviewer.TileXY latLonToTileXY​(double lat,
                                                                      double lon,
                                                                      int zoom)
        Specified by:
        latLonToTileXY in interface org.openstreetmap.gui.jmapviewer.interfaces.TileSource
      • getTileXMax

        public int getTileXMax​(int zoom)
        Specified by:
        getTileXMax in interface org.openstreetmap.gui.jmapviewer.interfaces.TileSource
        Overrides:
        getTileXMax in class org.openstreetmap.gui.jmapviewer.tilesources.AbstractTMSTileSource
      • getTileYMax

        public int getTileYMax​(int zoom)
        Specified by:
        getTileYMax in interface org.openstreetmap.gui.jmapviewer.interfaces.TileSource
        Overrides:
        getTileYMax in class org.openstreetmap.gui.jmapviewer.tilesources.AbstractTMSTileSource
      • latLonToXY

        public java.awt.Point latLonToXY​(double lat,
                                         double lon,
                                         int zoom)
        Specified by:
        latLonToXY in interface org.openstreetmap.gui.jmapviewer.interfaces.TileSource
      • xyToLatLon

        public org.openstreetmap.gui.jmapviewer.Coordinate xyToLatLon​(int x,
                                                                      int y,
                                                                      int zoom)
        Specified by:
        xyToLatLon in interface org.openstreetmap.gui.jmapviewer.interfaces.TileSource
      • getHeaders

        public java.util.Map<java.lang.String,​java.lang.String> getHeaders()
        Specified by:
        getHeaders in interface org.openstreetmap.gui.jmapviewer.interfaces.TemplatedTileSource
      • getMaxZoom

        public int getMaxZoom()
        Specified by:
        getMaxZoom in interface org.openstreetmap.gui.jmapviewer.interfaces.TileSource
        Overrides:
        getMaxZoom in class org.openstreetmap.gui.jmapviewer.tilesources.AbstractTMSTileSource
      • getTileId

        public java.lang.String getTileId​(int zoom,
                                          int tilex,
                                          int tiley)
        Specified by:
        getTileId in interface org.openstreetmap.gui.jmapviewer.interfaces.TileSource
        Overrides:
        getTileId in class org.openstreetmap.gui.jmapviewer.tilesources.AbstractTMSTileSource
      • checkUrl

        public static void checkUrl​(java.lang.String url)
        Checks if url is acceptable by this Tile Source
        Parameters:
        url - URL to check
      • groupLayersByNameAndTileMatrixSet

        public static java.util.List<java.util.Map.Entry<java.lang.String,​java.util.List<WMTSTileSource.Layer>>> groupLayersByNameAndTileMatrixSet​(java.util.Collection<WMTSTileSource.Layer> layers)
        Group layers by name and tile matrix set.
        Parameters:
        layers - to be grouped
        Returns:
        list with entries - grouping identifier + list of layers
      • getSupportedProjections

        public java.util.Collection<java.lang.String> getSupportedProjections()
        Returns set of projection codes that this TileSource supports.
        Returns:
        set of projection codes that this TileSource supports
      • tileXYtoProjected

        public org.openstreetmap.gui.jmapviewer.interfaces.IProjected tileXYtoProjected​(int x,
                                                                                        int y,
                                                                                        int zoom)
        Specified by:
        tileXYtoProjected in interface org.openstreetmap.gui.jmapviewer.interfaces.TileSource
      • projectedToTileXY

        public org.openstreetmap.gui.jmapviewer.TileXY projectedToTileXY​(org.openstreetmap.gui.jmapviewer.interfaces.IProjected projected,
                                                                         int zoom)
        Specified by:
        projectedToTileXY in interface org.openstreetmap.gui.jmapviewer.interfaces.TileSource
      • isInside

        public boolean isInside​(org.openstreetmap.gui.jmapviewer.Tile inner,
                                org.openstreetmap.gui.jmapviewer.Tile outer)
        Specified by:
        isInside in interface org.openstreetmap.gui.jmapviewer.interfaces.TileSource
      • getCoveringTileRange

        public org.openstreetmap.gui.jmapviewer.TileRange getCoveringTileRange​(org.openstreetmap.gui.jmapviewer.Tile tile,
                                                                               int newZoom)
        Specified by:
        getCoveringTileRange in interface org.openstreetmap.gui.jmapviewer.interfaces.TileSource
      • getServerCRS

        public java.lang.String getServerCRS()
        Specified by:
        getServerCRS in interface org.openstreetmap.gui.jmapviewer.interfaces.TileSource
      • getLayers

        public java.util.Collection<WMTSTileSource.LayergetLayers()
        Layers that can be used with this tile source
        Returns:
        unmodifiable collection of layers available in this tile source
        Since:
        13879