Class 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
    • Field Detail

      • LOGGER

        protected static final Logger LOGGER
      • cacheSize

        protected static int cacheSize
    • Constructor Detail

      • TileService

        protected TileService​(String name)
        Creates a TileService

        Client 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/
      • 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
      • 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().
      • getHttpClient

        public final HTTPClient getHttpClient()
        Returns the http client to use for fetching images.
        Throws:
        IllegalStateException - If the service is constructed without a client.