public class SpatialHelper extends Object
Helper class to search and access Spatial MetaData. This class wraps some of the spatial functions that datanucleus-spatial offers via JDOQL in "real" Java methods and also adds extended functionality, like reading values from JDO-Metadata and getting CRS (Coordinate Reference System) information from the database.
The datatypes and terminology used in this class is (like most of datanucleus-spatial) heavily based on OGC's Simple Feature specification. See http://www.opengeospatial.org/standards/sfa for details.
| Modifier and Type | Class and Description |
|---|---|
protected class |
SpatialHelper.QueryExecutor
Abstract helper class to execute queries.
|
| Modifier and Type | Field and Description |
|---|---|
protected org.datanucleus.api.jdo.JDOPersistenceManagerFactory |
pmf |
protected org.datanucleus.store.rdbms.RDBMSStoreManager |
storeMgr |
| Constructor and Description |
|---|
SpatialHelper(org.datanucleus.api.jdo.JDOPersistenceManagerFactory pmf)
Creates a new
SpatialHelper instance for the given PMF. |
| Modifier and Type | Method and Description |
|---|---|
Rectangle2D |
calculateBoundsInDatastore(Class pc,
String fieldName,
javax.jdo.PersistenceManager pm) |
protected void |
checkValid(Class pc,
String fieldName) |
Rectangle2D |
estimateBoundsFromDatastoreMetadata(Class pc,
String fieldName,
javax.jdo.PersistenceManager pm)
Returns the (estimated) spatial extent, also called bounding box from datastore metadata for the
given geometry field.
|
protected SpatialRDBMSAdapter |
getAdapter() |
protected org.datanucleus.store.rdbms.table.Column |
getColumn(Class pc,
org.datanucleus.metadata.AbstractMemberMetaData mmd) |
protected org.datanucleus.store.rdbms.table.Column |
getColumn(Class pc,
String fieldName) |
String |
getCrsNameForSrid(Class pc,
int srid,
javax.jdo.PersistenceManager pm)
Returns the name of the Coordinate Reference System (CRS) for the given srid.
|
String |
getCrsWktForSrid(Class pc,
int srid,
javax.jdo.PersistenceManager pm)
Returns the description of the Coordinate Reference System (CRS) for the given srid in WKT (Well-Known
Text).
|
Integer |
getDimensionFromJdoMetadata(Class pc,
String fieldName)
Returns the dimension from JDO-Metadata for the given geometry field.
|
String[] |
getGeometryColumnBackedFields(Class pc)
Return all field names of the given class that are backed by a geometry column in the database.
|
protected Integer |
getIntegerFromJdoMetadata(Class pc,
String fieldName,
String extensionKey) |
protected org.datanucleus.metadata.MetaDataManager |
getMetaDataManager() |
Integer |
getSridFromDatastoreMetadata(Class pc,
String fieldName,
javax.jdo.PersistenceManager pm)
Returns the srid from datastore metadata for the given geometry field.
|
Integer |
getSridFromJdoMetadata(Class pc,
String fieldName)
Returns the srid from JDO-Metadata for the given geometry field.
|
protected org.datanucleus.store.rdbms.table.Table |
getTable(Class pc) |
protected String |
getValueFromJdoMetadata(Class pc,
String memberName,
String extensionKey) |
boolean |
isGeometryColumnBackedField(Class pc,
String fieldName)
Checks whether the given field name for the given class is backed by a geometry column in the database.
|
protected boolean |
isGeometryColumnBackedField(org.datanucleus.store.rdbms.table.Column c) |
protected Object |
readFirstValueForField(Class pc,
String fieldName,
javax.jdo.PersistenceManager pm) |
protected org.datanucleus.api.jdo.JDOPersistenceManagerFactory pmf
protected org.datanucleus.store.rdbms.RDBMSStoreManager storeMgr
public SpatialHelper(org.datanucleus.api.jdo.JDOPersistenceManagerFactory pmf)
SpatialHelper instance for the given PMF.pmf - The PMF, can't be null or closed.public Integer getSridFromJdoMetadata(Class pc, String fieldName)
null, if the
user has not specified a value in his metadata.pc - The PersistenceCapapable classfieldName - Name of the geometry fieldnull.SpatialRDBMSAdapter.SRID_EXTENSION_KEYpublic Integer getDimensionFromJdoMetadata(Class pc, String fieldName)
null, if
the user has not specified a value in his metadata.pc - The PersistenceCapapable classfieldName - Name of the geometry fieldnull.SpatialRDBMSAdapter.DIMENSION_EXTENSION_KEYpublic Integer getSridFromDatastoreMetadata(Class pc, String fieldName, javax.jdo.PersistenceManager pm)
null,
if the datastore doesn't support such an operation (e.g. MySQL) or if there is no metadata in the
datastore available for the given class and field name.pc - The persistable classfieldName - Name of the geometry fieldpm - PersistenceManager instance that should be used to access the datastorenull.public Rectangle2D estimateBoundsFromDatastoreMetadata(Class pc, String fieldName, javax.jdo.PersistenceManager pm)
Returns the (estimated) spatial extent, also called bounding box from datastore metadata for the
given geometry field. Will return null, if the datastore doesn't support such an operation
(e.g. MySQL) or if there is no metadata in the datastore available for the given class and field name.
pc - The persistable classfieldName - Name of the geometry fieldpm - PersistenceManager instance that should be used to access the datastorenull.public Rectangle2D calculateBoundsInDatastore(Class pc, String fieldName, javax.jdo.PersistenceManager pm)
public String getCrsWktForSrid(Class pc, int srid, javax.jdo.PersistenceManager pm)
null, if the datastore doesn't support such an operation (e.g. MySQL)
or if there is no metadata in the datastore available for the given class and srid.pc - The persistable classsrid - The sridpm - PersistenceManager instance that should be used to access the datastorenull.public String getCrsNameForSrid(Class pc, int srid, javax.jdo.PersistenceManager pm)
null, if the datastore doesn't support such an operation (e.g. MySQL) or if there is no
metadata in the datastore available for the given class and srid.pc - The persistable classsrid - The sridpm - PersistenceManager instance that should be used to access the datastorenull.protected Integer getIntegerFromJdoMetadata(Class pc, String fieldName, String extensionKey)
protected String getValueFromJdoMetadata(Class pc, String memberName, String extensionKey)
public String[] getGeometryColumnBackedFields(Class pc)
pc - The persistable classnull.public boolean isGeometryColumnBackedField(Class pc, String fieldName)
pc - The persistable classfieldName - Name of the fieldtrue, if the field is backed by a geometry column, false otherwise.protected boolean isGeometryColumnBackedField(org.datanucleus.store.rdbms.table.Column c)
protected org.datanucleus.store.rdbms.table.Table getTable(Class pc)
protected org.datanucleus.store.rdbms.table.Column getColumn(Class pc, org.datanucleus.metadata.AbstractMemberMetaData mmd)
protected SpatialRDBMSAdapter getAdapter() throws ClassCastException
ClassCastExceptionprotected org.datanucleus.metadata.MetaDataManager getMetaDataManager()
protected void checkValid(Class pc, String fieldName) throws IllegalArgumentException, NullPointerException
Copyright © 2015. All rights reserved.