Package nl.bebr.mapviewer.data
Class TileFactoryInfo
- java.lang.Object
-
- nl.bebr.mapviewer.data.TileFactoryInfo
-
- Direct Known Subclasses:
OSMTileFactoryInfo,SLMapServerInfo,VirtualEarthTileFactoryInfo
public class TileFactoryInfo extends 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.- Author:
- joshy
-
-
Field Summary
Fields Modifier and Type Field Description protected StringbaseURLThe base url for loading tiles from.static StringFILE_NAME_FORMATstatic StringTILE_EXTENSION
-
Constructor Summary
Constructors Constructor Description TileFactoryInfo(int minimumZoomLevel, int maximumZoomLevel, int totalMapZoom, int tileSize, boolean xr2l, boolean yt2b, String baseURL, String xparam, String yparam, String zparam)Creates a new instance of TileFactoryInfo.TileFactoryInfo(String name, int minimumZoomLevel, int maximumZoomLevel, int totalMapZoom, int tileSize, boolean xr2l, boolean yt2b, String baseURL, String xparam, String yparam, String zparam)Creates a new instance of TileFactoryInfo.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)TileCacheInfogetCacheInfo(URI uri)TranslatesURItointgetDefaultZoomLevel()URLgetIconUrl()doublegetLongitudeDegreeWidthInPixels(int zoom)doublegetLongitudeRadianWidthInPixels(int zoom)Point2DgetMapCenterInPixelsAtZoom(int zoom)intgetMapWidthInTilesAtZoom(int zoom)intgetMaximumZoomLevel()intgetMinimumZoomLevel()StringgetName()The name of this info.intgetTileSize(int zoom)Get the tile size.StringgetTileUrl(int x, int y, int zoom)Returns the tile url for the specified tile at the specified zoom level.intgetTotalMapZoom()inthashCode()booleanisPersistent()booleanisXr2l()A property indicating if the X coordinates of tiles go from right to left or left to right.booleanisYt2b()A property indicating if the Y coordinates of tiles go from right to left or left to right.protected intrecalculateZoom(int zoom)voidsetDefaultZoomLevel(int defaultZoomLevel)voidsetIconUrl(URL iconUrl)voidsetPersistent(boolean persistent)voidsetXr2l(boolean xr2l)A property indicating if the X coordinates of tiles go from right to left or left to right.voidsetYt2b(boolean yt2b)A property indicating if the Y coordinates of tiles go from right to left or left to right.
-
-
-
Field Detail
-
TILE_EXTENSION
public static final String TILE_EXTENSION
- See Also:
- Constant Field Values
-
FILE_NAME_FORMAT
public static final String FILE_NAME_FORMAT
- See Also:
- Constant Field Values
-
baseURL
protected String baseURL
The base url for loading tiles from.
-
-
Constructor Detail
-
TileFactoryInfo
public TileFactoryInfo(int minimumZoomLevel, int maximumZoomLevel, int totalMapZoom, int tileSize, boolean xr2l, boolean yt2b, String baseURL, String xparam, String yparam, 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(String name, int minimumZoomLevel, int maximumZoomLevel, int totalMapZoom, int tileSize, boolean xr2l, boolean yt2b, String baseURL, String xparam, String yparam, 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 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
-
-
Method Detail
-
getMinimumZoomLevel
public int getMinimumZoomLevel()
- Returns:
-
getMaximumZoomLevel
public int getMaximumZoomLevel()
- Returns:
-
getTotalMapZoom
public int getTotalMapZoom()
- Returns:
-
getMapWidthInTilesAtZoom
public int getMapWidthInTilesAtZoom(int zoom)
- Parameters:
zoom-- Returns:
-
getMapCenterInPixelsAtZoom
public Point2D getMapCenterInPixelsAtZoom(int zoom)
- Parameters:
zoom-- Returns:
-
getTileUrl
public 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 leveltilePoint- the tile point- Returns:
- a valid url to load the tile
-
getTileSize
public int getTileSize(int zoom)
Get the tile size.- Returns:
- the tile size
-
getLongitudeDegreeWidthInPixels
public double getLongitudeDegreeWidthInPixels(int zoom)
- Parameters:
zoom-- Returns:
-
getLongitudeRadianWidthInPixels
public double getLongitudeRadianWidthInPixels(int zoom)
- Parameters:
zoom-- Returns:
-
isXr2l
public boolean isXr2l()
A property indicating if the X coordinates of tiles go from right to left or left to right.- Returns:
-
setXr2l
public void setXr2l(boolean xr2l)
A property indicating if the X coordinates of tiles go from right to left or left to right.- Parameters:
xr2l-
-
isYt2b
public boolean isYt2b()
A property indicating if the Y coordinates of tiles go from right to left or left to right.- Returns:
-
setYt2b
public void setYt2b(boolean yt2b)
A property indicating if the Y coordinates of tiles go from right to left or left to right.- Parameters:
yt2b-
-
getDefaultZoomLevel
public int getDefaultZoomLevel()
-
setDefaultZoomLevel
public void setDefaultZoomLevel(int defaultZoomLevel)
-
getName
public String getName()
The name of this info.- Returns:
- Returns the name of this info class for debugging or GUI widgets.
-
getCacheInfo
public TileCacheInfo getCacheInfo(URI uri)
TranslatesURIto- Parameters:
uri-- Returns:
-
setIconUrl
public void setIconUrl(URL iconUrl)
-
getIconUrl
public URL getIconUrl()
-
recalculateZoom
protected int recalculateZoom(int zoom)
-
setPersistent
public void setPersistent(boolean persistent)
-
isPersistent
public boolean isPersistent()
-
-