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 classWMTSTileSource.Dimensionstatic classWMTSTileSource.LayerClass representing WMTS Layer informationprivate static classWMTSTileSource.SelectLayerDialogprivate static classWMTSTileSource.TileMatrixstatic classWMTSTileSource.TileMatrixSetclass representing WMTS TileMatrixSet This connects projection and TileMatrix (how the map is divided in tiles)private static classWMTSTileSource.TileMatrixSetBuilderstatic classWMTSTileSource.WMTSGetCapabilitiesExceptionException thrown when parser doesn't find expected information in GetCapabilities document
-
Field Summary
Fields Modifier and Type Field Description private intcachedTileSizeprivate doublecrsScaleprivate WMTSTileSource.LayercurrentLayerprivate WMTSTileSource.TileMatrixSetcurrentTileMatrixSetprivate DefaultLayerdefaultLayerprivate java.util.Map<java.lang.String,java.lang.String>headersprivate java.util.Collection<WMTSTileSource.Layer>layersprivate NativeScaleLayer.ScaleListnativeScaleListprivate static javax.xml.namespace.QNameQN_CONTENTSprivate static javax.xml.namespace.QNameQN_DEFAULTprivate static javax.xml.namespace.QNameQN_DIMENSIONprivate static javax.xml.namespace.QNameQN_FORMATprivate static javax.xml.namespace.QNameQN_LAYERprivate static javax.xml.namespace.QNameQN_MATRIX_HEIGHTprivate static javax.xml.namespace.QNameQN_MATRIX_WIDTHprivate static javax.xml.namespace.QNameQN_RESOURCE_URLprivate static javax.xml.namespace.QNameQN_SCALE_DENOMINATORprivate static javax.xml.namespace.QNameQN_STYLEprivate static javax.xml.namespace.QNameQN_TILE_HEIGHTprivate static javax.xml.namespace.QNameQN_TILE_WIDTHprivate static javax.xml.namespace.QNameQN_TILEMATRIXprivate static javax.xml.namespace.QNameQN_TILEMATRIX_SET_LINKprivate static javax.xml.namespace.QNameQN_TILEMATRIXSETprivate static javax.xml.namespace.QNameQN_TOPLEFT_CORNERprivate static javax.xml.namespace.QNameQN_VALUEprivate ProjectiontileProjectionprivate GetCapabilitiesParseHelper.TransferModetransferModeprivate static java.lang.StringURL_GET_ENCODING_PARAMSstatic java.lang.StringWMTS_NS_URLWMTS 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 voidcheckUrl(java.lang.String url)Checks if url is acceptable by this Tile Sourcestatic WMTSCapabilitiesgetCapabilities(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.TileRangegetCoveringTileRange(org.openstreetmap.gui.jmapviewer.Tile tile, int newZoom)doublegetDistance(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 sourceintgetMaxZoom()NativeScaleLayer.ScaleListgetNativeScales()Get native scales of tile source.java.lang.StringgetServerCRS()java.util.Collection<java.lang.String>getSupportedProjections()Returns set of projection codes that this TileSource supports.java.lang.StringgetTileId(int zoom, int tilex, int tiley)private WMTSTileSource.TileMatrixgetTileMatrix(int zoom)Returns TileMatrix that's working on given zoom levelProjectiongetTileProjection()Returns the tile projection.private ProjectionBoundsgetTileProjectionBounds(org.openstreetmap.gui.jmapviewer.Tile tile)intgetTileSize()java.lang.StringgetTileUrl(int zoom, int tilex, int tiley)intgetTileXMax(int zoom)private intgetTileXMax(int zoom, Projection proj)intgetTileYMax(int zoom)private intgetTileYMax(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.voidinitProjection(Projection proj)Initializes projection for this TileSource with projectionbooleanisInside(org.openstreetmap.gui.jmapviewer.Tile inner, org.openstreetmap.gui.jmapviewer.Tile outer)org.openstreetmap.gui.jmapviewer.TileXYlatLonToTileXY(double lat, double lon, int zoom)java.awt.PointlatLonToXY(double lat, double lon, int zoom)private static BBoxparseBoundingBox(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> TparseCoor(java.lang.String coor, boolean switchXY, java.util.function.BiFunction<java.lang.String,java.lang.String,T> function)private static WMTSTileSource.DimensionparseDimension(javax.xml.stream.XMLStreamReader reader)Gets Dimension value.private static EastNorthparseEastNorth(java.lang.String coor, boolean switchXY)private static LatLonparseLatLon(java.lang.String coor, boolean switchXY)private static WMTSTileSource.LayerparseLayer(javax.xml.stream.XMLStreamReader reader)Parse Layer tag.private static WMTSCapabilitiesparseOperationMetadata(javax.xml.stream.XMLStreamReader reader)Parses OperationMetadata section.private static WMTSTileSource.TileMatrixparseTileMatrix(javax.xml.stream.XMLStreamReader reader, java.lang.String matrixCrs)Parses TileMatrix section.private static WMTSTileSource.TileMatrixSetparseTileMatrixSet(javax.xml.stream.XMLStreamReader reader)Parses TileMatrixSet section.private static java.lang.StringparseTileMatrixSetLink(javax.xml.stream.XMLStreamReader reader)Gets TileMatrixSetLink value.org.openstreetmap.gui.jmapviewer.TileXYprojectedToTileXY(org.openstreetmap.gui.jmapviewer.interfaces.IProjected projected, int zoom)private EastNorthtileToEastNorth(int x, int y, int z)org.openstreetmap.gui.jmapviewer.interfaces.ICoordinatetileXYToLatLon(int x, int y, int zoom)org.openstreetmap.gui.jmapviewer.interfaces.IProjectedtileXYtoProjected(int x, int y, int zoom)DefaultLayeruserSelectLayer()Creates a dialog based on this tile source with all available layers and returns the name of selected layerorg.openstreetmap.gui.jmapviewer.CoordinatexyToLatLon(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:
getTileSizein interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileSource- Overrides:
getTileSizein classorg.openstreetmap.gui.jmapviewer.tilesources.AbstractTMSTileSource
-
getTileUrl
public java.lang.String getTileUrl(int zoom, int tilex, int tiley)
- Specified by:
getTileUrlin interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileSource- Overrides:
getTileUrlin 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:
getDistancein interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileSource
-
tileXYToLatLon
public org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate tileXYToLatLon(int x, int y, int zoom)
- Specified by:
tileXYToLatLonin interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileSource
-
latLonToTileXY
public org.openstreetmap.gui.jmapviewer.TileXY latLonToTileXY(double lat, double lon, int zoom)
- Specified by:
latLonToTileXYin interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileSource
-
getTileXMax
public int getTileXMax(int zoom)
- Specified by:
getTileXMaxin interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileSource- Overrides:
getTileXMaxin classorg.openstreetmap.gui.jmapviewer.tilesources.AbstractTMSTileSource
-
getTileYMax
public int getTileYMax(int zoom)
- Specified by:
getTileYMaxin interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileSource- Overrides:
getTileYMaxin classorg.openstreetmap.gui.jmapviewer.tilesources.AbstractTMSTileSource
-
latLonToXY
public java.awt.Point latLonToXY(double lat, double lon, int zoom)
- Specified by:
latLonToXYin interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileSource
-
xyToLatLon
public org.openstreetmap.gui.jmapviewer.Coordinate xyToLatLon(int x, int y, int zoom)
- Specified by:
xyToLatLonin interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileSource
-
getHeaders
public java.util.Map<java.lang.String,java.lang.String> getHeaders()
- Specified by:
getHeadersin interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TemplatedTileSource
-
getMaxZoom
public int getMaxZoom()
- Specified by:
getMaxZoomin interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileSource- Overrides:
getMaxZoomin classorg.openstreetmap.gui.jmapviewer.tilesources.AbstractTMSTileSource
-
getTileId
public java.lang.String getTileId(int zoom, int tilex, int tiley)
- Specified by:
getTileIdin interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileSource- Overrides:
getTileIdin 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.ScaleListof 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:
tileXYtoProjectedin 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:
projectedToTileXYin 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:
isInsidein interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileSource
-
getCoveringTileRange
public org.openstreetmap.gui.jmapviewer.TileRange getCoveringTileRange(org.openstreetmap.gui.jmapviewer.Tile tile, int newZoom)
- Specified by:
getCoveringTileRangein interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileSource
-
getServerCRS
public java.lang.String getServerCRS()
- Specified by:
getServerCRSin 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
-
-