|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.bbn.openmap.util.cacheHandler.CacheHandler com.bbn.openmap.dataAccess.mapTile.StandardMapTileFactory
public class StandardMapTileFactory
The StandardImageTileFactory is a TileFactory implementation that retrieves image tiles from local storage. These tiles are assumed to be stored in the local file system, at some root directory, and then in some hierarchy like zoom-level/x coord/y coord.file-extension. This class can be extended to allow different tile naming/storing conventions to be used.
This component can be configured using properties:
rootDir=the path to the parent directory of the tiles. The factory will construct specific file paths that are appended to this value. fileExt=the file extension to append to the tile names cacheSize=the number of mapTiles the factory should hold on to. The default is 100. # default is OSMMapTileCoordinateTransform, but it depends on the source of tiles. GDAL is TSMMapTileCoordinateTransform mapTileTransform=com.bbn.openmap.dataAccess.mapTile.OSMMapTileCoordinateTransform, or com.bbn.openmap.dataAccess.mapTile.TSMMapTileCoordinateTransform # what to do about missing tiles? emptyTileHandler=com.bbn.openmap.dataAccess.mapTile.SimpleEmptyTileHandler # Set a tile image preparer, if you want to change how images are rendered (greyscale, for instance) tileImagePreparer=com.bbn.openmap.dataAccess.mapTile.StandardImagePreparer # or tileImagePreparer=com.bbn.openmap.dataAccess.mapTile.GreyscaleImagePreparer
Nested Class Summary | |
---|---|
static class |
StandardMapTileFactory.TilePathBuilder
|
Field Summary | |
---|---|
static java.lang.String |
CACHE_SIZE_PROPERTY
|
static java.lang.String |
EMPTY_TILE_HANDLER_PROPERTY
|
protected EmptyTileHandler |
emptyTileHandler
|
static java.lang.String |
FILE_EXT_PROPERTY
|
protected java.lang.String |
fileExt
|
protected Projection |
lastProj
|
protected static java.util.logging.Logger |
logger
|
protected static java.util.logging.Logger |
mapTileLogger
|
protected MapTileRequester |
mapTileRequester
If set, the MapTileRequester will be notified when the list provided in getTiles() has been updated, and asked if it should continue with the getTiles() request at opportune times, when tile fetching is stable. |
protected MapTileCoordinateTransform |
mtcTransform
Coordinate transform for the uv coordinates of the tiles. |
static java.lang.String |
MTCTRANSFORM_PROPERTY
|
protected java.lang.String |
prefix
|
static java.lang.String |
ROOT_DIR_PATH_PROPERTY
Inserted into properties loaded via tiles.omp, so that the EmptyTileHandler can know where the tile set is located, in case it needs to know the absolute path. |
static java.lang.String |
ROOT_DIR_PROPERTY
|
protected java.lang.String |
rootDir
|
protected java.lang.String |
rootDirProperty
|
static java.lang.String |
TILE_IMAGE_PREPARER_PROPERTY
|
static java.lang.String |
TILE_PROPERTIES
The name of the properties file that the factory looks for in the root directory of the data (tiles.omp). |
protected TileImagePreparer |
tileImagePreparer
|
protected boolean |
verbose
|
static java.lang.String |
ZOOM_LEVEL_INFO_PROPERTY
|
static java.lang.String |
ZOOM_LEVEL_TILE_SIZE_PROPERTY
|
protected ZoomLevelInfo |
zoomLevelInfo
|
protected int |
zoomLevelTileSize
The zoom level tile size is used by the factory to determine when it needs to get tiles for a different zoom level. |
Fields inherited from class com.bbn.openmap.util.cacheHandler.CacheHandler |
---|
DEFAULT_MAX_CACHE_SIZE, logicalClock, objs |
Fields inherited from interface com.bbn.openmap.PropertyConsumer |
---|
EditorProperty, initPropertiesProperty, LabelEditorProperty, ScopedEditorProperty |
Constructor Summary | |
---|---|
StandardMapTileFactory()
|
|
StandardMapTileFactory(MapTileRequester layer,
java.lang.String rootDir,
java.lang.String tileFileExt)
|
Method Summary | |
---|---|
protected java.lang.String |
buildCacheKey(int x,
int y,
int z,
java.lang.String fileExt)
Creates a unique cache key for this tile based on zoom, x, y. |
java.lang.String |
buildFilePath(int x,
int y,
int z,
java.lang.String fileExt)
Build an image path to load, based on specified tile coordinates, zoom level and file extension settings. |
protected void |
configureFromProperties(java.io.InputStream is,
java.lang.String rootDirectory)
Called with an input stream for a properties file, used for reading tiles.omp files. |
protected OMGraphic |
createOMGraphicFromBufferedImage(java.awt.image.BufferedImage bi,
int x,
int y,
int zoomLevel,
Projection proj)
Creates an OMRaster appropriate for projection and other parameters from a buffered image. |
java.lang.Object |
get(java.lang.Object key,
int x,
int y,
int zoomLevel,
Projection proj)
The main call to retrieve something from the cache, modified to allow load method to do some projection calculations to initialize tile parameters. |
CacheObject |
getEmptyTile(java.lang.Object key,
int x,
int y,
int zoomLevel,
Projection proj)
Call to make when you want the tile factory to create some empty tile representation for the given location. |
EmptyTileHandler |
getEmptyTileHandler()
Get object that handles empty tiles. |
java.lang.String |
getFileExt()
|
java.lang.Object |
getFromCache(java.lang.Object key,
int x,
int y,
int zoomLevel)
An auxiliary call to retrieve something from the cache, modified to allow load method to do some projection calculations to initialize tile parameters. |
java.lang.String |
getInitPropertiesOrder()
|
MapTileRequester |
getMapTileRequester()
|
MapTileCoordinateTransform |
getMtcTransform()
|
java.util.Properties |
getProperties(java.util.Properties getList)
Method to fill in a Properties object, reflecting the current values of the PropertyConsumer. |
java.util.Properties |
getPropertyInfo(java.util.Properties list)
Method to fill in a Properties object with values reflecting the properties able to be set on this PropertyConsumer. |
java.lang.String |
getPropertyPrefix()
Get the property key prefix that is being used to prepend to the property keys for Properties lookups. |
java.lang.String |
getRootDir()
|
TileImagePreparer |
getTileImagePreparer()
|
protected OMGraphic |
getTileMatchingProjectionType(java.awt.image.BufferedImage image,
int x,
int y,
int zoomLevel)
Create an OMScalingRaster that matches the basic projection of the current map. |
protected OMGraphic |
getTileNotMatchingProjectionType(java.awt.image.BufferedImage image,
int x,
int y,
int zoomLevel)
Create an OMWarpingImage that knows how to re-project itself for different projections. |
protected StandardMapTileFactory.TilePathBuilder |
getTilePathBuilder()
|
protected void |
getTiles(int uvleft,
int uvright,
int uvup,
int uvbottom,
ZoomLevelInfo zoomLevelInfo,
Projection proj,
OMGraphicList list)
|
OMGraphicList |
getTiles(Projection proj)
Returns projected tiles for the given projection. |
OMGraphicList |
getTiles(Projection proj,
int zoomLevel)
Returns projected tiles for given projection at specified zoom level. |
OMGraphicList |
getTiles(Projection proj,
int zoomLevel,
OMGraphicList list)
Returns projected tiles for given projection at specified zoom level. |
ZoomLevelInfo |
getZoomLevelInfo()
Get the ZoomLevelInfo set on the factory. |
CacheObject |
load(java.lang.Object key)
Called from get if the key doesn't exist, to "load" the new object into the cache before returning it. |
CacheObject |
load(java.lang.Object key,
int x,
int y,
int zoomLevel,
Projection proj)
Called to load cache object from data source, when not found in cache. |
protected java.awt.image.BufferedImage |
preprocessImage(java.awt.Image origImage,
int imageWidth,
int imageHeight)
Method that allows subclasses to modify the image as necessary before it is passed into an OMGraphic. |
void |
reset()
Tell the factory to dump the cache. |
void |
setEmptyTileHandler(EmptyTileHandler emptyTileHandler)
|
void |
setFileExt(java.lang.String fileExt)
|
void |
setMapTileRequester(MapTileRequester mtRequestor)
Set a MapTileRequestor in the tile factory that should be told to repaint when new tiles become available, and to check with during the tile fetch whether to keep going or not. |
void |
setMtcTransform(MapTileCoordinateTransform mtcTransform)
Set the map tile coordinate transformed used to figure out lat/lon to tile coordinates. |
void |
setProperties(java.util.Properties setList)
Method to set the properties in the PropertyConsumer. |
void |
setProperties(java.lang.String prefix,
java.util.Properties setList)
Method to set the properties in the PropertyConsumer. |
void |
setPropertyPrefix(java.lang.String prefix)
Set the property key prefix that should be used by the PropertyConsumer. |
void |
setRootDir(java.lang.String rootDirectory)
|
void |
setTileImagePreparer(TileImagePreparer tileImagePreparer)
|
protected void |
setTilePathBuilder(StandardMapTileFactory.TilePathBuilder tpb)
|
void |
setZoomLevelInfo(ZoomLevelInfo zoomLevelInfo)
Get the ZoomLevelInfo set on the factory. |
Methods inherited from class com.bbn.openmap.util.cacheHandler.CacheHandler |
---|
clear, get, getCacheSize, listIterator, replaceLeastUsed, resetCache, resetCache, searchCache |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.lang.String prefix
protected static final java.util.logging.Logger logger
protected static final java.util.logging.Logger mapTileLogger
public static final java.lang.String ROOT_DIR_PROPERTY
public static final java.lang.String FILE_EXT_PROPERTY
public static final java.lang.String CACHE_SIZE_PROPERTY
public static final java.lang.String MTCTRANSFORM_PROPERTY
public static final java.lang.String EMPTY_TILE_HANDLER_PROPERTY
public static final java.lang.String ZOOM_LEVEL_INFO_PROPERTY
public static final java.lang.String ZOOM_LEVEL_TILE_SIZE_PROPERTY
public static final java.lang.String TILE_IMAGE_PREPARER_PROPERTY
public static final java.lang.String ROOT_DIR_PATH_PROPERTY
public static final java.lang.String TILE_PROPERTIES
protected ZoomLevelInfo zoomLevelInfo
protected java.lang.String rootDir
protected java.lang.String fileExt
protected java.lang.String rootDirProperty
protected EmptyTileHandler emptyTileHandler
protected boolean verbose
protected int zoomLevelTileSize
protected TileImagePreparer tileImagePreparer
protected MapTileRequester mapTileRequester
protected MapTileCoordinateTransform mtcTransform
protected Projection lastProj
Constructor Detail |
---|
public StandardMapTileFactory()
public StandardMapTileFactory(MapTileRequester layer, java.lang.String rootDir, java.lang.String tileFileExt)
Method Detail |
---|
public CacheObject load(java.lang.Object key)
CacheHandler
load
in class CacheHandler
public void reset()
reset
in interface MapTileFactory
public CacheObject load(java.lang.Object key, int x, int y, int zoomLevel, Projection proj)
key
- cache keyx
- uv x coordinatey
- uv y coordinatezoomLevel
- zoom level for tile to loadproj
- passed solely to enable checking if the projection of the
tiles matches the rendered projection.
protected OMGraphic createOMGraphicFromBufferedImage(java.awt.image.BufferedImage bi, int x, int y, int zoomLevel, Projection proj) throws java.lang.InterruptedException
bi
- BufferedImage to use for tile.x
- x uv coordinate for tile.y
- y uv coordinate for tile.zoomLevel
- zoom level for tile.proj
- the current map projection
java.lang.InterruptedException
protected OMGraphic getTileMatchingProjectionType(java.awt.image.BufferedImage image, int x, int y, int zoomLevel)
image
- BufferedImage created from tile filex
- uv x coordinatey
- uv y coordinatezoomLevel
- zoom level for tile retrieval
protected OMGraphic getTileNotMatchingProjectionType(java.awt.image.BufferedImage image, int x, int y, int zoomLevel)
image
- x
- y
- zoomLevel
-
protected java.awt.image.BufferedImage preprocessImage(java.awt.Image origImage, int imageWidth, int imageHeight) throws java.lang.InterruptedException
origImage
- Any java ImageimageWidth
- pixel widthimageHeight
- pixel height
java.lang.InterruptedException
public java.lang.Object get(java.lang.Object key, int x, int y, int zoomLevel, Projection proj)
key
- cache key, usually string of location of a tilex
- uv x location of tiley
- uv y location of tilezoomLevel
- zoom level of tileproj
- passed solely to enable checking if the projection of the
tiles matches the rendered projection.
public java.lang.Object getFromCache(java.lang.Object key, int x, int y, int zoomLevel)
key
- cache key, usually string of location of a tilex
- uv x location of tiley
- uv y location of tilezoomLevel
- zoom level of tile
public CacheObject getEmptyTile(java.lang.Object key, int x, int y, int zoomLevel, Projection proj)
key
- the cache key for this objectx
- the uv x coordinate of the tiley
- the uv y coordinate of the tilezoomLevel
- the zoom level for the tileproj
- the projection being used for the map.
public OMGraphicList getTiles(Projection proj)
getTiles
in interface MapTileFactory
proj
- the projection to fetch tiles for.
public OMGraphicList getTiles(Projection proj, int zoomLevel)
getTiles
in interface MapTileFactory
proj
- projection for queryzoomLevel
- zoom level 1-20 for tiles to be returned, -1 for code to
figure out appropriate zoom level.
public OMGraphicList getTiles(Projection proj, int zoomLevel, OMGraphicList list)
getTiles
in interface MapTileFactory
proj
- projection for queryzoomLevel
- zoom level 1-20 for tiles to be returned, -1 for code to
figure out appropriate zoom level.list
- OMGraphicList that is returned, that will also have tiles
added to it.
protected void getTiles(int uvleft, int uvright, int uvup, int uvbottom, ZoomLevelInfo zoomLevelInfo, Projection proj, OMGraphicList list)
public java.lang.String buildFilePath(int x, int y, int z, java.lang.String fileExt)
x
- the x tile coordinatey
- the y tile coordinatez
- the zoom levelfileExt
- the file extension to use for the path.protected void setTilePathBuilder(StandardMapTileFactory.TilePathBuilder tpb)
protected StandardMapTileFactory.TilePathBuilder getTilePathBuilder()
protected java.lang.String buildCacheKey(int x, int y, int z, java.lang.String fileExt)
x
- tile coord.y
- tile coord.z
- zoomLevel.fileExt
- file extension.
public MapTileRequester getMapTileRequester()
public void setMapTileRequester(MapTileRequester mtRequestor)
MapTileFactory
setMapTileRequester
in interface MapTileFactory
mtRequestor
- callback MapTileRequestor to ask status questions.public java.util.Properties getProperties(java.util.Properties getList)
PropertyConsumer
getProperties
in interface PropertyConsumer
getList
- a Properties object to load the PropertyConsumer
properties into. If getList equals null, then a new
Properties object should be created.
public java.util.Properties getPropertyInfo(java.util.Properties list)
PropertyConsumer
getPropertyInfo
in interface PropertyConsumer
list
- a Properties object to load the PropertyConsumer
properties into. If getList equals null, then a new
Properties object should be created.
public java.lang.String getInitPropertiesOrder()
public java.lang.String getPropertyPrefix()
PropertyConsumer
getPropertyPrefix
in interface PropertyConsumer
public void setProperties(java.util.Properties setList)
PropertyConsumer
setProperties
in interface PropertyConsumer
setList
- a properties object that the PropertyConsumer
can use to retrieve expected properties it can use for
configuration.public void setProperties(java.lang.String prefix, java.util.Properties setList)
PropertyConsumer
setProperties
in interface PropertyConsumer
prefix
- a String used by the PropertyConsumer to prepend
to each property value it wants to look up -
setList.getProperty(prefix.propertyKey). If the prefix
had already been set, then the prefix passed in should
replace that previous value.setList
- a Properties object that the PropertyConsumer
can use to retrieve expected properties it can use for
configuration.public void setPropertyPrefix(java.lang.String prefix)
PropertyConsumer
setPropertyPrefix
in interface PropertyConsumer
prefix
- the prefix String.public java.lang.String getRootDir()
public void setRootDir(java.lang.String rootDirectory)
public TileImagePreparer getTileImagePreparer()
public void setTileImagePreparer(TileImagePreparer tileImagePreparer)
protected void configureFromProperties(java.io.InputStream is, java.lang.String rootDirectory) throws java.io.IOException
is
- input stream for tiles.omp file.rootDirectory
- original path to what was specified as root
directory
java.io.IOException
public java.lang.String getFileExt()
public void setFileExt(java.lang.String fileExt)
public ZoomLevelInfo getZoomLevelInfo()
public void setZoomLevelInfo(ZoomLevelInfo zoomLevelInfo)
Won't allow itself to be set to null.
zoomLevelInfo
- the zoomLevelInfo to setpublic MapTileCoordinateTransform getMtcTransform()
public void setMtcTransform(MapTileCoordinateTransform mtcTransform)
mtcTransform
- public EmptyTileHandler getEmptyTileHandler()
MapTileFactory
getEmptyTileHandler
in interface MapTileFactory
public void setEmptyTileHandler(EmptyTileHandler emptyTileHandler)
emptyTileHandler
- the emptyTileHandler to set
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |