@Configurable public class GeometryHandler extends Object implements Cleanupable, EpsgConstants
FeatureQueryHandler
and SpatialFilteringProfile DAO.Modifier and Type | Field and Description |
---|---|
private String |
authority |
private static ReentrantLock |
creationLock |
private org.opengis.referencing.crs.CRSAuthorityFactory |
crsAuthority |
private boolean |
datasoureUsesNorthingFirst |
private int |
defaultResponse3DEPSG |
private int |
defaultResponseEPSG |
private List<Range> |
epsgsWithNorthingFirstAxisOrder |
private static GeometryHandler |
instance |
private static org.slf4j.Logger |
LOGGER |
private boolean |
spatialDatasource |
private int |
storage3DEPSG |
private int |
storageEPSG |
private Set<String> |
supportedCRS |
private Map<Integer,org.opengis.referencing.crs.CoordinateReferenceSystem> |
supportedCRSMap |
EPSG, EPSG_PREFIX, EPSG_PREFIX_DOUBLE_COLON, EPSG_WGS84, EPSG_WGS84_3D, NOT_SET_EPSG
Modifier | Constructor and Description |
---|---|
private |
GeometryHandler()
Private constructor
|
Modifier and Type | Method and Description |
---|---|
Set<String> |
addAuthorityCrsPrefix(Collection<Integer> crses) |
String |
addAuthorityCrsPrefix(int crs) |
Set<String> |
addOgcCrsPrefix(Collection<Integer> crses) |
String |
addOgcCrsPrefix(int crs) |
private void |
addToSupportedCrs(int epsgCode)
Add integer EPSG code to supported CRS set
|
void |
cleanup() |
protected void |
clearSupportedCRSMap()
Clears the supported Coordinate Reference Systems map
|
private org.opengis.referencing.crs.CoordinateReferenceSystem |
createCRS(int epsgCode)
Create CRS for EPSG code
|
boolean |
featureIsInFilter(com.vividsolutions.jts.geom.Geometry geometry,
List<com.vividsolutions.jts.geom.Geometry> envelopes)
Check if geometry is in SpatialFilter envelopes
|
String |
getAuthority() |
private org.opengis.referencing.crs.CoordinateReferenceSystem |
getCRS(int epsgCode)
Get CRS from EPSG code
|
private org.opengis.referencing.crs.CRSAuthorityFactory |
getCrsAuthorityFactory()
Get CSR authority
|
int |
getDefaultResponse3DEPSG()
Get configured default response 3D EPSG code
|
int |
getDefaultResponseEPSG()
Get configured default response EPSG code
|
com.vividsolutions.jts.geom.Geometry |
getFilterForNonSpatialDatasource(SpatialFilter filter)
Get filter geometry for BBOX spatial filter and non spatial datasource
|
static GeometryHandler |
getInstance() |
int |
getStorage3DEPSG()
Get configured storage 3D EPSG code
|
int |
getStorageEPSG()
Get configured storage EPSG code
|
Set<String> |
getSupportedCRS()
Get List of supported EPSG codes
|
double |
getValueAsDouble(Object value)
Deprecated.
|
String |
getWktString(Object longitude,
Object latitude)
Get WKT string from longitude and latitude
|
String |
getWktString(Object longitude,
Object latitude,
int epsg)
Get WKT string from longitude and latitude with axis order as defined by
EPSG code.
|
private void |
initCrsAuthoritycrsAuthority() |
boolean |
isDatasourceNorthingFirst()
Check if the datasource uses northing first coordinates
|
boolean |
isEastingFirstEpsgCode(int epsgCode)
Check if the EPSG code is easting first
|
boolean |
isNorthingFirstEpsgCode(int epsgCode)
Check if the EPSG code is northing first
|
boolean |
isSpatialDatasource()
Is datasource a spatial datasource
|
void |
setAuthority(String authority) |
void |
setDatasourceNorthingFirst(boolean datasoureUsesNorthingFirst)
Set the northing first indicator for the datasource
|
void |
setDefaultResponse3DEpsg(int epsgCode3D)
Set default response 3D EPSG code from settings
|
void |
setDefaultResponseEpsg(int epsgCode)
Set default response EPSG code from settings
|
void |
setEpsgCodesWithNorthingFirstAxisOrder(String codes)
Set the EPSG code ranges for which the coordinates should be switched
|
void |
setSpatialDatasource(boolean spatialDatasource)
Set flag if the used datasource is a spatial datasource (provides spatial
functions)
|
void |
setStorage3DEpsg(int epsgCode3D)
Set storage 3D EPSG code from settings
|
void |
setStorageEpsg(int epsgCode)
Set storage EPSG code from settings
|
void |
setSupportedCRS(String supportedCRS)
Set the supported EPSG codes
|
com.vividsolutions.jts.geom.Geometry |
switchCoordinateAxisFromToDatasourceIfNeeded(com.vividsolutions.jts.geom.Geometry geom)
Switch the coordinate axis of geometry from or for datasource
|
private com.vividsolutions.jts.geom.Geometry |
switchCoordinateAxisIfNeeded(com.vividsolutions.jts.geom.Geometry geometry,
int targetSRID) |
com.vividsolutions.jts.geom.Geometry |
transform(com.vividsolutions.jts.geom.Geometry geometry,
int targetSRID)
Transform geometry to this EPSG code
|
private com.vividsolutions.jts.geom.Geometry |
transform(com.vividsolutions.jts.geom.Geometry geometry,
int targetSRID,
org.opengis.referencing.crs.CoordinateReferenceSystem sourceCRS,
org.opengis.referencing.crs.CoordinateReferenceSystem targetCRS)
Transform geometry
|
com.vividsolutions.jts.geom.Envelope |
transformEnvelope(com.vividsolutions.jts.geom.Envelope envelope,
int sourceSRID,
int targetSRID)
Transform envelope from source to target EPSG code
|
com.vividsolutions.jts.geom.Geometry |
transformToStorageEpsg(com.vividsolutions.jts.geom.Geometry geometry)
Transforms the geometry to the storage EPSG code
|
private static final org.slf4j.Logger LOGGER
private static GeometryHandler instance
private static ReentrantLock creationLock
private boolean datasoureUsesNorthingFirst
private int storageEPSG
private int storage3DEPSG
private int defaultResponseEPSG
private int defaultResponse3DEPSG
private boolean spatialDatasource
private String authority
private org.opengis.referencing.crs.CRSAuthorityFactory crsAuthority
public static GeometryHandler getInstance()
private void initCrsAuthoritycrsAuthority()
public void cleanup()
cleanup
in interface Cleanupable
public int getStorageEPSG()
public int getStorage3DEPSG()
public int getDefaultResponseEPSG()
public int getDefaultResponse3DEPSG()
@Setting(value="service.defaultEpsg") public void setStorageEpsg(int epsgCode) throws ConfigurationException
epsgCode
- EPSG code from settingsConfigurationException
- If an error occurs@Setting(value="service.default3DEpsg") public void setStorage3DEpsg(int epsgCode3D) throws ConfigurationException
epsgCode3D
- 3D EPSG code from settingsConfigurationException
- If an error occurs@Setting(value="service.defaultResponseEpsg") public void setDefaultResponseEpsg(int epsgCode) throws ConfigurationException
epsgCode
- EPSG code from settingsConfigurationException
- If an error occurs@Setting(value="service.defaultRespopnse3DEpsg") public void setDefaultResponse3DEpsg(int epsgCode3D) throws ConfigurationException
epsgCode3D
- 3D EPSG code from settingsConfigurationException
- If an error occurs@Setting(value="service.supportedCrs") public void setSupportedCRS(String supportedCRS) throws ConfigurationException
supportedCRS
- Supported EPSG codesConfigurationException
public String getAuthority()
private void addToSupportedCrs(int epsgCode)
epsgCode
- Integer EPSG code@Setting(value="misc.datasourceNorthingFirst") public void setDatasourceNorthingFirst(boolean datasoureUsesNorthingFirst)
datasoureUsesNorthingFirst
- Northing first indicatorpublic boolean isDatasourceNorthingFirst()
true
, if the datasource uses northing first
coordinates@Setting(value="misc.switchCoordinatesForEpsgCodes") public void setEpsgCodesWithNorthingFirstAxisOrder(String codes) throws ConfigurationException
codes
- EPSG code rangesConfigurationException
- If an error occurs@Setting(value="service.SpatialDatasource") public void setSpatialDatasource(boolean spatialDatasource)
spatialDatasource
- Flag if spatial datasourcepublic boolean isNorthingFirstEpsgCode(int epsgCode)
epsgCode
- EPSG code to checktrue
, if the EPSG code is northing firstpublic boolean isEastingFirstEpsgCode(int epsgCode)
epsgCode
- EPSG code to checktrue
, if the EPSG code is easting firstpublic boolean isSpatialDatasource()
public com.vividsolutions.jts.geom.Geometry switchCoordinateAxisFromToDatasourceIfNeeded(com.vividsolutions.jts.geom.Geometry geom) throws OwsExceptionReport
geom
- Geometry to switch coordinate axisOwsExceptionReport
- If coordinate axis switching failsprivate com.vividsolutions.jts.geom.Geometry switchCoordinateAxisIfNeeded(com.vividsolutions.jts.geom.Geometry geometry, int targetSRID) throws OwsExceptionReport
OwsExceptionReport
@Deprecated public double getValueAsDouble(Object value)
value
- Value to checkpublic com.vividsolutions.jts.geom.Geometry getFilterForNonSpatialDatasource(SpatialFilter filter) throws OwsExceptionReport
filter
- SpatialFilterOwsExceptionReport
- If SpatialFilter is not supportedpublic String getWktString(Object longitude, Object latitude)
longitude
- Longitude coordinatelatitude
- Latitude coordinatepublic String getWktString(Object longitude, Object latitude, int epsg)
longitude
- Longitude coordinatelatitude
- Latitude coordinateepsg
- EPSG code to check for axis orderpublic boolean featureIsInFilter(com.vividsolutions.jts.geom.Geometry geometry, List<com.vividsolutions.jts.geom.Geometry> envelopes)
geometry
- Geometry to checkenvelopes
- SpatialFilter envelopespublic com.vividsolutions.jts.geom.Geometry transformToStorageEpsg(com.vividsolutions.jts.geom.Geometry geometry) throws OwsExceptionReport
geometry
- Geometry to transformOwsExceptionReport
public com.vividsolutions.jts.geom.Geometry transform(com.vividsolutions.jts.geom.Geometry geometry, int targetSRID) throws OwsExceptionReport
geometry
- Geometry to transformtargetSRID
- Target EPSG codeOwsExceptionReport
private com.vividsolutions.jts.geom.Geometry transform(com.vividsolutions.jts.geom.Geometry geometry, int targetSRID, org.opengis.referencing.crs.CoordinateReferenceSystem sourceCRS, org.opengis.referencing.crs.CoordinateReferenceSystem targetCRS) throws OwsExceptionReport
geometry
- Geometry to transformtargetSRID
- TargetEPSG codesourceCRS
- Source CRStargetCRS
- Target CRSOwsExceptionReport
private org.opengis.referencing.crs.CoordinateReferenceSystem getCRS(int epsgCode) throws CodedException
epsgCode
- EPSG code to get CRS forCodedException
- If the geometry EPSG code is not supportedprivate org.opengis.referencing.crs.CoordinateReferenceSystem createCRS(int epsgCode) throws CodedException
epsgCode
- EPSG code to create CRS forCodedException
- If the geometry EPSG code is not supportedprivate org.opengis.referencing.crs.CRSAuthorityFactory getCrsAuthorityFactory()
public Set<String> getSupportedCRS()
public com.vividsolutions.jts.geom.Envelope transformEnvelope(com.vividsolutions.jts.geom.Envelope envelope, int sourceSRID, int targetSRID) throws CodedException
envelope
- Envelope to transformsourceSRID
- Source EPSG codetargetSRID
- Target EPSG codeCodedException
- If the geometry EPSG code is not supportedprotected void clearSupportedCRSMap()
public Set<String> addAuthorityCrsPrefix(Collection<Integer> crses)
public String addAuthorityCrsPrefix(int crs)
public Set<String> addOgcCrsPrefix(Collection<Integer> crses)
public String addOgcCrsPrefix(int crs)
Copyright © 2012-2015 52north.org. All Rights Reserved.