Class WMTSTileSource
- java.lang.Object
-
- org.openstreetmap.gui.jmapviewer.tilesources.AbstractTileSource
-
- org.openstreetmap.gui.jmapviewer.tilesources.AbstractTMSTileSource
-
- org.openstreetmap.josm.data.imagery.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
WMTSTileSource.Dimension
static class
WMTSTileSource.Layer
Class representing WMTS Layer informationprivate static class
WMTSTileSource.SelectLayerDialog
private static class
WMTSTileSource.TileMatrix
static class
WMTSTileSource.TileMatrixSet
class representing WMTS TileMatrixSet This connects projection and TileMatrix (how the map is divided in tiles)private static class
WMTSTileSource.TileMatrixSetBuilder
static class
WMTSTileSource.WMTSGetCapabilitiesException
Exception thrown when parser doesn't find expected information in GetCapabilities document
-
Field Summary
Fields Modifier and Type Field Description private int
cachedTileSize
private double
crsScale
private WMTSTileSource.Layer
currentLayer
private WMTSTileSource.TileMatrixSet
currentTileMatrixSet
private DefaultLayer
defaultLayer
private java.util.Map<java.lang.String,java.lang.String>
headers
private java.util.Collection<WMTSTileSource.Layer>
layers
private NativeScaleLayer.ScaleList
nativeScaleList
private static javax.xml.namespace.QName
QN_CONTENTS
private static javax.xml.namespace.QName
QN_DEFAULT
private static javax.xml.namespace.QName
QN_DIMENSION
private static javax.xml.namespace.QName
QN_FORMAT
private static javax.xml.namespace.QName
QN_LAYER
private static javax.xml.namespace.QName
QN_MATRIX_HEIGHT
private static javax.xml.namespace.QName
QN_MATRIX_WIDTH
private static javax.xml.namespace.QName
QN_RESOURCE_URL
private static javax.xml.namespace.QName
QN_SCALE_DENOMINATOR
private static javax.xml.namespace.QName
QN_STYLE
private static javax.xml.namespace.QName
QN_TILE_HEIGHT
private static javax.xml.namespace.QName
QN_TILE_WIDTH
private static javax.xml.namespace.QName
QN_TILEMATRIX
private static javax.xml.namespace.QName
QN_TILEMATRIX_SET_LINK
private static javax.xml.namespace.QName
QN_TILEMATRIXSET
private static javax.xml.namespace.QName
QN_TOPLEFT_CORNER
private static javax.xml.namespace.QName
QN_VALUE
private Projection
tileProjection
private GetCapabilitiesParseHelper.TransferMode
transferMode
private static java.lang.String
URL_GET_ENCODING_PARAMS
static java.lang.String
WMTS_NS_URL
WMTS namespace address
-
Constructor Summary
Constructors Constructor Description WMTSTileSource(ImageryInfo info)
Creates a tile source based on imagery infoWMTSTileSource(ImageryInfo info, Projection projection)
Creates a tile source based on imagery info and initializes it with given projection.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
checkUrl(java.lang.String url)
Checks if url is acceptable by this Tile Sourcestatic WMTSCapabilities
getCapabilities(java.lang.String url, java.util.Map<java.lang.String,java.lang.String> headers)
Call remote server and parse response to WMTSCapabilities objectorg.openstreetmap.gui.jmapviewer.TileRange
getCoveringTileRange(org.openstreetmap.gui.jmapviewer.Tile tile, int newZoom)
double
getDistance(double lat1, double lon1, double lat2, double lon2)
java.util.Map<java.lang.String,java.lang.String>
getHeaders()
java.util.Collection<WMTSTileSource.Layer>
getLayers()
Layers that can be used with this tile sourceint
getMaxZoom()
NativeScaleLayer.ScaleList
getNativeScales()
Get native scales of tile source.java.lang.String
getServerCRS()
java.util.Collection<java.lang.String>
getSupportedProjections()
Returns set of projection codes that this TileSource supports.java.lang.String
getTileId(int zoom, int tilex, int tiley)
private WMTSTileSource.TileMatrix
getTileMatrix(int zoom)
Returns TileMatrix that's working on given zoom levelProjection
getTileProjection()
Returns the tile projection.private ProjectionBounds
getTileProjectionBounds(org.openstreetmap.gui.jmapviewer.Tile tile)
int
getTileSize()
java.lang.String
getTileUrl(int zoom, int tilex, int tiley)
int
getTileXMax(int zoom)
private int
getTileXMax(int zoom, Projection proj)
int
getTileYMax(int zoom)
private int
getTileYMax(int zoom, Projection proj)
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.void
initProjection(Projection proj)
Initializes projection for this TileSource with projectionboolean
isInside(org.openstreetmap.gui.jmapviewer.Tile inner, org.openstreetmap.gui.jmapviewer.Tile outer)
org.openstreetmap.gui.jmapviewer.TileXY
latLonToTileXY(double lat, double lon, int zoom)
java.awt.Point
latLonToXY(double lat, double lon, int zoom)
private static BBox
parseBoundingBox(javax.xml.stream.XMLStreamReader reader)
Parses WGS84BoundingBox section.private static java.util.Collection<WMTSTileSource.Layer>
parseContents(javax.xml.stream.XMLStreamReader reader)
Parse Contents tag.private static <T> T
parseCoor(java.lang.String coor, boolean switchXY, java.util.function.BiFunction<java.lang.String,java.lang.String,T> function)
private static WMTSTileSource.Dimension
parseDimension(javax.xml.stream.XMLStreamReader reader)
Gets Dimension value.private static EastNorth
parseEastNorth(java.lang.String coor, boolean switchXY)
private static LatLon
parseLatLon(java.lang.String coor, boolean switchXY)
private static WMTSTileSource.Layer
parseLayer(javax.xml.stream.XMLStreamReader reader)
Parse Layer tag.private static WMTSCapabilities
parseOperationMetadata(javax.xml.stream.XMLStreamReader reader)
Parses OperationMetadata section.private static WMTSTileSource.TileMatrix
parseTileMatrix(javax.xml.stream.XMLStreamReader reader, java.lang.String matrixCrs)
Parses TileMatrix section.private static WMTSTileSource.TileMatrixSet
parseTileMatrixSet(javax.xml.stream.XMLStreamReader reader)
Parses TileMatrixSet section.private static java.lang.String
parseTileMatrixSetLink(javax.xml.stream.XMLStreamReader reader)
Gets TileMatrixSetLink value.org.openstreetmap.gui.jmapviewer.TileXY
projectedToTileXY(org.openstreetmap.gui.jmapviewer.interfaces.IProjected projected, int zoom)
private EastNorth
tileToEastNorth(int x, int y, int z)
org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate
tileXYToLatLon(int x, int y, int zoom)
org.openstreetmap.gui.jmapviewer.interfaces.IProjected
tileXYtoProjected(int x, int y, int zoom)
DefaultLayer
userSelectLayer()
Creates a dialog based on this tile source with all available layers and returns the name of selected layerorg.openstreetmap.gui.jmapviewer.Coordinate
xyToLatLon(int x, int y, int zoom)
-
Methods inherited from class org.openstreetmap.gui.jmapviewer.tilesources.AbstractTMSTileSource
getBaseUrl, getDefaultTileSize, getExtension, getId, getMetadata, getMinZoom, getName, getTilePath, getTileXMin, getTileYMin, isModTileFeatures, isNoTileAtZoom, toString
-
Methods inherited from class org.openstreetmap.gui.jmapviewer.tilesources.AbstractTileSource
getAttributionImage, getAttributionImageURL, getAttributionLinkURL, getAttributionText, getTermsOfUseText, getTermsOfUseURL, requiresAttribution, setAttributionImage, setAttributionImageURL, setAttributionLinkURL, setAttributionText, setTermsOfUseText, setTermsOfUseURL
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
-
-
-
Field Detail
-
WMTS_NS_URL
public static final java.lang.String WMTS_NS_URL
WMTS namespace address- See Also:
- Constant Field Values
-
QN_CONTENTS
private static final javax.xml.namespace.QName QN_CONTENTS
-
QN_DEFAULT
private static final javax.xml.namespace.QName QN_DEFAULT
-
QN_DIMENSION
private static final javax.xml.namespace.QName QN_DIMENSION
-
QN_FORMAT
private static final javax.xml.namespace.QName QN_FORMAT
-
QN_LAYER
private static final javax.xml.namespace.QName QN_LAYER
-
QN_MATRIX_WIDTH
private static final javax.xml.namespace.QName QN_MATRIX_WIDTH
-
QN_MATRIX_HEIGHT
private static final javax.xml.namespace.QName QN_MATRIX_HEIGHT
-
QN_RESOURCE_URL
private static final javax.xml.namespace.QName QN_RESOURCE_URL
-
QN_SCALE_DENOMINATOR
private static final javax.xml.namespace.QName QN_SCALE_DENOMINATOR
-
QN_STYLE
private static final javax.xml.namespace.QName QN_STYLE
-
QN_TILEMATRIX
private static final javax.xml.namespace.QName QN_TILEMATRIX
-
QN_TILEMATRIXSET
private static final javax.xml.namespace.QName QN_TILEMATRIXSET
-
QN_TILEMATRIX_SET_LINK
private static final javax.xml.namespace.QName QN_TILEMATRIX_SET_LINK
-
QN_TILE_WIDTH
private static final javax.xml.namespace.QName QN_TILE_WIDTH
-
QN_TILE_HEIGHT
private static final javax.xml.namespace.QName QN_TILE_HEIGHT
-
QN_TOPLEFT_CORNER
private static final javax.xml.namespace.QName QN_TOPLEFT_CORNER
-
QN_VALUE
private static final javax.xml.namespace.QName QN_VALUE
-
URL_GET_ENCODING_PARAMS
private static final java.lang.String URL_GET_ENCODING_PARAMS
- See Also:
- Constant Field Values
-
cachedTileSize
private int cachedTileSize
-
headers
private final java.util.Map<java.lang.String,java.lang.String> headers
-
layers
private final java.util.Collection<WMTSTileSource.Layer> layers
-
currentLayer
private WMTSTileSource.Layer currentLayer
-
currentTileMatrixSet
private WMTSTileSource.TileMatrixSet currentTileMatrixSet
-
crsScale
private double crsScale
-
transferMode
private final GetCapabilitiesParseHelper.TransferMode transferMode
-
nativeScaleList
private NativeScaleLayer.ScaleList nativeScaleList
-
defaultLayer
private final DefaultLayer defaultLayer
-
tileProjection
private Projection tileProjection
-
-
Constructor Detail
-
WMTSTileSource
public WMTSTileSource(ImageryInfo info) throws java.io.IOException, WMTSTileSource.WMTSGetCapabilitiesException
Creates a tile source based on imagery info- Parameters:
info
- imagery info- Throws:
java.io.IOException
- if any I/O error occursWMTSTileSource.WMTSGetCapabilitiesException
- when document didn't contain any layersjava.lang.IllegalArgumentException
- if any other error happens for the given imagery info
-
WMTSTileSource
public WMTSTileSource(ImageryInfo info, Projection projection) throws java.io.IOException, WMTSTileSource.WMTSGetCapabilitiesException
Creates a tile source based on imagery info and initializes it with given projection.- Parameters:
info
- imagery infoprojection
- projection to be used by this TileSource- Throws:
java.io.IOException
- if any I/O error occursWMTSTileSource.WMTSGetCapabilitiesException
- when document didn't contain any layersjava.lang.IllegalArgumentException
- if any other error happens for the given imagery info- Since:
- 14507
-
-
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 documentheaders
- HTTP headers to set when calling getCapabilities url- Returns:
- capabilities
- Throws:
java.io.IOException
- in case of any I/O errorWMTSTileSource.WMTSGetCapabilitiesException
- when document didn't contain any layersjava.lang.IllegalArgumentException
- in case of any other error
-
parseContents
private static java.util.Collection<WMTSTileSource.Layer> parseContents(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
- SeeXMLStreamReader
-
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
- SeeXMLStreamReader
-
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
- SeeXMLStreamReader
-
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
- SeeXMLStreamReader
-
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
- SeeXMLStreamReader
-
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 instancematrixCrs
- projection used by this matrix- Returns:
- TileMatrix object
- Throws:
javax.xml.stream.XMLStreamException
- SeeXMLStreamReader
-
parseCoor
private static <T> T parseCoor(java.lang.String coor, boolean switchXY, java.util.function.BiFunction<java.lang.String,java.lang.String,T> function)
-
parseEastNorth
private static EastNorth parseEastNorth(java.lang.String coor, boolean switchXY)
-
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
- SeeXMLStreamReader
-
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
- SeeXMLStreamReader
-
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 interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileSource
- Overrides:
getTileSize
in classorg.openstreetmap.gui.jmapviewer.tilesources.AbstractTMSTileSource
-
getTileUrl
public java.lang.String getTileUrl(int zoom, int tilex, int tiley)
- Specified by:
getTileUrl
in interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileSource
- Overrides:
getTileUrl
in classorg.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 interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileSource
-
tileXYToLatLon
public org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate tileXYToLatLon(int x, int y, int zoom)
- Specified by:
tileXYToLatLon
in interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileSource
-
latLonToTileXY
public org.openstreetmap.gui.jmapviewer.TileXY latLonToTileXY(double lat, double lon, int zoom)
- Specified by:
latLonToTileXY
in interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileSource
-
getTileXMax
public int getTileXMax(int zoom)
- Specified by:
getTileXMax
in interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileSource
- Overrides:
getTileXMax
in classorg.openstreetmap.gui.jmapviewer.tilesources.AbstractTMSTileSource
-
getTileYMax
public int getTileYMax(int zoom)
- Specified by:
getTileYMax
in interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileSource
- Overrides:
getTileYMax
in classorg.openstreetmap.gui.jmapviewer.tilesources.AbstractTMSTileSource
-
latLonToXY
public java.awt.Point latLonToXY(double lat, double lon, int zoom)
- Specified by:
latLonToXY
in interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileSource
-
xyToLatLon
public org.openstreetmap.gui.jmapviewer.Coordinate xyToLatLon(int x, int y, int zoom)
- Specified by:
xyToLatLon
in interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileSource
-
getHeaders
public java.util.Map<java.lang.String,java.lang.String> getHeaders()
- Specified by:
getHeaders
in interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TemplatedTileSource
-
getMaxZoom
public int getMaxZoom()
- Specified by:
getMaxZoom
in interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileSource
- Overrides:
getMaxZoom
in classorg.openstreetmap.gui.jmapviewer.tilesources.AbstractTMSTileSource
-
getTileId
public java.lang.String getTileId(int zoom, int tilex, int tiley)
- Specified by:
getTileId
in interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileSource
- Overrides:
getTileId
in classorg.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
-
getTileYMax
private int getTileYMax(int zoom, Projection proj)
-
getTileXMax
private int getTileXMax(int zoom, Projection proj)
-
getNativeScales
public NativeScaleLayer.ScaleList getNativeScales()
Get native scales of tile source.- Returns:
NativeScaleLayer.ScaleList
of native scales
-
getTileProjection
public Projection getTileProjection()
Returns the tile projection.- Returns:
- the tile projection
-
tileXYtoProjected
public org.openstreetmap.gui.jmapviewer.interfaces.IProjected tileXYtoProjected(int x, int y, int zoom)
- Specified by:
tileXYtoProjected
in interfaceorg.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 interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileSource
-
tileToEastNorth
private EastNorth tileToEastNorth(int x, int y, int z)
-
getTileProjectionBounds
private ProjectionBounds getTileProjectionBounds(org.openstreetmap.gui.jmapviewer.Tile tile)
-
isInside
public boolean isInside(org.openstreetmap.gui.jmapviewer.Tile inner, org.openstreetmap.gui.jmapviewer.Tile outer)
- Specified by:
isInside
in interfaceorg.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 interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileSource
-
getServerCRS
public java.lang.String getServerCRS()
- Specified by:
getServerCRS
in interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileSource
-
getLayers
public java.util.Collection<WMTSTileSource.Layer> getLayers()
Layers that can be used with this tile source- Returns:
- unmodifiable collection of layers available in this tile source
- Since:
- 13879
-
-