Package com.massifmaps.datasources
Class HTTPTileDataSource
java.lang.Object
com.massifmaps.datasources.TileDataSource
com.massifmaps.datasources.HTTPTileDataSource
A tile data source that loads tiles using a HTTP connection.
The requests are generated using a template scheme, where tags in the baseURL string are replaced with actual values.
The following tags are supported: s, z, zoom, x, y, xflipped, yflipped, quadkey, frame.
For example, if baseURL = "https://tile.openstreetmap.org/{zoom}/{x}/{y}.png" and the requested tile has zoom = 2,
x = 1 and y = 3, then the tile will be loaded from the following URL: "https://tile.openstreetmap.org/2/1/3.png".
This data source also supports PMTiles archives hosted over HTTP. If the URL ends with .pmtiles or starts with
pmtiles://, the data source will automatically use HTTP range requests to fetch tiles from the PMTiles archive.
The requests are generated using a template scheme, where tags in the baseURL string are replaced with actual values.
The following tags are supported: s, z, zoom, x, y, xflipped, yflipped, quadkey, frame.
For example, if baseURL = "https://tile.openstreetmap.org/{zoom}/{x}/{y}.png" and the requested tile has zoom = 2,
x = 1 and y = 3, then the tile will be loaded from the following URL: "https://tile.openstreetmap.org/2/1/3.png".
This data source also supports PMTiles archives hosted over HTTP. If the URL ends with .pmtiles or starts with
pmtiles://, the data source will automatically use HTTP range requests to fetch tiles from the PMTiles archive.
-
Constructor Summary
ConstructorsConstructorDescriptionHTTPTileDataSource(int minZoom, int maxZoom, String baseURL) Constructs a HTTPTileDataSource object. -
Method Summary
Modifier and TypeMethodDescriptionprotected StringbuildTileURL(String baseURL, MapTile tile) Returns the base URL template containing tags.Returns the current set of HTTP headers used.Returns the subdomains for {s} tag.intReturns the current timeout value.booleanReturns true/false based on whether the max-age header check is used.
If this is enabled, SDK will automatically refresh the tiles when tiles have expired.booleanReturns true/false based whether the TMS tiling scheme is used.Loads the specified tile.
Note: the tile coordinate system used here is vertically flipped relative to layer tile coordinate system.voidsetBaseURL(String baseURL) Sets the base URL for the data source.voidsetHTTPHeaders(StringMap headers) Sets HTTP headers for all requests.voidsetMaxAgeHeaderCheck(boolean maxAgeCheck) Enables/disables the max-age header check.
If this is enabled, SDK will automatically refresh the tiles when tiles have expired.voidsetSubdomains(StringVector subdomains) Sets the subdomains for {s} tag.voidsetTimeout(int timeout) Sets the current timeout value.voidsetTMSScheme(boolean tmsScheme) Enables/disables the TMS tiling scheme.Methods inherited from class com.massifmaps.datasources.TileDataSource
buildTagValues, containsMetaDataKey, getContainerMetaData, getDataExtent, getMaxOverzoomLevel, getMaxZoom, getMaxZoomWithOverzoom, getMetaData, getMetaDataElement, getMinZoom, getProjection, isMaxOverzoomLevelSet, notifyTilesChanged, setMaxOverzoomLevel, setMetaData, setMetaDataElement
-
Constructor Details
-
HTTPTileDataSource
Constructs a HTTPTileDataSource object.- Parameters:
minZoom- The minimum zoom level supported by this data source.maxZoom- The maximum zoom level supported by this data source.baseURL- The base URL containing tags (for example, "https://tile.openstreetmap.org/{zoom}/{x}/{y}.png").
-
-
Method Details
-
getBaseURL
Returns the base URL template containing tags.- Returns:
- The base URL template.
-
setBaseURL
Sets the base URL for the data source.- Parameters:
baseURL- The base URL containing tags (for example, "https://tile.openstreetmap.org/{zoom}/{x}/{y}.png").
-
getSubdomains
Returns the subdomains for {s} tag. The default is ["a", "b", "c", "d"].- Returns:
- The list of subdomains.
-
setSubdomains
Sets the subdomains for {s} tag.- Parameters:
subdomains- The list of subdomains to use.
-
isTMSScheme
public boolean isTMSScheme()Returns true/false based whether the TMS tiling scheme is used.- Returns:
- True if TMS tiling scheme is used. False if XYZ scheme is used.
-
setTMSScheme
public void setTMSScheme(boolean tmsScheme) Enables/disables the TMS tiling scheme. In TMS scheme y coordinate of the tile is flipped. The default is disabled.- Parameters:
tmsScheme- True is TMS tiling scheme should be used. False is XYZ should be used.
-
isMaxAgeHeaderCheck
public boolean isMaxAgeHeaderCheck()Returns true/false based on whether the max-age header check is used.
If this is enabled, SDK will automatically refresh the tiles when tiles have expired.- Returns:
- True if max-age header check is used. False otherwise.
-
setMaxAgeHeaderCheck
public void setMaxAgeHeaderCheck(boolean maxAgeCheck) Enables/disables the max-age header check.
If this is enabled, SDK will automatically refresh the tiles when tiles have expired. The default is disabled.- Parameters:
maxAgeCheck- True if the check should be enabled, false otherwise.
-
getTimeout
public int getTimeout()Returns the current timeout value.- Returns:
- The current timeout value in seconds. If negative, then default platform-specific timeout is used.
-
setTimeout
public void setTimeout(int timeout) Sets the current timeout value.- Parameters:
timeout- The new timeout value in seconds. If negative, then default platform-specific timeout is used.
-
getHTTPHeaders
Returns the current set of HTTP headers used. Initially this set is empty and can be changed with setHTTPHeaders.- Returns:
- The current set of custom HTTP headers.
-
setHTTPHeaders
Sets HTTP headers for all requests. Calling this method will invalidate the datasource and
all layers using this data source will be refreshed.- Parameters:
headers- A map of HTTP headers that will be used in subsequent requests.
-
loadTile
Description copied from class:TileDataSourceLoads the specified tile.
Note: the tile coordinate system used here is vertically flipped relative to layer tile coordinate system.- Overrides:
loadTilein classTileDataSource- Parameters:
mapTile- The tile to load.- Returns:
- The tile data. If the tile is not available, null may be returned.
-
buildTileURL
-