public abstract class AbstractRestMapProvider extends java.lang.Object implements ProviderContextAware, MapProvider, Disposable
Location service provider base class based on REST service.
Encapsulates the basic functions required to access the REST map service, and all service providers that use REST map services can use such class to extend.
Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractRestMapProvider.TileIndex
The index of the tile, including the line number, column number
|
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
CACHEKEY |
protected int |
defaultDPI
DPI of picture.
|
static java.lang.String |
LINK_MARK |
protected static LocLogger |
logger |
static java.lang.String |
QUESTION_MARK |
static double |
RESOLUTION_PRECESION
Resolution accuracy, within the accuracy range, thinks that the two resolutions are equal.
|
int |
tileCols
Tile width, the unit is the pixel, the default is 256 pixels.
|
int |
tileRows
Tile height, the unit is the pixel, the default is 256 pixels.
|
static java.lang.String |
URL_ENCODE
The encoding format of the URI.
|
Constructor and Description |
---|
AbstractRestMapProvider() |
AbstractRestMapProvider(MapProviderSetting setting) |
Modifier and Type | Method and Description |
---|---|
protected static void |
checkParameterNull(java.lang.Object obj, java.lang.String parameterName) |
protected abstract void |
checkSetting(MapProviderSetting setting)
Initialize the default map state.
|
void |
clearCache(java.lang.String mapName, Rectangle2D bounds)
Clears the cache image of the map's corresponding range.
|
void |
dispose()
Release the resource object.
|
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 ImageCacheHelper |
getCacheHelper() |
java.lang.String |
getContent(java.lang.String url, java.lang.String method)
Execute an HTTP request on the specified URL to get the response.
|
MapParameter |
getDefaultMapParameter(java.lang.String mapName)
Returns the default map state.
|
protected java.util.Map<java.lang.String,MapParameter> |
getDefaultMapParameters() |
JsonConverter |
getJsonConverter()
Gets JSON Converter.
|
MapImage |
getMapImage(MapParameter mapParameter, ImageOutputOption outputOption)
According to the map parameters, picture output settings to obtain the map image.
|
protected byte[] |
getMapImageData(java.lang.String imageFilePath) |
MapParameter |
getMapParameter(java.lang.String mapName)
Gets the status of a map (the map parameters) after outputting map images last time.
|
MapProviderSetting |
getMapProviderSetting() |
java.util.List<java.lang.String> |
getNames()
Returns the map name list.
|
Overview |
getOverview(MapParameter mapParameter, ImageOutputOption outputOption)
Gets eagle-eye map according to map parameters and image output settings.
|
java.lang.String |
getResource(java.lang.String mapName, ResourceParameter resourceParameter)
Gets the resource image of a specified map according to a resource image parameter.
|
abstract double[] |
getSupportResolutions()
Returns the resolution of the current service support.
|
protected Rectangle2D |
getTileBounds(double currentResolution, int colIndex, int rowIndex, Point2D tileOrigin)
With the given resolution, returns the range of tiles where the specified point is located.
|
protected abstract java.io.InputStream |
getTileImageStream(MapParameter tileParam, ImageOutputOption outputOption, int colIndex, int rowIndex, double currentResolution)
Gets the image stream for the specified tile.
|
protected AbstractRestMapProvider.TileIndex |
getTileIndex(Point2D point, double currentResolution, Point2D tileOriginPos)
Returns the tile index of the tile where the specified point is located
|
protected abstract Point2D |
getTileOrigin()
Gets the geographic coordinates of the upper left corner of the map.
|
protected abstract java.util.Map<java.lang.String,MapParameter> |
initDefaultMapParameter()
Initializes the default map state, the return value is a map, the key is the map name, and the value is the map parameter object.
|
protected abstract java.util.List<java.lang.String> |
initSupportedMapNames()
Initialize the list of supported maps.
|
protected boolean |
isResolutionEquals(double resolution1, double resolution2) |
protected boolean |
isResolutionSupported(double currentResolution) |
protected abstract boolean |
loadMetaData()
Load meta information for the Rest service.
|
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 void |
outputImage(MapParameter param, ImageOutputOption outputOption, double currentResolution, java.lang.String targetFileName)
Draws a picture in real time.
|
protected void |
outputImageToFile(java.lang.String targetFileName, java.awt.image.BufferedImage targetImage)
The area in which each tile coincide with the given range are spliced into a picture, write to the specified file
|
protected boolean |
outputStreamToFile(java.io.InputStream resultStream, java.lang.String targetFileName)
Writes a byte stream to a file
|
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 boolean |
rectifyViewBoundsAndViewer(MapParameter defaultMapParameter)
Corrects the map state so that the ratio of map width to height is equal to the ratio of plot width to plot height
|
protected double |
resolutionToScale(double resolution, int dpi, Unit mapUnit)
According to the resolution, DPI, map units, calculate the scale.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
sendRequestByHttpURLConnection(java.lang.String urlStr, java.lang.String method, java.io.InputStream requestStream)
Send an HTTP request via
HttpURLConnection . |
MapParameter |
setDefaultMapParameter(MapParameter mapParameter)
Sets the default map parameters.
|
protected void |
setDefaultMapParameters(java.util.Map<java.lang.String,MapParameter> defaultMapParameters)
Sets the default map state.
|
protected void |
setJsonConverter(JsonConverter jsonConverter)
Sets JSON converter, the JSON converter can convert a JSON string to a Java object.
|
void |
setMapProviderSetting(MapProviderSetting mapProviderSetting) |
void |
setProviderContext(ProviderContext context)
Sets the service provider context
|
MapImage |
viewEntire(java.lang.String layerName, MapParameter mapParameter, ImageOutputOption outputOption)
Conducts full display according to the map layer name, map parameters and picture output settings.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getResource, getVectorStyle, support, updateMap
public static final java.lang.String QUESTION_MARK
public static final java.lang.String LINK_MARK
public static final java.lang.String URL_ENCODE
The encoding format of the URI.
public static final double RESOLUTION_PRECESION
Resolution accuracy, within the accuracy range, thinks that the two resolutions are equal.
protected static final LocLogger logger
protected static final java.lang.String CACHEKEY
public int tileCols
Tile width, the unit is the pixel, the default is 256 pixels.
public int tileRows
Tile height, the unit is the pixel, the default is 256 pixels.
protected int defaultDPI
DPI of picture.
public AbstractRestMapProvider(MapProviderSetting setting)
public AbstractRestMapProvider()
public void setProviderContext(ProviderContext context)
ProviderContextAware
Sets the service provider context
setProviderContext
in interface ProviderContextAware
context
- service provider contextprotected abstract boolean loadMetaData()
protected abstract java.util.List<java.lang.String> initSupportedMapNames()
protected abstract void checkSetting(MapProviderSetting setting)
setting
-public MapParameter getDefaultMapParameter(java.lang.String mapName)
Returns the default map state.
Makes the center point of the map range as the default center point, makes the pixel size of a tile as the default picture size, the pixel size of a tile as the default picture size,
getDefaultMapParameter
in interface MapProvider
mapName
- map name.protected abstract java.util.Map<java.lang.String,MapParameter> initDefaultMapParameter()
Initializes the default map state, the return value is a map, the key is the map name, and the value is the map parameter object.
protected boolean rectifyViewBoundsAndViewer(MapParameter defaultMapParameter)
public MapImage getMapImage(MapParameter mapParameter, ImageOutputOption outputOption)
According to the map parameters, picture output settings to obtain the map image.
getMapImage
in interface MapProvider
mapParameter
- map parametersoutputOption
- Picture output settings.protected void outputImage(MapParameter param, ImageOutputOption outputOption, double currentResolution, java.lang.String targetFileName)
param
-outputOption
-currentResolution
-targetFileName
-protected boolean isResolutionSupported(double currentResolution)
protected abstract Point2D getTileOrigin()
Gets the geographic coordinates of the upper left corner of the map.
protected void outputImageToFile(java.lang.String targetFileName, java.awt.image.BufferedImage targetImage)
The area in which each tile coincide with the given range are spliced into a picture, write to the specified file
targetFileName
- The specified file nametargetImage
- Results pictureprotected boolean outputStreamToFile(java.io.InputStream resultStream, java.lang.String targetFileName)
resultStream
-targetFileName
-protected abstract java.io.InputStream getTileImageStream(MapParameter tileParam, ImageOutputOption outputOption, int colIndex, int rowIndex, double currentResolution)
Gets the image stream for the specified tile.
tileParam
-outputOption
-colIndex
-rule
-currentResolution
-protected AbstractRestMapProvider.TileIndex getTileIndex(Point2D point, double currentResolution, Point2D tileOriginPos)
point
-currentResolution
-protected Rectangle2D getTileBounds(double currentResolution, int colIndex, int rowIndex, Point2D tileOrigin)
protected byte[] getMapImageData(java.lang.String imageFilePath)
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 Overview getOverview(MapParameter mapParameter, ImageOutputOption outputOption)
MapProvider
Gets eagle-eye map according to map parameters and image output settings.
getOverview
in interface MapProvider
mapParameter
- Map parameters.outputOption
- Image output settings.public MapImage viewEntire(java.lang.String layerName, MapParameter mapParameter, ImageOutputOption outputOption)
Conducts full display according to the map layer name, map parameters and picture output settings.
The layer name specified in the parameter refers to the geographic circumference of the minimum circumscribed rectangle as full display of the contents of the layer.
viewEntire
in interface MapProvider
layerName
- Map layer name, that is, the geographic circumference of the minimum circumscribed rectangle as full display of the contents of the layer.mapParameter
- Map parametersoutputOption
- Image output settings.public java.util.List<java.lang.String> getNames()
getNames
in interface MapProvider
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 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 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 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 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]
.protected static void checkParameterNull(java.lang.Object obj, java.lang.String parameterName)
public void dispose()
Disposable
Release the resource object.
dispose
in interface Disposable
public void clearCache(java.lang.String mapName, Rectangle2D bounds)
Clears the cache image of the map's corresponding range.
clearCache
in interface MapProvider
mapName
- Map name.bounds
- Map range.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 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 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 java.lang.String getContent(java.lang.String url, java.lang.String method) throws java.io.IOException
Execute an HTTP request on the specified URL to get the response.
url
- The specified URI.method
- An HTTP method that executes a URI, such as "GET".java.io.IOException
public MapParameter setDefaultMapParameter(MapParameter mapParameter)
MapProvider
Sets the default map parameters.
setDefaultMapParameter
in interface MapProvider
mapParameter
- Map parameters.protected boolean isResolutionEquals(double resolution1, double resolution2)
protected java.util.Map<java.lang.String,java.lang.Object> sendRequestByHttpURLConnection(java.lang.String urlStr, java.lang.String method, java.io.InputStream requestStream) throws java.io.IOException
Send an HTTP request via HttpURLConnection
.
urlStr
- Request URI.method
- HTTP methods such as "GET".requestStream
- Request stream.java.io.IOException
protected double resolutionToScale(double resolution, int dpi, Unit mapUnit)
According to the resolution, DPI, map units, calculate the scale.
resolution
- The specified resolution in units of "pixels / map units".dpi
- Specified DPI.mapUnit
- Map unit, which corresponds to the unit of resolution.public JsonConverter getJsonConverter()
Gets JSON Converter.
The JSON converter can convert a JSON string to a Java object.
protected void setJsonConverter(JsonConverter jsonConverter)
Sets JSON converter, the JSON converter can convert a JSON string to a Java object.
jsonConverter
- JSON converter.protected java.util.Map<java.lang.String,MapParameter> getDefaultMapParameters()
protected void setDefaultMapParameters(java.util.Map<java.lang.String,MapParameter> defaultMapParameters)
Sets the default map state.
defaultMapParameters
- Map state mapping, the key is the map name, and the value is the map parameter object.protected ImageCacheHelper getCacheHelper()
public MapProviderSetting getMapProviderSetting()
public void setMapProviderSetting(MapProviderSetting mapProviderSetting)
public abstract double[] getSupportResolutions()