Class TileFactoryInfo

java.lang.Object
org.jxmapviewer.viewer.TileFactoryInfo
Direct Known Subclasses:
GoogleMapsTileFactoryInfo, OSMTileFactoryInfo, VirtualEarthTileFactoryInfo, WMSTileFactoryInfo

public class TileFactoryInfo
extends java.lang.Object
A TileFactoryInfo encapsulates all information specific to a map server. This includes everything from the url to load the map tiles from to the size and depth of the tiles. Theoretically any map server can be used by installing a customized TileFactoryInfo. Currently
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected java.lang.String baseURL
    The base url for loading tiles from.
  • Constructor Summary

    Constructors 
    Constructor Description
    TileFactoryInfo​(int minimumZoomLevel, int maximumZoomLevel, int totalMapZoom, int tileSize, boolean xr2l, boolean yt2b, java.lang.String baseURL, java.lang.String xparam, java.lang.String yparam, java.lang.String zparam)
    Creates a new instance of TileFactoryInfo.
    TileFactoryInfo​(java.lang.String name, int minimumZoomLevel, int maximumZoomLevel, int totalMapZoom, int tileSize, boolean xr2l, boolean yt2b, java.lang.String baseURL, java.lang.String xparam, java.lang.String yparam, java.lang.String zparam)
    Creates a new instance of TileFactoryInfo.
  • Method Summary

    Modifier and Type Method Description
    java.lang.String getAttribution()
    Some map providers require explicit attribution, can be null
    java.lang.String getBaseURL()  
    int getDefaultZoomLevel()  
    java.lang.String getLicense()  
    double getLongitudeDegreeWidthInPixels​(int zoom)  
    double getLongitudeRadianWidthInPixels​(int zoom)  
    java.awt.geom.Point2D getMapCenterInPixelsAtZoom​(int zoom)  
    int getMapWidthInTilesAtZoom​(int zoom)  
    int getMaximumZoomLevel()  
    int getMinimumZoomLevel()  
    java.lang.String getName()
    The name of this info.
    int getTileSize​(int zoom)
    Get the tile size.
    java.lang.String getTileUrl​(int x, int y, int zoom)
    Returns the tile url for the specified tile at the specified zoom level.
    int getTotalMapZoom()  
    boolean isXr2l()  
    boolean isYt2b()  
    void setDefaultZoomLevel​(int defaultZoomLevel)  
    void setXr2l​(boolean xr2l)  
    void setYt2b​(boolean yt2b)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • baseURL

      protected java.lang.String baseURL
      The base url for loading tiles from.
  • Constructor Details

    • TileFactoryInfo

      public TileFactoryInfo​(int minimumZoomLevel, int maximumZoomLevel, int totalMapZoom, int tileSize, boolean xr2l, boolean yt2b, java.lang.String baseURL, java.lang.String xparam, java.lang.String yparam, java.lang.String zparam)
      Creates a new instance of TileFactoryInfo. Note that TileFactoryInfo should be considered invariate, meaning that subclasses should ensure all of the properties stay the same after the class is constructed. Returning different values of getTileSize() for example is considered an error and may result in unexpected behavior.
      Parameters:
      minimumZoomLevel - The minimum zoom level
      maximumZoomLevel - the maximum zoom level
      totalMapZoom - the top zoom level, essentially the height of the pyramid
      tileSize - the size of the tiles in pixels (must be square)
      xr2l - if the x goes r to l (is this backwards?)
      yt2b - if the y goes top to bottom
      baseURL - the base url for grabbing tiles
      xparam - the x parameter for the tile url
      yparam - the y parameter for the tile url
      zparam - the z parameter for the tile url
    • TileFactoryInfo

      public TileFactoryInfo​(java.lang.String name, int minimumZoomLevel, int maximumZoomLevel, int totalMapZoom, int tileSize, boolean xr2l, boolean yt2b, java.lang.String baseURL, java.lang.String xparam, java.lang.String yparam, java.lang.String zparam)
      Creates a new instance of TileFactoryInfo. Note that TileFactoryInfo should be considered invariate, meaning that subclasses should ensure all of the properties stay the same after the class is constructed. Returning different values of getTileSize() for example is considered an error and may result in unexpected behavior.
      Parameters:
      name - A name to identify this information.
      minimumZoomLevel - The minimum zoom level, the user is allowed to zoom, means the smallest map
      maximumZoomLevel - the maximum zoom level, the user is allowed to zoom, means the biggest map
      totalMapZoom - how many zoom levels the map provides
      tileSize - the size of the tiles in pixels (must be square)
      xr2l - if the x goes r to l (is this backwards?)
      yt2b - if the y goes top to bottom
      baseURL - the base url for grabbing tiles
      xparam - the x parameter for the tile url
      yparam - the y parameter for the tile url
      zparam - the z parameter for the tile url
  • Method Details

    • getMinimumZoomLevel

      public int getMinimumZoomLevel()
      Returns:
      the minimum zoom level
    • getMaximumZoomLevel

      public int getMaximumZoomLevel()
      Returns:
      the maximum zoom level
    • getTotalMapZoom

      public int getTotalMapZoom()
      Returns:
      the total map zoom level
    • getMapWidthInTilesAtZoom

      public int getMapWidthInTilesAtZoom​(int zoom)
      Parameters:
      zoom - the zoom level
      Returns:
      the map width in tiles
    • getMapCenterInPixelsAtZoom

      public java.awt.geom.Point2D getMapCenterInPixelsAtZoom​(int zoom)
      Parameters:
      zoom - the zoom level
      Returns:
      the map center in pixels
    • getTileUrl

      public java.lang.String getTileUrl​(int x, int y, int zoom)
      Returns the tile url for the specified tile at the specified zoom level. By default it will generate a tile url using the base url and parameters specified in the constructor. Thus if
      baseURl =
       http://www.myserver.com/maps?version=0.1 xparam = x yparam = y zparam = z tilepoint = [1,2] zoom level = 3
        
      then the resulting url would be:
      http://www.myserver.com/maps?version=0.1&x=1&y=2&z=3
      Note that the URL can be a file: url.
      Parameters:
      zoom - the zoom level
      x - the x value, measured from left to right
      y - the y value, measured from top to bottom
      Returns:
      a valid url to load the tile
    • getTileSize

      public int getTileSize​(int zoom)
      Get the tile size.
      Parameters:
      zoom - the zoom level
      Returns:
      the tile size
    • getLongitudeDegreeWidthInPixels

      public double getLongitudeDegreeWidthInPixels​(int zoom)
      Parameters:
      zoom - the zoom level
      Returns:
      the longitude degree width in pixels
    • getLongitudeRadianWidthInPixels

      public double getLongitudeRadianWidthInPixels​(int zoom)
      Parameters:
      zoom - the zoom level
      Returns:
      the longitude radian width in pixels
    • isXr2l

      public boolean isXr2l()
      Returns:
      indicates if the X coordinates of tiles go from right to left or left to right.
    • setXr2l

      public void setXr2l​(boolean xr2l)
      Parameters:
      xr2l - indicates if the X coordinates of tiles go from right to left or left to right.
    • isYt2b

      public boolean isYt2b()
      Returns:
      true if the Y coordinates of tiles go from top to bottom
    • setYt2b

      public void setYt2b​(boolean yt2b)
      Parameters:
      yt2b - should be true if the Y coordinates of tiles go from top to bottom
    • getDefaultZoomLevel

      public int getDefaultZoomLevel()
      Returns:
      the default zoom level
    • setDefaultZoomLevel

      public void setDefaultZoomLevel​(int defaultZoomLevel)
      Parameters:
      defaultZoomLevel - the default zoom level
    • getName

      public java.lang.String getName()
      The name of this info.
      Returns:
      Returns the name of this info class for debugging or GUI widgets.
    • getBaseURL

      public java.lang.String getBaseURL()
      Returns:
      the base URL
    • getAttribution

      public java.lang.String getAttribution()
      Some map providers require explicit attribution, can be null
      Returns:
      the attribution text
    • getLicense

      public java.lang.String getLicense()
      Returns:
      the license of the map provider, can be null