public class WMTSTileSource extends AbstractTMSTileSource implements TemplatedTileSource
Modifier and Type | Class and Description |
---|---|
private static class |
WMTSTileSource.Dimension |
static class |
WMTSTileSource.Layer
Class representing WMTS Layer information
|
private 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
|
Modifier and Type | Field and Description |
---|---|
private static java.lang.String[] |
ALL_PATTERNS |
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 java.lang.String |
PATTERN_HEADER |
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
|
baseUrl, id, modTileFeatures, name, tileSize
attributionImage, attributionImageURL, attributionLinkURL, attributionText, termsOfUseText, termsOfUseURL
Constructor and Description |
---|
WMTSTileSource(ImageryInfo info)
Creates a tile source based on imagery info
|
WMTSTileSource(ImageryInfo info,
Projection projection)
Creates a tile source based on imagery info and initializes it with given projection.
|
Modifier and Type | Method and Description |
---|---|
static void |
checkUrl(java.lang.String url)
Checks if url is acceptable by this Tile Source
|
static WMTSCapabilities |
getCapabilities(java.lang.String url,
java.util.Map<java.lang.String,java.lang.String> headers)
Call remote server and parse response to WMTSCapabilities object
|
TileRange |
getCoveringTileRange(Tile tile,
int newZoom)
Returns a range of tiles, that cover a given tile, which is
usually at a different zoom level.
|
double |
getDistance(double lat1,
double lon1,
double lat2,
double lon2)
Gets the distance using Spherical law of cosines.
|
java.util.Map<java.lang.String,java.lang.String> |
getHeaders() |
java.util.Collection<WMTSTileSource.Layer> |
getLayers()
Layers that can be used with this tile source
|
int |
getMaxZoom()
Specifies the maximum zoom value.
|
NativeScaleLayer.ScaleList |
getNativeScales()
Get native scales of tile source.
|
java.lang.String |
getServerCRS()
Get coordinate reference system for this tile source.
|
java.util.Collection<java.lang.String> |
getSupportedProjections() |
java.lang.String |
getTileId(int zoom,
int tilex,
int tiley)
Creates tile identifier that is unique among all tile sources, but the same tile will always
get the same identifier.
|
private WMTSTileSource.TileMatrix |
getTileMatrix(int zoom) |
Projection |
getTileProjection()
Returns the tile projection.
|
private ProjectionBounds |
getTileProjectionBounds(Tile tile) |
int |
getTileSize()
Specifies how large each tile is.
|
java.lang.String |
getTileUrl(int zoom,
int tilex,
int tiley)
Constructs the tile url.
|
int |
getTileXMax(int zoom)
Get maximum x index of tile for specified zoom level.
|
private int |
getTileXMax(int zoom,
Projection proj) |
int |
getTileYMax(int zoom)
Get maximum y index of tile for specified zoom level.
|
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) |
private java.lang.String |
handleTemplate(java.lang.String url) |
void |
initProjection(Projection proj)
Initializes projection for this TileSource with projection
|
boolean |
isInside(Tile inner,
Tile outer)
Check if one tile is inside another tile.
|
TileXY |
latLonToTileXY(double lat,
double lon,
int zoom)
Transforms longitude and latitude to tile indices.
|
TileXY |
latLonToTileXY(ICoordinate point,
int zoom)
Transforms longitude and latitude to tile indices.
|
java.awt.Point |
latLonToXY(double lat,
double lon,
int zoom)
Transforms longitude and latitude to pixel space (as if all tiles at specified zoom level where joined).
|
java.awt.Point |
latLonToXY(ICoordinate point,
int zoom)
Transforms longitude and latitude to pixel space (as if all tiles at specified zoom level where joined).
|
private static java.util.Collection<WMTSTileSource.Layer> |
parseContents(javax.xml.stream.XMLStreamReader reader)
Parse Contents tag.
|
private static WMTSTileSource.Dimension |
parseDimension(javax.xml.stream.XMLStreamReader reader)
Gets Dimension value.
|
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.
|
TileXY |
projectedToTileXY(IProjected projected,
int zoom)
Convert projected coordinates to tile indices.
|
private EastNorth |
tileToEastNorth(int x,
int y,
int z) |
ICoordinate |
tileXYToLatLon(int x,
int y,
int zoom)
Transforms tile indices to longitude and latitude.
|
ICoordinate |
tileXYToLatLon(Tile tile)
Determines to longitude and latitude of a tile.
|
ICoordinate |
tileXYToLatLon(TileXY xy,
int zoom)
Transforms tile indices to longitude and latitude.
|
IProjected |
tileXYtoProjected(int x,
int y,
int zoom)
Convert tile indices (x/y/zoom) into projected coordinates of the tile origin.
|
DefaultLayer |
userSelectLayer()
Creates a dialog based on this tile source with all available layers and returns the name of selected layer
|
Coordinate |
xyToLatLon(int x,
int y,
int zoom)
Transforms a point in pixel space to longitude/latitude (WGS84).
|
Coordinate |
xyToLatLon(java.awt.Point point,
int zoom)
Transforms a point in pixel space to longitude/latitude (WGS84).
|
getBaseUrl, getDefaultTileSize, getExtension, getId, getMetadata, getMinZoom, getName, getTilePath, getTileXMin, getTileYMin, isModTileFeatures, isNoTileAtZoom, toString
getAttributionImage, getAttributionImageURL, getAttributionLinkURL, getAttributionText, getTermsOfUseText, getTermsOfUseURL, requiresAttribution, setAttributionImage, setAttributionImageURL, setAttributionLinkURL, setAttributionText, setTermsOfUseText, setTermsOfUseURL
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getDefaultTileSize, getId, getMetadata, getMinZoom, getName, getTileXMin, getTileYMin, isModTileFeatures, isNoTileAtZoom
getAttributionImage, getAttributionImageURL, getAttributionLinkURL, getAttributionText, getTermsOfUseText, getTermsOfUseURL, requiresAttribution
public static final java.lang.String WMTS_NS_URL
private static final javax.xml.namespace.QName QN_CONTENTS
private static final javax.xml.namespace.QName QN_DEFAULT
private static final javax.xml.namespace.QName QN_DIMENSION
private static final javax.xml.namespace.QName QN_FORMAT
private static final javax.xml.namespace.QName QN_LAYER
private static final javax.xml.namespace.QName QN_MATRIX_WIDTH
private static final javax.xml.namespace.QName QN_MATRIX_HEIGHT
private static final javax.xml.namespace.QName QN_RESOURCE_URL
private static final javax.xml.namespace.QName QN_SCALE_DENOMINATOR
private static final javax.xml.namespace.QName QN_STYLE
private static final javax.xml.namespace.QName QN_TILEMATRIX
private static final javax.xml.namespace.QName QN_TILEMATRIXSET
private static final javax.xml.namespace.QName QN_TILEMATRIX_SET_LINK
private static final javax.xml.namespace.QName QN_TILE_WIDTH
private static final javax.xml.namespace.QName QN_TILE_HEIGHT
private static final javax.xml.namespace.QName QN_TOPLEFT_CORNER
private static final javax.xml.namespace.QName QN_VALUE
private static final java.lang.String PATTERN_HEADER
private static final java.lang.String URL_GET_ENCODING_PARAMS
private static final java.lang.String[] ALL_PATTERNS
private int cachedTileSize
private final java.util.Map<java.lang.String,java.lang.String> headers
private final java.util.Collection<WMTSTileSource.Layer> layers
private WMTSTileSource.Layer currentLayer
private WMTSTileSource.TileMatrixSet currentTileMatrixSet
private double crsScale
private final GetCapabilitiesParseHelper.TransferMode transferMode
private NativeScaleLayer.ScaleList nativeScaleList
private final DefaultLayer defaultLayer
private Projection tileProjection
public WMTSTileSource(ImageryInfo info) throws java.io.IOException, WMTSTileSource.WMTSGetCapabilitiesException
info
- imagery infojava.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 infopublic WMTSTileSource(ImageryInfo info, Projection projection) throws java.io.IOException, WMTSTileSource.WMTSGetCapabilitiesException
info
- imagery infoprojection
- projection to be used by this TileSourcejava.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 infopublic DefaultLayer userSelectLayer()
private java.lang.String handleTemplate(java.lang.String url)
public static WMTSCapabilities getCapabilities(java.lang.String url, java.util.Map<java.lang.String,java.lang.String> headers) throws java.io.IOException, WMTSTileSource.WMTSGetCapabilitiesException
url
- of the getCapabilities documentheaders
- HTTP headers to set when calling getCapabilities urljava.io.IOException
- in case of any I/O errorWMTSTileSource.WMTSGetCapabilitiesException
- when document didn't contain any layersjava.lang.IllegalArgumentException
- in case of any other errorprivate static java.util.Collection<WMTSTileSource.Layer> parseContents(javax.xml.stream.XMLStreamReader reader) throws javax.xml.stream.XMLStreamException
reader
- StAX reader instancejavax.xml.stream.XMLStreamException
- See XMLStreamReader
private static WMTSTileSource.Layer parseLayer(javax.xml.stream.XMLStreamReader reader) throws javax.xml.stream.XMLStreamException
reader
- StAX reader instancejavax.xml.stream.XMLStreamException
- See XMLStreamReader
private static WMTSTileSource.Dimension parseDimension(javax.xml.stream.XMLStreamReader reader) throws javax.xml.stream.XMLStreamException
reader
- StAX reader instancejavax.xml.stream.XMLStreamException
- See XMLStreamReader
private static java.lang.String parseTileMatrixSetLink(javax.xml.stream.XMLStreamReader reader) throws javax.xml.stream.XMLStreamException
reader
- StAX reader instancejavax.xml.stream.XMLStreamException
- See XMLStreamReader
private static WMTSTileSource.TileMatrixSet parseTileMatrixSet(javax.xml.stream.XMLStreamReader reader) throws javax.xml.stream.XMLStreamException
reader
- StAX reader instancejavax.xml.stream.XMLStreamException
- See XMLStreamReader
private static WMTSTileSource.TileMatrix parseTileMatrix(javax.xml.stream.XMLStreamReader reader, java.lang.String matrixCrs) throws javax.xml.stream.XMLStreamException
reader
- StAX reader instancematrixCrs
- projection used by this matrixjavax.xml.stream.XMLStreamException
- See XMLStreamReader
private static WMTSCapabilities parseOperationMetadata(javax.xml.stream.XMLStreamReader reader) throws javax.xml.stream.XMLStreamException
reader
- StAX reader instancejavax.xml.stream.XMLStreamException
- See XMLStreamReader
public void initProjection(Projection proj)
proj
- projection to be used by this TileSourcepublic int getTileSize()
TileSource
getTileSize
in interface TileSource
getTileSize
in class AbstractTMSTileSource
public java.lang.String getTileUrl(int zoom, int tilex, int tiley)
TileSource
getTileUrl
in interface TileSource
getTileUrl
in class AbstractTMSTileSource
zoom
- zoom leveltilex
- X coordinatetiley
- Y coordinateprivate WMTSTileSource.TileMatrix getTileMatrix(int zoom)
zoom
- zoom levelpublic double getDistance(double lat1, double lon1, double lat2, double lon2)
TileSource
getDistance
in interface TileSource
lat1
- latitude of first pointlon1
- longitude of first pointlat2
- latitude of second pointlon2
- longitude of second pointpublic ICoordinate tileXYToLatLon(Tile tile)
TileSource
tileXYToLatLon
in interface TileSource
tileXYToLatLon
in class AbstractTMSTileSource
tile
- Tilepublic ICoordinate tileXYToLatLon(TileXY xy, int zoom)
TileSource
tileXYToLatLon
in interface TileSource
tileXYToLatLon
in class AbstractTMSTileSource
xy
- X/Y tile indiceszoom
- zoom levelpublic ICoordinate tileXYToLatLon(int x, int y, int zoom)
TileSource
tileXYToLatLon
in interface TileSource
x
- x tile indexy
- y tile indexzoom
- zoom levelpublic TileXY latLonToTileXY(double lat, double lon, int zoom)
TileSource
latLonToTileXY
in interface TileSource
lat
- latitudelon
- longitudezoom
- zoom levelpublic TileXY latLonToTileXY(ICoordinate point, int zoom)
TileSource
latLonToTileXY
in interface TileSource
latLonToTileXY
in class AbstractTMSTileSource
point
- pointzoom
- zoom levelpublic int getTileXMax(int zoom)
TileSource
getTileXMax
in interface TileSource
getTileXMax
in class AbstractTMSTileSource
zoom
- zoom levelpublic int getTileYMax(int zoom)
TileSource
getTileYMax
in interface TileSource
getTileYMax
in class AbstractTMSTileSource
zoom
- zoom levelpublic java.awt.Point latLonToXY(double lat, double lon, int zoom)
TileSource
latLonToXY
in interface TileSource
lat
- latitudelon
- longitudezoom
- zoom levelpublic java.awt.Point latLonToXY(ICoordinate point, int zoom)
TileSource
latLonToXY
in interface TileSource
latLonToXY
in class AbstractTMSTileSource
point
- pointzoom
- zoom levelpublic Coordinate xyToLatLon(java.awt.Point point, int zoom)
TileSource
xyToLatLon
in interface TileSource
xyToLatLon
in class AbstractTMSTileSource
point
- pointzoom
- zoom levelpublic Coordinate xyToLatLon(int x, int y, int zoom)
TileSource
xyToLatLon
in interface TileSource
x
- X coordinatey
- Y coordinatezoom
- zoom levelpublic java.util.Map<java.lang.String,java.lang.String> getHeaders()
getHeaders
in interface TemplatedTileSource
public int getMaxZoom()
TileSource
TileSource.getMaxZoom()
].getMaxZoom
in interface TileSource
getMaxZoom
in class AbstractTMSTileSource
JMapViewer.MAX_ZOOM
public java.lang.String getTileId(int zoom, int tilex, int tiley)
TileSource
getTileId
in interface TileSource
getTileId
in class AbstractTMSTileSource
zoom
- zoom leveltilex
- X coordinatetiley
- Y coordinatepublic static void checkUrl(java.lang.String url)
url
- URL to checkpublic static java.util.List<java.util.Map.Entry<java.lang.String,java.util.List<WMTSTileSource.Layer>>> groupLayersByNameAndTileMatrixSet(java.util.Collection<WMTSTileSource.Layer> layers)
layers
- to be groupedpublic java.util.Collection<java.lang.String> getSupportedProjections()
private int getTileYMax(int zoom, Projection proj)
private int getTileXMax(int zoom, Projection proj)
public NativeScaleLayer.ScaleList getNativeScales()
NativeScaleLayer.ScaleList
of native scalespublic Projection getTileProjection()
public IProjected tileXYtoProjected(int x, int y, int zoom)
TileSource
tileXYtoProjected
in interface TileSource
x
- x tile indexy
- z tile indexzoom
- zoom levelpublic TileXY projectedToTileXY(IProjected projected, int zoom)
TileSource
projectedToTileXY
in interface TileSource
projected
- projected coordinateszoom
- zoom levelprivate EastNorth tileToEastNorth(int x, int y, int z)
private ProjectionBounds getTileProjectionBounds(Tile tile)
public boolean isInside(Tile inner, Tile outer)
TileSource
isInside
in interface TileSource
inner
- the tile that is suspected to be inside the other tileouter
- the tile that might contain the first tilepublic TileRange getCoveringTileRange(Tile tile, int newZoom)
TileSource
getCoveringTileRange
in interface TileSource
tile
- the tile to covernewZoom
- zoom level of the covering tilesnewZoom
public java.lang.String getServerCRS()
TileSource
getServerCRS
in interface TileSource
public java.util.Collection<WMTSTileSource.Layer> getLayers()