Package org.geotools.tile
Class TileService
- Object
-
- TileService
-
- All Implemented Interfaces:
ImageLoader
- Direct Known Subclasses:
WebMercatorTileService
,WMTSTileService
public abstract class TileService extends Object implements ImageLoader
A TileService represent the class of objects that serve map tiles.TileServices must at least have a name and a base URL.
- Since:
- 12
- Author:
- to.srwn, Ugo Taddei
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
TileService(String name)
Creates a TileServiceprotected
TileService(String name, String baseURL)
Create a new TileService with a name and a base URL.protected
TileService(String name, String baseURL, HTTPClient client)
Create a new TileService with a name and a base URL
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static ReferencedEnvelope
createSafeEnvelopeInWGS84(ReferencedEnvelope _mapExtent)
Set<Tile>
findTilesInExtent(ReferencedEnvelope _mapExtent, double scaleFactor, boolean recommendedZoomLevel, int maxNumberOfTiles)
String
getBaseUrl()
Returns the prefix of an tile-url, e.g.: http://tile.openstreetmap.org/abstract ReferencedEnvelope
getBounds()
Returns the bounds for the complete TileServiceHTTPClient
getHttpClient()
Returns the http client to use for fetching images.int
getMaxZoomLevel()
Returns the highest zoom-level number from the scaleList.int
getMinZoomLevel()
Returns the lowest zoom-level number from the scaleList.String
getName()
abstract CoordinateReferenceSystem
getProjectedTileCrs()
The projection the tiles are drawn in.abstract double[]
getScaleList()
Returns a list that represents a mapping between zoom-levels and map scale.CoordinateReferenceSystem
getTileCrs()
The CRS that is used when the extent is cut in tiles.abstract TileFactory
getTileFactory()
Returns the TileFactory which is used to call the method getTileFromCoordinate().int
getTileHeight()
int
getTileWidth()
int
getZoomLevelFromMapScale(ScaleZoomLevelMatcher zoomLevelMatcher, double scaleFactor)
Translates the map scale into a zoom-level for the map services.int
getZoomLevelToUse(ScaleZoomLevelMatcher zoomLevelMatcher, double scaleFactor, boolean useRecommended)
Returns the zoom-level that should be used to fetch the tiles.abstract TileIdentifier
identifyTileAtCoordinate(double lon, double lat, ZoomLevel zoomLevel)
Returns tile identifier for the tile at the given coordinateBufferedImage
loadImageTileImage(Tile tile)
Fetches the image from url given by tile.Tile
obtainTile(TileIdentifier identifier)
Check cache for given identifier.String
toString()
-
-
-
Field Detail
-
LOGGER
protected static final Logger LOGGER
-
cacheSize
protected static int cacheSize
-
-
Constructor Detail
-
TileService
protected TileService(String name)
Creates a TileServiceClient isn't set so you should override loadImageTileImage.
- Parameters:
name
- the name. Cannot be null.
-
TileService
protected TileService(String name, String baseURL)
Create a new TileService with a name and a base URL.Client isn't set so you should override loadImageTileImage.
- Parameters:
name
- the name. Cannot be null.baseURL
- the base URL. This is a string representing the common part of the URL for all this service's tiles. Cannot be null. Note that this constructor doesn't ensure that the URL is well-formed.
-
TileService
protected TileService(String name, String baseURL, HTTPClient client)
Create a new TileService with a name and a base URL- Parameters:
name
- the name. Cannot be null.baseURL
- the base URL. This is a string representing the common part of the URL for all this service's tiles. Cannot be null. Note that this constructor doesn't ensure that the URL is well-formed.client
- HTTPClient instance to use for a tile request.
-
-
Method Detail
-
getName
public String getName()
-
getTileWidth
public int getTileWidth()
-
getTileHeight
public int getTileHeight()
-
getBaseUrl
public String getBaseUrl()
Returns the prefix of an tile-url, e.g.: http://tile.openstreetmap.org/
-
getTileCrs
public CoordinateReferenceSystem getTileCrs()
The CRS that is used when the extent is cut in tiles.
-
getZoomLevelFromMapScale
public int getZoomLevelFromMapScale(ScaleZoomLevelMatcher zoomLevelMatcher, double scaleFactor)
Translates the map scale into a zoom-level for the map services.The scale-factor (0-100) decides whether the tiles will be scaled down (100) or scaled up (0).
- Parameters:
scaleFactor
- Scale-factor (0-100)- Returns:
- Zoom-level
-
getZoomLevelToUse
public int getZoomLevelToUse(ScaleZoomLevelMatcher zoomLevelMatcher, double scaleFactor, boolean useRecommended)
Returns the zoom-level that should be used to fetch the tiles.- Parameters:
useRecommended
- always use the calculated zoom-level, do not use the one the user selected
-
getMinZoomLevel
public int getMinZoomLevel()
Returns the lowest zoom-level number from the scaleList.
-
getMaxZoomLevel
public int getMaxZoomLevel()
Returns the highest zoom-level number from the scaleList.
-
findTilesInExtent
public Set<Tile> findTilesInExtent(ReferencedEnvelope _mapExtent, double scaleFactor, boolean recommendedZoomLevel, int maxNumberOfTiles)
-
identifyTileAtCoordinate
public abstract TileIdentifier identifyTileAtCoordinate(double lon, double lat, ZoomLevel zoomLevel)
Returns tile identifier for the tile at the given coordinate
-
loadImageTileImage
public BufferedImage loadImageTileImage(Tile tile) throws IOException
Fetches the image from url given by tile.- Specified by:
loadImageTileImage
in interfaceImageLoader
- Returns:
- an image
- Throws:
IOException
-
obtainTile
public Tile obtainTile(TileIdentifier identifier)
Check cache for given identifier. Call TileFactory to create new if not present.
-
getScaleList
public abstract double[] getScaleList()
Returns a list that represents a mapping between zoom-levels and map scale.Array index: zoom-level Value at index: map scale High zoom-level -> more detailed map Low zoom-level -> less detailed map
- Returns:
- mapping between zoom-levels and map scale
-
getBounds
public abstract ReferencedEnvelope getBounds()
Returns the bounds for the complete TileService
-
getProjectedTileCrs
public abstract CoordinateReferenceSystem getProjectedTileCrs()
The projection the tiles are drawn in.
-
getTileFactory
public abstract TileFactory getTileFactory()
Returns the TileFactory which is used to call the method getTileFromCoordinate().
-
createSafeEnvelopeInWGS84
public static final ReferencedEnvelope createSafeEnvelopeInWGS84(ReferencedEnvelope _mapExtent)
-
getHttpClient
public final HTTPClient getHttpClient()
Returns the http client to use for fetching images.- Throws:
IllegalStateException
- If the service is constructed without a client.
-
-