Class TiledMapProviderBase
- java.lang.Object
-
- com.supermap.services.components.spi.TiledMapProviderBase
-
- All Implemented Interfaces:
- Disposable, MapProvider, ProviderContextAware
- Direct Known Subclasses:
- LocalTileProviderBase, RemoteTileProviderBase
public abstract class TiledMapProviderBase extends java.lang.Object implements ProviderContextAware, MapProvider, Disposable
Map service provider types based on REST service.
Encapsulated the basic functions needed to access REST map service, all the service providers using REST map service can use this extension.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description protected static interfaceTiledMapProviderBase.TileDataConverterprotected static interfaceTiledMapProviderBase.TileImageDrawerstatic classTiledMapProviderBase.TileImageParameter
-
Field Summary
Fields Modifier and Type Field and Description protected static java.lang.StringCACHE_DIRprotected static java.lang.StringLINK_MARKprotected java.util.concurrent.locks.ReentrantLocklockprotected static LocLoggerloggerprotected static ResourceManagermessageprotected static java.lang.StringQUESTION_MARKprotected static java.lang.StringREGEXprotected static java.lang.StringREPLACEMENTinttilePixHeightTile height, the unit is in pixel, the default is 256 pixels.protected inttilePixWidthTile width, the unit is in pixel, the default is 256 pixels.
-
Constructor Summary
Constructors Constructor and Description TiledMapProviderBase()The default constructor.TiledMapProviderBase(MapProviderSetting setting)Constructor with parameters.
-
Method Summary
Methods Modifier and Type Method and Description protected abstract booleancacheEnabled()protected voidcheckSetting(MapProviderSetting setting)Checks the configuration of map service provider.voidclearCache(java.lang.String mapName, Rectangle2D bounds)Clears the cache corresponding to a specified area.voiddispose()Release the resource object.protected MapImagefillWatermark(MapImage result, MapParameter mapParameter, ImageOutputOption outputOption)QueryResultfindNearest(java.lang.String mapName, Geometry geometry, double maxDistance, QueryParameterSet queryParameterSet)Queries the nearest geometric object on a specified map whose distance to a specified geometry is within a certain value.protected abstract java.util.concurrent.atomic.AtomicBooleangenerateBigImage(TiledMapProviderBase.TileImageDrawer drawer, TiledMapProviderBase.TileImageParameter[] tileImageParameters)MapParametergetDefaultMapParameter(java.lang.String mapName)Gets the default map parameters of the specified map.protected java.util.Map<java.lang.String,MapParameter>getDefaultMapParameters()Returns the default map parameters.MapImagegetMapImage(MapParameter mapParameter, ImageOutputOption outputOption)Gets map images according to map parameters and image output settings.MapParametergetMapParameter(java.lang.String mapName)Gets the status of a map (the map parameters) after outputting map images last time.MapProviderSettinggetMapProviderSetting()Gets the configuration of map service provider.java.util.List<java.lang.String>getNames()Initializing the default map status, a mapping object will be returned, of which the key is map name, valude is map parameter object.protected abstract Point2DgetOrigin(java.lang.String mapName)Get the geographical coordinate of left upper corner of the map.OverviewgetOverview(MapParameter mapParameter, ImageOutputOption outputOption)Gets the overview map image according to map parameters and image output settings.protected doublegetProximalResolution(double[] paramResolutions, double currentResolution)Search the resolution that is larger than or equal to the current,and the nearest resolution.protected doublegetProximalResolution(double[] paramResolutions, double currentResolution, int maxTolerance)Search the resolution that is larger than or equal to the current,and the nearest resolution.protected doublegetResolutoinByScale(double resolution, MapParameter defaultMapParameter)java.lang.StringgetResource(java.lang.String mapName, ResourceParameter resourceParameter)Gets the resource image of a specified map according to a resource image parameter.byte[]getResource(java.lang.String mapName, ResourceParameter resourceParameter, Point2D[] points)Gets the resource image of a specified map according to a resource image parameter.abstract OutputFormat[]getSupportImageFormat(java.lang.String mapName)Return the supported image formats.abstract double[]getSupportResolutions(java.lang.String mapName)Returns the resolution of the current service support.
protected TiledMapProviderBase.TileDataConvertergetTileDataConverter()VectorStylegetVectorStyle(java.lang.String mapName, java.lang.String[] layerNames, VectorStyleType type)Gets the specified vector layer style in the specified map.protected voidinit(MapProviderSetting setting)Initialization function.protected abstract java.util.Map<java.lang.String,MapParameter>initDefaultMapParameter()Initializing the default map status, a mapping object will be returned, of which the key is map name, valude is map parameter object.protected abstract java.util.List<java.lang.String>initSupportedMapNames()Initializes the supported map list.protected booleanisResolutionEquals(double resolution1, double resolution2)Determines if two resolutions are within the tolerance (1.0E-6)MeasureResultmeasureArea(java.lang.String mapName, Point2D[] points, MeasureParameter measureParam)Measures areas on a specified map based on 2D geographic coordinates and a measuring parameter.MeasureResultmeasureDistance(java.lang.String mapName, Point2D[] points, MeasureParameter measureParam)Measures distances on a specified map based on 2D geographic coordinates and a measuring parameter.protected byte[]outputImage(MapParameter param, ImageOutputOption outputOption, double currentResolution)Output image in real time.protected byte[]outputImage(MapParameter param, ImageOutputOption outputOption, double currentResolution, Point2D tileOrigin, int tileImageWidth, int tileImageHeight, double[] resolutions)Outputting map according to the map parameter.protected voidoutputImageToFile(java.lang.String targetFileName, java.awt.image.BufferedImage targetImage, ImageOutputOption outputOption)Merges the tiles and the region of given range to a image.protected voidoutputImageToFile(java.lang.String targetFileName, byte[] imageData, ImageOutputOption outputOption)QueryResultqueryByBounds(java.lang.String mapName, Rectangle2D bounds, QueryParameterSet queryParameterSet)Queries the geometries in the specified range on the map.QueryResultqueryByDistance(java.lang.String mapName, Geometry geometry, double distance, QueryParameterSet queryParameterSet)Queries all the geometric objects on a specified map whose distances to a specified geometry are within a certain value.QueryResultqueryByGeometry(java.lang.String mapName, Geometry geometry, SpatialQueryMode spatialQueryMode, QueryParameterSet queryParameterSet)Queries geometric objects that satisfy a certain spatial relationship with a specified geometric object and meet query conditions on a specified map.QueryResultqueryBySQL(java.lang.String mapName, QueryParameterSet queryParameterSet)Performs SQL query on specified map.protected MapParameterrectifyMapParameter(MapParameter param, MapParameter rectifyParam)MapParametersetDefaultMapParameter(MapParameter mapParameter)Sets the default map parameters.protected voidsetDefaultMapParameters(java.util.Map<java.lang.String,MapParameter> defaultMapParameters)Sets the default map status.voidsetMapProviderSetting(MapProviderSetting mapProviderSetting)Sets the configuration of map service provider.voidsetProviderContext(ProviderContext context)Sets the service provider contextbooleansupport(java.lang.String mapName, MapCapability capability)Determines whether the map supports the specified function.booleanupdateMap(MapParameter mapParameter)Updates the map status permanently, which will do a persistence in the disk.MapImageviewEntire(java.lang.String layerName, MapParameter mapParameter, ImageOutputOption outputOption)Displays a map in the Full Extent mode according to map layer name, map parameters and image output settings.
-
-
-
Field Detail
-
REGEX
protected static final java.lang.String REGEX
-
REPLACEMENT
protected static final java.lang.String REPLACEMENT
-
QUESTION_MARK
protected static final java.lang.String QUESTION_MARK
-
LINK_MARK
protected static final java.lang.String LINK_MARK
-
CACHE_DIR
protected static final java.lang.String CACHE_DIR
-
message
protected static ResourceManager message
-
logger
protected static final LocLogger logger
-
lock
protected final java.util.concurrent.locks.ReentrantLock lock
-
tilePixWidth
protected int tilePixWidth
Tile width, the unit is in pixel, the default is 256 pixels.
-
tilePixHeight
public int tilePixHeight
Tile height, the unit is in pixel, the default is 256 pixels.
.
-
-
Constructor Detail
-
TiledMapProviderBase
public TiledMapProviderBase()
The default constructor.
-
TiledMapProviderBase
public TiledMapProviderBase(MapProviderSetting setting)
Constructor with parameters.- Parameters:
setting-
-
-
Method Detail
-
setProviderContext
public void setProviderContext(ProviderContext context)
Description copied from interface:ProviderContextAwareSets the service provider context
- Specified by:
setProviderContextin interfaceProviderContextAware- Parameters:
context- service provider context
-
getNames
public java.util.List<java.lang.String> getNames()
Initializing the default map status, a mapping object will be returned, of which the key is map name, valude is map parameter object.
- Specified by:
getNamesin interfaceMapProvider- Returns:
- Map status mapping. The key is the map name, and the value is the map parameter object.
-
getMapParameter
public MapParameter getMapParameter(java.lang.String mapName)
Description copied from interface:MapProviderGets the status of a map (the map parameters) after outputting map images last time.
- Specified by:
getMapParameterin interfaceMapProvider- Parameters:
mapName- The specified map name.- Returns:
- Map parameters.
-
setDefaultMapParameter
public MapParameter setDefaultMapParameter(MapParameter mapParameter)
Description copied from interface:MapProviderSets the default map parameters.
- Specified by:
setDefaultMapParameterin interfaceMapProvider- Parameters:
mapParameter- Map parameters.- Returns:
- The map parameter object.
-
getDefaultMapParameter
public MapParameter getDefaultMapParameter(java.lang.String mapName)
Description copied from interface:MapProviderGets the default map parameters of the specified map.
Retrieval of the initial default map parameter depends on the type of the service accessed. For example, if the GIS functions provided by SuperMap Objects Java are accessed, the initial default map parameter is obtained from a workspace file; if the GIS functions of a WMS service are accessed, the default map parameter is determined in the WMS service.
- Specified by:
getDefaultMapParameterin interfaceMapProvider- Parameters:
mapName- The map name.- Returns:
- The map parameter object.
-
clearCache
public void clearCache(java.lang.String mapName, Rectangle2D bounds)Description copied from interface:MapProviderClears the cache corresponding to a specified area.
- Specified by:
clearCachein interfaceMapProvider
-
getMapImage
public MapImage getMapImage(MapParameter mapParameter, ImageOutputOption outputOption)
Description copied from interface:MapProviderGets map images according to map parameters and image output settings.
- Specified by:
getMapImagein interfaceMapProvider- Parameters:
mapParameter- Map parameters.outputOption- Image output settings.- Returns:
- The map image object.
-
fillWatermark
protected MapImage fillWatermark(MapImage result, MapParameter mapParameter, ImageOutputOption outputOption)
-
rectifyMapParameter
protected MapParameter rectifyMapParameter(MapParameter param, MapParameter rectifyParam)
-
getResource
public java.lang.String getResource(java.lang.String mapName, ResourceParameter resourceParameter)Description copied from interface:MapProviderGets the resource image of a specified map according to a resource image parameter.
- Specified by:
getResourcein interfaceMapProvider- Parameters:
mapName- The map name.resourceParameter- The resource image parameter.- Returns:
- The resource image address.
-
getResource
public byte[] getResource(java.lang.String mapName, ResourceParameter resourceParameter, Point2D[] points)Description copied from interface:MapProviderGets the resource image of a specified map according to a resource image parameter.
- Specified by:
getResourcein interfaceMapProvider- Parameters:
mapName- The map name.resourceParameter- The resource image parameter.points- The points used to draw resource images.- Returns:
- Binary stream of the image.
-
measureDistance
public MeasureResult measureDistance(java.lang.String mapName, Point2D[] points, MeasureParameter measureParam)
Description copied from interface:MapProviderMeasures distances on a specified map based on 2D geographic coordinates and a measuring parameter.
- Specified by:
measureDistancein interfaceMapProvider- Parameters:
mapName- The map name.points- The array of 2D geographic coordinates.measureParam- The measuring parameter.- Returns:
- Measurement result object.
-
measureArea
public MeasureResult measureArea(java.lang.String mapName, Point2D[] points, MeasureParameter measureParam)
Description copied from interface:MapProviderMeasures areas on a specified map based on 2D geographic coordinates and a measuring parameter.
- Specified by:
measureAreain interfaceMapProvider- Parameters:
mapName- The map name.points- The array of 2D geographic coordinates.measureParam- The measuring parameter.- Returns:
- Measurement result object.
-
queryByDistance
public QueryResult queryByDistance(java.lang.String mapName, Geometry geometry, double distance, QueryParameterSet queryParameterSet)
Description copied from interface:MapProviderQueries all the geometric objects on a specified map whose distances to a specified geometry are within a certain value.
Which means to query all the geometries within a circle whose center is the specified geometry.
- Specified by:
queryByDistancein interfaceMapProvider- Parameters:
mapName- The map name.geometry- The geometric object.distance- The querying distance.queryParameterSet- Query parameters can query multiple layers of a map. The query parameters in a single layer can be set inqueryParameterSet.queryParams[i].- Returns:
- Query result object.
-
queryByGeometry
public QueryResult queryByGeometry(java.lang.String mapName, Geometry geometry, SpatialQueryMode spatialQueryMode, QueryParameterSet queryParameterSet)
Description copied from interface:MapProviderQueries geometric objects that satisfy a certain spatial relationship with a specified geometric object and meet query conditions on a specified map.
- Specified by:
queryByGeometryin interfaceMapProvider- Parameters:
mapName- The map name.geometry- The geometric object, which has spatial information and shape information, but no attribute information.spatialQueryMode- The spatial query mode, which defines several spatial relationships between geometries, and it allows users to construct filter conditions to perform querying. For example, searching spatial objects which are contained in specified region object, or which have a disjoint or adjacent relationship with the specified region object.queryParameterSet- Query parameters can query multiple layers of a map. The query parameters in a single layer can be set inqueryParameterSet.queryParams[i].- Returns:
- Query result object.
-
queryByBounds
public QueryResult queryByBounds(java.lang.String mapName, Rectangle2D bounds, QueryParameterSet queryParameterSet)
Description copied from interface:MapProviderQueries the geometries in the specified range on the map.
- Specified by:
queryByBoundsin interfaceMapProvider- Parameters:
mapName- The map name.bounds- The specified query bounds.- Returns:
- Query result object.
-
queryBySQL
public QueryResult queryBySQL(java.lang.String mapName, QueryParameterSet queryParameterSet)
Description copied from interface:MapProviderPerforms SQL query on specified map.
- Specified by:
queryBySQLin interfaceMapProvider- Parameters:
mapName- The map name.queryParameterSet- Query parameters can query multiple layers of a map. The query parameters in a single layer can be set inqueryParameterSet.queryParams[i].- Returns:
- Query result object.
-
findNearest
public QueryResult findNearest(java.lang.String mapName, Geometry geometry, double maxDistance, QueryParameterSet queryParameterSet)
Description copied from interface:MapProviderQueries the nearest geometric object on a specified map whose distance to a specified geometry is within a certain value. When limit the number of returned geometric objects (specified by
QueryParameterSet.expectCount), the query result is the expectCount features nearest to the center in the records. There is no orders of expectCount.- Specified by:
findNearestin interfaceMapProvider- Parameters:
mapName- The map name.geometry- The geometric object.maxDistance- The maximum distance, of which the unit is identical with that of the map specified with mapName parameter.queryParameterSet- Query parameters can query multiple layers of a map. The query parameters in a single layer can be set inqueryParameterSet.queryParams[i].- Returns:
- Query result object.
-
viewEntire
public MapImage viewEntire(java.lang.String layerName, MapParameter mapParameter, ImageOutputOption outputOption)
Description copied from interface:MapProviderDisplays a map in the Full Extent mode according to map layer name, map parameters and image output settings.
The full geographic map extent to display is the minimum circumscribed rectangle of the specified layer.
- Specified by:
viewEntirein interfaceMapProvider- Parameters:
layerName- Layer name, used to determine the full map extent.mapParameter- Map parameters.outputOption- Image output settings.- Returns:
- The Map object.
-
getOverview
public Overview getOverview(MapParameter mapParameter, ImageOutputOption outputOption)
Gets the overview map image according to map parameters and image output settings.
- Specified by:
getOverviewin interfaceMapProvider- Parameters:
mapParameter- Map parameters.outputOption- Image output settings.- Returns:
- The overview map image object.
-
getMapProviderSetting
public MapProviderSetting getMapProviderSetting()
Gets the configuration of map service provider.
- Returns:
- The configuration of map service provider.
-
setMapProviderSetting
public void setMapProviderSetting(MapProviderSetting mapProviderSetting)
Sets the configuration of map service provider.
- Parameters:
mapProviderSetting- The configuration of map service provider.
-
dispose
public void dispose()
Release the resource object.
- Specified by:
disposein interfaceDisposable
-
checkSetting
protected void checkSetting(MapProviderSetting setting)
Checks the configuration of map service provider.- Parameters:
setting-
-
outputImage
protected byte[] outputImage(MapParameter param, ImageOutputOption outputOption, double currentResolution)
Output image in real time. It is stored in the specified path according to the map parameter.
- Parameters:
param- Map statusoutputOption- Image parametercurrentResolution- Resolution
-
outputImage
protected byte[] outputImage(MapParameter param, ImageOutputOption outputOption, double currentResolution, Point2D tileOrigin, int tileImageWidth, int tileImageHeight, double[] resolutions)
Outputting map according to the map parameter.- Parameters:
param- Map parameters.outputOption- Image output parameters.currentResolution- The current resolution.tileOrigin- The origin of current tile matrix.tileImageWidth- The width of current tile matrix.tileImageHeight- The height of current tile matrix.resolutions-- Returns:
-
getProximalResolution
protected double getProximalResolution(double[] paramResolutions, double currentResolution)Search the resolution that is larger than or equal to the current,and the nearest resolution. If the matching resolution is too different from the actual resolution (default is 5 times), returns -1.
-
getProximalResolution
protected double getProximalResolution(double[] paramResolutions, double currentResolution, int maxTolerance)Search the resolution that is larger than or equal to the current,and the nearest resolution.
When the matching resolution is too different from the actual resolution (over maxTolerance), returns -1; when maxTolerance == 0, it means no tolerance
-
outputImageToFile
protected void outputImageToFile(java.lang.String targetFileName, java.awt.image.BufferedImage targetImage, ImageOutputOption outputOption)Merges the tiles and the region of given range to a image. Input to the specified file.
- Parameters:
targetFileName- The specified file nametargetImage- Result imageoutputOption- Output parameters.
-
outputImageToFile
protected void outputImageToFile(java.lang.String targetFileName, byte[] imageData, ImageOutputOption outputOption)
-
isResolutionEquals
protected boolean isResolutionEquals(double resolution1, double resolution2)Determines if two resolutions are within the tolerance (1.0E-6)
- Parameters:
resolution1- doubleresolution2- double- Returns:
- Is it equal
-
getDefaultMapParameters
protected java.util.Map<java.lang.String,MapParameter> getDefaultMapParameters()
Returns the default map parameters.- Returns:
- The default map parameters.
-
setDefaultMapParameters
protected void setDefaultMapParameters(java.util.Map<java.lang.String,MapParameter> defaultMapParameters)
Sets the default map status.
- Parameters:
defaultMapParameters- Map status mapping. The key is the map name, and the value is the map parameter object.
-
init
protected void init(MapProviderSetting setting)
Initialization function. This function does not carry on null judgment on parameter, but it may judge the correction of the contents.
- Parameters:
setting- The configuration object of service provider.
-
getResolutoinByScale
protected double getResolutoinByScale(double resolution, MapParameter defaultMapParameter)
-
support
public boolean support(java.lang.String mapName, MapCapability capability)Description copied from interface:MapProviderDetermines whether the map supports the specified function.- Specified by:
supportin interfaceMapProvider- Parameters:
mapName- The map name.capability- Function type.- Returns:
- true means to support; otherwise, false.
-
getSupportResolutions
public abstract double[] getSupportResolutions(java.lang.String mapName)
Returns the resolution of the current service support. If all resolutions are supported, empty is returned.
- Parameters:
mapName- The map name.- Returns:
- The resolution array.
-
initSupportedMapNames
protected abstract java.util.List<java.lang.String> initSupportedMapNames()
Initializes the supported map list.- Returns:
- The map name list.
-
initDefaultMapParameter
protected abstract java.util.Map<java.lang.String,MapParameter> initDefaultMapParameter()
Initializing the default map status, a mapping object will be returned, of which the key is map name, valude is map parameter object.
- Returns:
- Map status mapping. The key is the map name, and the value is the map parameter object.
-
getSupportImageFormat
public abstract OutputFormat[] getSupportImageFormat(java.lang.String mapName)
Return the supported image formats.
- Parameters:
mapName- The map name.- Returns:
- Supported image format array
-
getOrigin
protected abstract Point2D getOrigin(java.lang.String mapName)
Get the geographical coordinate of left upper corner of the map.
- Parameters:
mapName- The map name.- Returns:
- The geographical coordinate of left upper corner of the map.
-
generateBigImage
protected abstract java.util.concurrent.atomic.AtomicBoolean generateBigImage(TiledMapProviderBase.TileImageDrawer drawer, TiledMapProviderBase.TileImageParameter[] tileImageParameters)
-
cacheEnabled
protected abstract boolean cacheEnabled()
-
getVectorStyle
public VectorStyle getVectorStyle(java.lang.String mapName, java.lang.String[] layerNames, VectorStyleType type)
Description copied from interface:MapProviderGets the specified vector layer style in the specified map.- Specified by:
getVectorStylein interfaceMapProvider- Parameters:
mapName- The map name.layerNames- The layer name.type- The vector style type.- Returns:
- Vector layer style.
-
updateMap
public boolean updateMap(MapParameter mapParameter)
Description copied from interface:MapProviderUpdates the map status permanently, which will do a persistence in the disk.- Specified by:
updateMapin interfaceMapProvider- Parameters:
mapParameter- The map status to update to.- Returns:
- Whether the update is successful.
-
getTileDataConverter
protected TiledMapProviderBase.TileDataConverter getTileDataConverter()
-
-