Package org.jxmapviewer.viewer
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.StringbaseURLThe 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.StringgetAttribution()Some map providers require explicit attribution, can benulljava.lang.StringgetBaseURL()intgetDefaultZoomLevel()java.lang.StringgetLicense()doublegetLongitudeDegreeWidthInPixels(int zoom)doublegetLongitudeRadianWidthInPixels(int zoom)java.awt.geom.Point2DgetMapCenterInPixelsAtZoom(int zoom)intgetMapWidthInTilesAtZoom(int zoom)intgetMaximumZoomLevel()intgetMinimumZoomLevel()java.lang.StringgetName()The name of this info.intgetTileSize(int zoom)Get the tile size.java.lang.StringgetTileUrl(int x, int y, int zoom)Returns the tile url for the specified tile at the specified zoom level.intgetTotalMapZoom()booleanisXr2l()booleanisYt2b()voidsetDefaultZoomLevel(int defaultZoomLevel)voidsetXr2l(boolean xr2l)voidsetYt2b(boolean yt2b)
-
Field Details
-
baseURL
protected java.lang.String baseURLThe 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 levelmaximumZoomLevel- the maximum zoom leveltotalMapZoom- the top zoom level, essentially the height of the pyramidtileSize- 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 bottombaseURL- the base url for grabbing tilesxparam- the x parameter for the tile urlyparam- the y parameter for the tile urlzparam- 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 mapmaximumZoomLevel- the maximum zoom level, the user is allowed to zoom, means the biggest maptotalMapZoom- how many zoom levels the map providestileSize- 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 bottombaseURL- the base url for grabbing tilesxparam- the x parameter for the tile urlyparam- the y parameter for the tile urlzparam- 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
then the resulting url would be:baseURl = http://www.myserver.com/maps?version=0.1 xparam = x yparam = y zparam = z tilepoint = [1,2] zoom level = 3
Note that the URL can be ahttp://www.myserver.com/maps?version=0.1&x=1&y=2&z=3file:url.- Parameters:
zoom- the zoom levelx- the x value, measured from left to righty- 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 benull- Returns:
- the attribution text
-
getLicense
public java.lang.String getLicense()- Returns:
- the license of the map provider, can be
null
-