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.
Modifier and Type | Class and Description |
---|---|
protected static interface |
TiledMapProviderBase.TileDataConverter |
protected static interface |
TiledMapProviderBase.TileImageDrawer |
static class |
TiledMapProviderBase.TileImageParameter |
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
CACHE_DIR |
protected static java.lang.String |
LINK_MARK |
protected java.util.concurrent.locks.ReentrantLock |
lock |
protected static LocLogger |
logger |
protected static ResourceManager |
message |
protected static java.lang.String |
QUESTION_MARK |
protected static java.lang.String |
REGEX |
protected static java.lang.String |
REPLACEMENT |
int |
tilePixHeight
Tile height, the unit is in pixel, the default is 256 pixels.
|
protected int |
tilePixWidth
Tile width, the unit is in pixel, the default is 256 pixels.
|
Constructor and Description |
---|
TiledMapProviderBase()
The default constructor.
|
TiledMapProviderBase(MapProviderSetting setting)
Constructor with parameters.
|
Modifier and Type | Method and Description |
---|---|
protected abstract boolean |
cacheEnabled() |
protected void |
checkSetting(MapProviderSetting setting)
Checks the configuration of map service provider.
|
void |
clearCache(java.lang.String mapName, Rectangle2D bounds)
Clears the cache corresponding to a specified area.
|
void |
dispose()
Release the resource object.
|
protected MapImage |
fillWatermark(MapImage result, MapParameter mapParameter, ImageOutputOption outputOption) |
QueryResult |
findNearest(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.AtomicBoolean |
generateBigImage(TiledMapProviderBase.TileImageDrawer drawer, TiledMapProviderBase.TileImageParameter[] tileImageParameters) |
MapParameter |
getDefaultMapParameter(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.
|
MapImage |
getMapImage(MapParameter mapParameter, ImageOutputOption outputOption)
Gets map images according to map parameters and image output settings.
|
MapParameter |
getMapParameter(java.lang.String mapName)
Gets the status of a map (the map parameters) after outputting map images last time.
|
MapProviderSetting |
getMapProviderSetting()
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 Point2D |
getOrigin(java.lang.String mapName)
Get the geographical coordinate of left upper corner of the map.
|
Overview |
getOverview(MapParameter mapParameter, ImageOutputOption outputOption)
Gets the overview map image according to map parameters and image output settings.
|
protected double |
getProximalResolution(double[] paramResolutions, double currentResolution)
Search the resolution that is larger than or equal to the current,and the nearest resolution.
|
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.
|
protected double |
getResolutoinByScale(double resolution, MapParameter defaultMapParameter) |
java.lang.String |
getResource(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.TileDataConverter |
getTileDataConverter() |
VectorStyle |
getVectorStyle(java.lang.String mapName, java.lang.String[] layerNames, VectorStyleType type)
Gets the specified vector layer style in the specified map.
|
protected void |
init(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 boolean |
isResolutionEquals(double resolution1, double resolution2)
Determines if two resolutions are within the tolerance (1.0E-6)
|
MeasureResult |
measureArea(java.lang.String mapName, Point2D[] points, MeasureParameter measureParam)
Measures areas on a specified map based on 2D geographic coordinates and a measuring parameter.
|
MeasureResult |
measureDistance(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 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.
|
protected void |
outputImageToFile(java.lang.String targetFileName, byte[] imageData, ImageOutputOption outputOption) |
QueryResult |
queryByBounds(java.lang.String mapName, Rectangle2D bounds, QueryParameterSet queryParameterSet)
Queries the geometries in the specified range on the map.
|
QueryResult |
queryByDistance(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.
|
QueryResult |
queryByGeometry(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.
|
QueryResult |
queryBySQL(java.lang.String mapName, QueryParameterSet queryParameterSet)
Performs SQL query on specified map.
|
protected MapParameter |
rectifyMapParameter(MapParameter param, MapParameter rectifyParam) |
MapParameter |
setDefaultMapParameter(MapParameter mapParameter)
Sets the default map parameters.
|
protected void |
setDefaultMapParameters(java.util.Map<java.lang.String,MapParameter> defaultMapParameters)
Sets the default map status.
|
void |
setMapProviderSetting(MapProviderSetting mapProviderSetting)
Sets the configuration of map service provider.
|
void |
setProviderContext(ProviderContext context)
Sets the service provider context
|
boolean |
support(java.lang.String mapName, MapCapability capability)
Determines whether the map supports the specified function.
|
boolean |
updateMap(MapParameter mapParameter)
Updates the map status permanently, which will do a persistence in the disk.
|
MapImage |
viewEntire(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.
|
protected static final java.lang.String REGEX
protected static final java.lang.String REPLACEMENT
protected static final java.lang.String QUESTION_MARK
protected static final java.lang.String LINK_MARK
protected static final java.lang.String CACHE_DIR
protected static ResourceManager message
protected static final LocLogger logger
protected final java.util.concurrent.locks.ReentrantLock lock
protected int tilePixWidth
Tile width, the unit is in pixel, the default is 256 pixels.
public int tilePixHeight
Tile height, the unit is in pixel, the default is 256 pixels.
.public TiledMapProviderBase()
public TiledMapProviderBase(MapProviderSetting setting)
setting
-public void setProviderContext(ProviderContext context)
ProviderContextAware
Sets the service provider context
setProviderContext
in interface ProviderContextAware
context
- service provider contextpublic 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.
getNames
in interface MapProvider
public MapParameter getMapParameter(java.lang.String mapName)
MapProvider
Gets the status of a map (the map parameters) after outputting map images last time.
getMapParameter
in interface MapProvider
mapName
- The specified map name.public MapParameter setDefaultMapParameter(MapParameter mapParameter)
MapProvider
Sets the default map parameters.
setDefaultMapParameter
in interface MapProvider
mapParameter
- Map parameters.public MapParameter getDefaultMapParameter(java.lang.String mapName)
MapProvider
Gets 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.
getDefaultMapParameter
in interface MapProvider
mapName
- The map name.public void clearCache(java.lang.String mapName, Rectangle2D bounds)
MapProvider
Clears the cache corresponding to a specified area.
clearCache
in interface MapProvider
public MapImage getMapImage(MapParameter mapParameter, ImageOutputOption outputOption)
MapProvider
Gets map images according to map parameters and image output settings.
getMapImage
in interface MapProvider
mapParameter
- Map parameters.outputOption
- Image output settings.protected MapImage fillWatermark(MapImage result, MapParameter mapParameter, ImageOutputOption outputOption)
protected MapParameter rectifyMapParameter(MapParameter param, MapParameter rectifyParam)
public java.lang.String getResource(java.lang.String mapName, ResourceParameter resourceParameter)
MapProvider
Gets the resource image of a specified map according to a resource image parameter.
getResource
in interface MapProvider
mapName
- The map name.resourceParameter
- The resource image parameter.public byte[] getResource(java.lang.String mapName, ResourceParameter resourceParameter, Point2D[] points)
MapProvider
Gets the resource image of a specified map according to a resource image parameter.
getResource
in interface MapProvider
mapName
- The map name.resourceParameter
- The resource image parameter.points
- The points used to draw resource images.public MeasureResult measureDistance(java.lang.String mapName, Point2D[] points, MeasureParameter measureParam)
MapProvider
Measures distances on a specified map based on 2D geographic coordinates and a measuring parameter.
measureDistance
in interface MapProvider
mapName
- The map name.points
- The array of 2D geographic coordinates.measureParam
- The measuring parameter.public MeasureResult measureArea(java.lang.String mapName, Point2D[] points, MeasureParameter measureParam)
MapProvider
Measures areas on a specified map based on 2D geographic coordinates and a measuring parameter.
measureArea
in interface MapProvider
mapName
- The map name.points
- The array of 2D geographic coordinates.measureParam
- The measuring parameter.public QueryResult queryByDistance(java.lang.String mapName, Geometry geometry, double distance, QueryParameterSet queryParameterSet)
MapProvider
Queries 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.
queryByDistance
in interface MapProvider
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 in queryParameterSet.queryParams[i]
.public QueryResult queryByGeometry(java.lang.String mapName, Geometry geometry, SpatialQueryMode spatialQueryMode, QueryParameterSet queryParameterSet)
MapProvider
Queries geometric objects that satisfy a certain spatial relationship with a specified geometric object and meet query conditions on a specified map.
queryByGeometry
in interface MapProvider
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 in queryParameterSet.queryParams[i]
.public QueryResult queryByBounds(java.lang.String mapName, Rectangle2D bounds, QueryParameterSet queryParameterSet)
MapProvider
Queries the geometries in the specified range on the map.
queryByBounds
in interface MapProvider
mapName
- The map name.bounds
- The specified query bounds.public QueryResult queryBySQL(java.lang.String mapName, QueryParameterSet queryParameterSet)
MapProvider
Performs SQL query on specified map.
queryBySQL
in interface MapProvider
mapName
- The map name.queryParameterSet
- Query parameters can query multiple layers of a map. The query parameters in a single layer can be set in queryParameterSet.queryParams[i]
.public QueryResult findNearest(java.lang.String mapName, Geometry geometry, double maxDistance, QueryParameterSet queryParameterSet)
MapProvider
Queries 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.
findNearest
in interface MapProvider
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 in queryParameterSet.queryParams[i]
.public MapImage viewEntire(java.lang.String layerName, MapParameter mapParameter, ImageOutputOption outputOption)
MapProvider
Displays 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.
viewEntire
in interface MapProvider
layerName
- Layer name, used to determine the full map extent.mapParameter
- Map parameters.outputOption
- Image output settings.public Overview getOverview(MapParameter mapParameter, ImageOutputOption outputOption)
Gets the overview map image according to map parameters and image output settings.
getOverview
in interface MapProvider
mapParameter
- Map parameters.outputOption
- Image output settings.public MapProviderSetting getMapProviderSetting()
Gets the configuration of map service provider.
public void setMapProviderSetting(MapProviderSetting mapProviderSetting)
Sets the configuration of map service provider.
mapProviderSetting
- The configuration of map service provider.public void dispose()
Release the resource object.
dispose
in interface Disposable
protected void checkSetting(MapProviderSetting setting)
setting
-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.
param
- Map statusoutputOption
- Image parametercurrentResolution
- Resolutionprotected byte[] outputImage(MapParameter param, ImageOutputOption outputOption, double currentResolution, Point2D tileOrigin, int tileImageWidth, int tileImageHeight, double[] resolutions)
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
-protected double getProximalResolution(double[] paramResolutions, double currentResolution)
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
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.
targetFileName
- The specified file nametargetImage
- Result imageoutputOption
- Output parameters.protected void outputImageToFile(java.lang.String targetFileName, byte[] imageData, ImageOutputOption outputOption)
protected boolean isResolutionEquals(double resolution1, double resolution2)
Determines if two resolutions are within the tolerance (1.0E-6)
resolution1
- doubleresolution2
- doubleprotected java.util.Map<java.lang.String,MapParameter> getDefaultMapParameters()
protected void setDefaultMapParameters(java.util.Map<java.lang.String,MapParameter> defaultMapParameters)
Sets the default map status.
defaultMapParameters
- Map status mapping. The key is the map name, and the value is the map parameter object.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.
setting
- The configuration object of service provider.protected double getResolutoinByScale(double resolution, MapParameter defaultMapParameter)
public boolean support(java.lang.String mapName, MapCapability capability)
MapProvider
support
in interface MapProvider
mapName
- The map name.capability
- Function type.public abstract double[] getSupportResolutions(java.lang.String mapName)
Returns the resolution of the current service support. If all resolutions are supported, empty is returned.
mapName
- The map name.protected abstract java.util.List<java.lang.String> initSupportedMapNames()
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.
public abstract OutputFormat[] getSupportImageFormat(java.lang.String mapName)
Return the supported image formats.
mapName
- The map name.protected abstract Point2D getOrigin(java.lang.String mapName)
Get the geographical coordinate of left upper corner of the map.
mapName
- The map name.protected abstract java.util.concurrent.atomic.AtomicBoolean generateBigImage(TiledMapProviderBase.TileImageDrawer drawer, TiledMapProviderBase.TileImageParameter[] tileImageParameters)
protected abstract boolean cacheEnabled()
public VectorStyle getVectorStyle(java.lang.String mapName, java.lang.String[] layerNames, VectorStyleType type)
MapProvider
getVectorStyle
in interface MapProvider
mapName
- The map name.layerNames
- The layer name.type
- The vector style type.public boolean updateMap(MapParameter mapParameter)
MapProvider
updateMap
in interface MapProvider
mapParameter
- The map status to update to.protected TiledMapProviderBase.TileDataConverter getTileDataConverter()