Package org.geotools.tile
Class TileService
Object
TileService
- All Implemented Interfaces:
ImageLoader
- Direct Known Subclasses:
WebMercatorTileService,WMTSTileService
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
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedTileService(String name) Creates a TileServiceprotectedTileService(String name, String baseURL) Create a new TileService with a name and a base URL.protectedTileService(String name, String baseURL, HTTPClient client) Create a new TileService with a name and a base URL -
Method Summary
Modifier and TypeMethodDescriptionstatic final ReferencedEnvelopecreateSafeEnvelopeInWGS84(ReferencedEnvelope _mapExtent) findTilesInExtent(ReferencedEnvelope _mapExtent, double scaleFactor, boolean recommendedZoomLevel, int maxNumberOfTiles) Returns the prefix of an tile-url, e.g.: http://tile.openstreetmap.org/abstract ReferencedEnvelopeReturns the bounds for the complete TileServicefinal HTTPClientReturns the http client to use for fetching images.intReturns the highest zoom-level number from the scaleList.intReturns the lowest zoom-level number from the scaleList.getName()abstract CoordinateReferenceSystemThe projection the tiles are drawn in.abstract double[]Returns a list that represents a mapping between zoom-levels and map scale.The CRS that is used when the extent is cut in tiles.abstract TileFactoryReturns the TileFactory which is used to call the method getTileFromCoordinate().intintintgetZoomLevelFromMapScale(ScaleZoomLevelMatcher zoomLevelMatcher, double scaleFactor) Translates the map scale into a zoom-level for the map services.intgetZoomLevelToUse(ScaleZoomLevelMatcher zoomLevelMatcher, double scaleFactor, boolean useRecommended) Returns the zoom-level that should be used to fetch the tiles.abstract TileIdentifieridentifyTileAtCoordinate(double lon, double lat, ZoomLevel zoomLevel) Returns tile identifier for the tile at the given coordinateloadImageTileImage(Tile tile) Fetches the image from url given by tile.obtainTile(TileIdentifier identifier) Check cache for given identifier.toString()
-
Field Details
-
LOGGER
-
cacheSize
protected static int cacheSize
-
-
Constructor Details
-
TileService
Creates a TileServiceClient isn't set so you should override loadImageTileImage.
- Parameters:
name- the name. Cannot be null.
-
TileService
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
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 Details
-
getName
-
getTileWidth
public int getTileWidth() -
getTileHeight
public int getTileHeight() -
getBaseUrl
Returns the prefix of an tile-url, e.g.: http://tile.openstreetmap.org/ -
getTileCrs
The CRS that is used when the extent is cut in tiles. -
getZoomLevelFromMapScale
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
Fetches the image from url given by tile.- Specified by:
loadImageTileImagein interfaceImageLoader- Returns:
- an image
- Throws:
IOException
-
obtainTile
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
Returns the bounds for the complete TileService -
getProjectedTileCrs
The projection the tiles are drawn in. -
getTileFactory
Returns the TileFactory which is used to call the method getTileFromCoordinate(). -
createSafeEnvelopeInWGS84
-
toString
-
getHttpClient
Returns the http client to use for fetching images.- Throws:
IllegalStateException- If the service is constructed without a client.
-