|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.geotools.factory.AbstractFactory
org.geotools.referencing.factory.ReferencingFactory
org.geotools.referencing.factory.AbstractAuthorityFactory
org.geotools.referencing.factory.DirectAuthorityFactory
org.geotools.referencing.factory.epsg.DirectEpsgFactory
public abstract class DirectEpsgFactory
A coordinate reference system factory backed by the EPSG database tables.
The EPSG database is freely available at http://www.epsg.org. Current version of this class requires EPSG database version 6.6 or above.
This factory doesn't cache any result. Any call to a createFoo
method will send a new
query to the EPSG database. For caching, this factory should be wrapped in some buffered factory
like ThreadedEpsgFactory
.
This class is abstract - please see the subclasses for dialect specific implementations:
These factories accepts names as well as numerical identifiers. For example "NTF (Paris) / France I" and"27581"
both fetchs the same object.
However, names may be ambiguous since the same name may be used for more than one object.
This is the case of "WGS 84" for example. If such an ambiguity is found, an exception
will be thrown. If names are not wanted as a legal EPSG code, subclasses can override the
isPrimaryKey(java.lang.String)
method.
Field Summary |
---|
Fields inherited from class org.geotools.referencing.factory.DirectAuthorityFactory |
---|
factories |
Fields inherited from class org.geotools.referencing.factory.ReferencingFactory |
---|
LOGGER |
Fields inherited from class org.geotools.factory.AbstractFactory |
---|
hints, MAXIMUM_PRIORITY, MINIMUM_PRIORITY, NORMAL_PRIORITY, priority |
Constructor Summary | |
---|---|
DirectEpsgFactory(Hints userHints,
java.sql.Connection connection)
Constructs an authority factory using the specified connection. |
|
DirectEpsgFactory(Hints userHints,
javax.sql.DataSource dataSource)
Constructs an authority factory using the specified connection. |
Method Summary | |
---|---|
protected abstract java.lang.String |
adaptSQL(java.lang.String statement)
Invoked when a new PreparedStatement is about to be created from a SQL string. |
org.opengis.referencing.operation.CoordinateOperation |
createCoordinateOperation(java.lang.String code)
Returns a coordinate operation from a code. |
org.opengis.referencing.crs.CoordinateReferenceSystem |
createCoordinateReferenceSystem(java.lang.String code)
Returns a coordinate reference system from a code. |
org.opengis.referencing.cs.CoordinateSystem |
createCoordinateSystem(java.lang.String code)
Returns a coordinate system from a code. |
org.opengis.referencing.cs.CoordinateSystemAxis |
createCoordinateSystemAxis(java.lang.String code)
Returns a coordinate system axis from a code. |
org.opengis.referencing.datum.Datum |
createDatum(java.lang.String code)
Returns a datum from a code. |
org.opengis.referencing.datum.Ellipsoid |
createEllipsoid(java.lang.String code)
Returns an ellipsoid from a code. |
org.opengis.metadata.extent.Extent |
createExtent(java.lang.String code)
Returns an area of use. |
java.util.Set |
createFromCoordinateReferenceSystemCodes(java.lang.String sourceCode,
java.lang.String targetCode)
Creates operations from coordinate reference system codes. |
org.opengis.referencing.IdentifiedObject |
createObject(java.lang.String code)
Returns an arbitrary object from a code. |
org.opengis.referencing.operation.OperationMethod |
createOperationMethod(java.lang.String code)
Returns an operation method from a code. |
org.opengis.parameter.ParameterDescriptor |
createParameterDescriptor(java.lang.String code)
Returns a parameter descriptor from a code. |
org.opengis.referencing.datum.PrimeMeridian |
createPrimeMeridian(java.lang.String code)
Returns a prime meridian, relative to Greenwich. |
javax.measure.unit.Unit<?> |
createUnit(java.lang.String code)
Returns an unit from a code. |
void |
dispose()
Disposes any resources hold by this object. |
protected void |
finalize()
Invokes dispose() when this factory is garbage collected. |
org.opengis.metadata.citation.Citation |
getAuthority()
Returns the authority for this EPSG database. |
java.util.Set<java.lang.String> |
getAuthorityCodes(java.lang.Class<? extends org.opengis.referencing.IdentifiedObject> type)
Returns the set of authority codes of the given type. |
java.lang.String |
getBackingStoreDescription()
Returns a description of the database engine. |
protected java.sql.Connection |
getConnection()
Access to the connection used by this EpsgFactory. |
org.opengis.util.InternationalString |
getDescriptionText(java.lang.String code)
Gets a description of the object corresponding to a code. |
IdentifiedObjectFinder |
getIdentifiedObjectFinder(java.lang.Class type)
Returns a finder which can be used for looking up unidentified objects. |
java.util.Map<java.awt.RenderingHints.Key,?> |
getImplementationHints()
Returns the implementation hints for this factory. |
java.lang.String |
getValidationQuery()
Returns the current validation query |
protected boolean |
isConnectionValid(java.sql.Connection conn)
Tests if the connection is valid by running the user provided validation query, if any. |
protected boolean |
isPrimaryKey(java.lang.String code)
Returns true if the specified code may be a primary key in some table. |
void |
setValidationQuery(java.lang.String validationQuery)
Sets the query it's run before using connection and prepared statements in order to check the connection is still valid. |
protected void |
shutdown(boolean active)
Shutdown the database engine. |
Methods inherited from class org.geotools.referencing.factory.AbstractAuthorityFactory |
---|
createCartesianCS, createCompoundCRS, createCylindricalCS, createDerivedCRS, createEllipsoidalCS, createEngineeringCRS, createEngineeringDatum, createGeocentricCRS, createGeodeticDatum, createGeographicCRS, createImageCRS, createImageDatum, createPolarCS, createProjectedCRS, createSphericalCS, createTemporalCRS, createTemporalDatum, createTimeCS, createVerticalCRS, createVerticalCS, createVerticalDatum, noSuchAuthorityCode, trimAuthority |
Methods inherited from class org.geotools.referencing.factory.ReferencingFactory |
---|
ensureNonNull, getVendor |
Methods inherited from class org.geotools.factory.AbstractFactory |
---|
addImplementationHints, equals, getPriority, hashCode, onDeregistration, onRegistration, toString |
Methods inherited from class java.lang.Object |
---|
clone, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.opengis.referencing.crs.CRSAuthorityFactory |
---|
createCompoundCRS, createDerivedCRS, createEngineeringCRS, createGeocentricCRS, createGeographicCRS, createImageCRS, createProjectedCRS, createTemporalCRS, createVerticalCRS |
Methods inherited from interface org.opengis.referencing.cs.CSAuthorityFactory |
---|
createCartesianCS, createCylindricalCS, createEllipsoidalCS, createPolarCS, createSphericalCS, createTimeCS, createVerticalCS |
Methods inherited from interface org.opengis.referencing.datum.DatumAuthorityFactory |
---|
createEngineeringDatum, createGeodeticDatum, createImageDatum, createTemporalDatum, createVerticalDatum |
Methods inherited from interface org.opengis.referencing.Factory |
---|
getVendor |
Constructor Detail |
---|
public DirectEpsgFactory(Hints userHints, java.sql.Connection connection)
userHints
- The underlying factories used for objects creation.connection
- The connection to the underlying EPSG database.public DirectEpsgFactory(Hints userHints, javax.sql.DataSource dataSource)
userHints
- The underlying factories used for objects creation.dataSource
- The data source connecting to the underlying EPSG databaseMethod Detail |
---|
public org.opengis.metadata.citation.Citation getAuthority()
getAuthority
in interface org.opengis.referencing.AuthorityFactory
getAuthority
in class AbstractAuthorityFactory
public java.lang.String getBackingStoreDescription() throws org.opengis.referencing.FactoryException
getBackingStoreDescription
in class AbstractAuthorityFactory
null
.
org.opengis.referencing.FactoryException
- if the database's metadata can't be fetched.public java.util.Map<java.awt.RenderingHints.Key,?> getImplementationHints()
VERSION
.
getImplementationHints
in interface Factory
getImplementationHints
in class DirectAuthorityFactory
public java.util.Set<java.lang.String> getAuthorityCodes(java.lang.Class<? extends org.opengis.referencing.IdentifiedObject> type) throws org.opengis.referencing.FactoryException
NOTE: This method returns a living connection to the underlying database. This means that the returned set can executes efficiently idioms like the following one:
But do not keep the returned reference for a long time. The returned set should stay valid even if retained for a long time (as long as this factory has not been disposed), but the existence of those long-living connections may prevent this factory to release some resources. If the set of codes is needed for a long time, copy their values in an other collection object.getAuthorityCodes(typeothers)
getAuthorityCodes
in interface org.opengis.referencing.AuthorityFactory
type
- The spatial reference objects type (may be Object.class
).
org.opengis.referencing.FactoryException
- if access to the underlying database failed.public org.opengis.util.InternationalString getDescriptionText(java.lang.String code) throws org.opengis.referencing.FactoryException
getDescriptionText
in interface org.opengis.referencing.AuthorityFactory
code
- Value allocated by authority.
null
if the object
corresponding to the specified code
has no description.
org.opengis.referencing.NoSuchAuthorityCodeException
- if the specified code
was not found.
org.opengis.referencing.FactoryException
- if the query failed for some other reason.public org.opengis.referencing.IdentifiedObject createObject(java.lang.String code) throws org.opengis.referencing.FactoryException
createCoordinateReferenceSystem(java.lang.String)
,
createCoordinateSystem(java.lang.String)
, createDatum(java.lang.String)
, createEllipsoid(java.lang.String)
, or
createUnit(java.lang.String)
methods according the object type.
createObject
in interface org.opengis.referencing.AuthorityFactory
createObject
in class AbstractAuthorityFactory
code
- The EPSG value.
org.opengis.referencing.NoSuchAuthorityCodeException
- if this method can't find the requested code.
org.opengis.referencing.FactoryException
- if some other kind of failure occured in the backing
store. This exception usually have SQLException
as its cause.AbstractAuthorityFactory.createCoordinateReferenceSystem(java.lang.String)
,
AbstractAuthorityFactory.createDatum(java.lang.String)
,
AbstractAuthorityFactory.createEllipsoid(java.lang.String)
,
AbstractAuthorityFactory.createUnit(java.lang.String)
public javax.measure.unit.Unit<?> createUnit(java.lang.String code) throws org.opengis.referencing.FactoryException
createUnit
in interface org.opengis.referencing.cs.CSAuthorityFactory
createUnit
in class AbstractAuthorityFactory
code
- Value allocated by authority.
org.opengis.referencing.NoSuchAuthorityCodeException
- if this method can't find the requested code.
org.opengis.referencing.FactoryException
- if some other kind of failure occured in the backing
store. This exception usually have SQLException
as its cause.public org.opengis.referencing.datum.Ellipsoid createEllipsoid(java.lang.String code) throws org.opengis.referencing.FactoryException
createEllipsoid
in interface org.opengis.referencing.datum.DatumAuthorityFactory
createEllipsoid
in class AbstractAuthorityFactory
code
- The EPSG value.
org.opengis.referencing.NoSuchAuthorityCodeException
- if this method can't find the requested code.
org.opengis.referencing.FactoryException
- if some other kind of failure occured in the backing
store. This exception usually have SQLException
as its cause.AbstractAuthorityFactory.createGeodeticDatum(java.lang.String)
public org.opengis.referencing.datum.PrimeMeridian createPrimeMeridian(java.lang.String code) throws org.opengis.referencing.FactoryException
createPrimeMeridian
in interface org.opengis.referencing.datum.DatumAuthorityFactory
createPrimeMeridian
in class AbstractAuthorityFactory
code
- Value allocated by authority.
org.opengis.referencing.NoSuchAuthorityCodeException
- if this method can't find the requested code.
org.opengis.referencing.FactoryException
- if some other kind of failure occured in the backing
store. This exception usually have SQLException
as its cause.AbstractAuthorityFactory.createGeodeticDatum(java.lang.String)
public org.opengis.metadata.extent.Extent createExtent(java.lang.String code) throws org.opengis.referencing.FactoryException
createExtent
in class AbstractAuthorityFactory
code
- Value allocated by authority.
org.opengis.referencing.NoSuchAuthorityCodeException
- if this method can't find the requested code.
org.opengis.referencing.FactoryException
- if some other kind of failure occured in the backing
store. This exception usually have SQLException
as its cause.public org.opengis.referencing.datum.Datum createDatum(java.lang.String code) throws org.opengis.referencing.FactoryException
createDatum
in interface org.opengis.referencing.datum.DatumAuthorityFactory
createDatum
in class AbstractAuthorityFactory
code
- Value allocated by authority.
org.opengis.referencing.NoSuchAuthorityCodeException
- if this method can't find the requested code.
org.opengis.referencing.FactoryException
- if some other kind of failure occured in the backing
store. This exception usually have SQLException
as its cause.AbstractAuthorityFactory.createGeodeticDatum(java.lang.String)
,
AbstractAuthorityFactory.createVerticalDatum(java.lang.String)
,
AbstractAuthorityFactory.createTemporalDatum(java.lang.String)
public org.opengis.referencing.cs.CoordinateSystemAxis createCoordinateSystemAxis(java.lang.String code) throws org.opengis.referencing.FactoryException
createCoordinateSystemAxis
in interface org.opengis.referencing.cs.CSAuthorityFactory
createCoordinateSystemAxis
in class AbstractAuthorityFactory
code
- Value allocated by authority.
org.opengis.referencing.NoSuchAuthorityCodeException
- if the specified code
was not found.
org.opengis.referencing.FactoryException
- if the object creation failed for some other reason.public org.opengis.referencing.cs.CoordinateSystem createCoordinateSystem(java.lang.String code) throws org.opengis.referencing.FactoryException
createCoordinateSystem
in interface org.opengis.referencing.cs.CSAuthorityFactory
createCoordinateSystem
in class AbstractAuthorityFactory
code
- Value allocated by authority.
org.opengis.referencing.NoSuchAuthorityCodeException
- if this method can't find the requested code.
org.opengis.referencing.FactoryException
- if some other kind of failure occured in the backing
store. This exception usually have SQLException
as its cause.public org.opengis.referencing.crs.CoordinateReferenceSystem createCoordinateReferenceSystem(java.lang.String code) throws org.opengis.referencing.FactoryException
createCoordinateReferenceSystem
in interface org.opengis.referencing.crs.CRSAuthorityFactory
createCoordinateReferenceSystem
in class AbstractAuthorityFactory
code
- Value allocated by authority.
org.opengis.referencing.NoSuchAuthorityCodeException
- if this method can't find the requested code.
org.opengis.referencing.FactoryException
- if some other kind of failure occured in the backing
store. This exception usually have SQLException
as its cause.AbstractAuthorityFactory.createGeographicCRS(java.lang.String)
,
AbstractAuthorityFactory.createProjectedCRS(java.lang.String)
,
AbstractAuthorityFactory.createVerticalCRS(java.lang.String)
,
AbstractAuthorityFactory.createTemporalCRS(java.lang.String)
,
AbstractAuthorityFactory.createCompoundCRS(java.lang.String)
public org.opengis.parameter.ParameterDescriptor createParameterDescriptor(java.lang.String code) throws org.opengis.referencing.FactoryException
createParameterDescriptor
in class AbstractAuthorityFactory
code
- The parameter descriptor code allocated by EPSG authority.
org.opengis.referencing.NoSuchAuthorityCodeException
- if this method can't find the requested code.
org.opengis.referencing.FactoryException
- if some other kind of failure occured in the backing
store. This exception usually have SQLException
as its cause.public org.opengis.referencing.operation.OperationMethod createOperationMethod(java.lang.String code) throws org.opengis.referencing.FactoryException
createOperationMethod
in class AbstractAuthorityFactory
code
- The operation method code allocated by EPSG authority.
org.opengis.referencing.NoSuchAuthorityCodeException
- if this method can't find the requested code.
org.opengis.referencing.FactoryException
- if some other kind of failure occured in the backing
store. This exception usually have SQLException
as its cause.public org.opengis.referencing.operation.CoordinateOperation createCoordinateOperation(java.lang.String code) throws org.opengis.referencing.FactoryException
createCoordinateOperation
in interface org.opengis.referencing.operation.CoordinateOperationAuthorityFactory
createCoordinateOperation
in class AbstractAuthorityFactory
code
- Value allocated by authority.
org.opengis.referencing.NoSuchAuthorityCodeException
- if this method can't find the requested code.
org.opengis.referencing.FactoryException
- if some other kind of failure occured in the backing
store. This exception usually have SQLException
as its cause.public java.util.Set createFromCoordinateReferenceSystemCodes(java.lang.String sourceCode, java.lang.String targetCode) throws org.opengis.referencing.FactoryException
createFromCoordinateReferenceSystemCodes
in interface org.opengis.referencing.operation.CoordinateOperationAuthorityFactory
createFromCoordinateReferenceSystemCodes
in class AbstractAuthorityFactory
sourceCode
- Coded value of source coordinate reference system.targetCode
- Coded value of target coordinate reference system.
sourceCRS
to targetCRS
.
org.opengis.referencing.FactoryException
- if the object creation failed.public IdentifiedObjectFinder getIdentifiedObjectFinder(java.lang.Class type) throws org.opengis.referencing.FactoryException
getIdentifiedObjectFinder
in class AbstractAuthorityFactory
type
- The type of objects to look for.
org.opengis.referencing.FactoryException
- if the finder can not be created.protected abstract java.lang.String adaptSQL(java.lang.String statement)
PreparedStatement
is about to be created from a SQL string.
Since the EPSG database is available mainly in MS-Access
format, SQL statements are formatted using some syntax specific to this particular database
software (for example "SELECT * FROM [Coordinate Reference System]
"). When
prociding subclass targeting another database vendor, then this method should be overridden
in order to adapt the local SQL syntax.
For example a subclass connecting to a PostgreSQL database could replace all spaces (" ") between watching braces ("[" and "]") by underscore ("_").
statement
- The statement in MS-Access syntax.
protected boolean isPrimaryKey(java.lang.String code) throws org.opengis.referencing.FactoryException
true
if the specified code may be a primary key in some table. This method
do not needs to checks any entry in the database. It should just checks from the syntax if
the code looks like a valid EPSG identifier. The default implementation returns true
if all non-space characters are digits.
When this method returns false
, some createFoo(...)
methods look for the
code in the name column instead of the primary key column. This allows to accept the
"NTF (Paris) / France I" string (for example) in addition to the "27581"
primary key. Both should fetch the same object.
If this method returns true
in all cases, then this factory never search for matching
names. In such case, an appropriate exception will be thrown in createFoo(...)
methods if the code is not found in the primary key column. Subclasses can overrides this
method that way if this is the intended behavior.
code
- The code the inspect.
true
if the code is probably a primary key.
org.opengis.referencing.FactoryException
- if an unexpected error occured while inspecting the code.public void dispose() throws org.opengis.referencing.FactoryException
dispose
in class AbstractAuthorityFactory
org.opengis.referencing.FactoryException
- if an error occured while closing the connection.protected void shutdown(boolean active) throws java.sql.SQLException
ThreadedEpsgFactory
at JVM shutdown: one time before the connection is closed, and a second
time after. This shutdown hook is usefull for embedded database engine
starting a server process in addition to the client process. Just closing the connection
is not enough for them. Example:
"SHUTDOWN"
statement using the
connection before it is closed.The default implementation does nothing, which is suffisient for implementations connecting to a distant server (i.e. non-embedded database engine), for example MS-Access or PostgreSQL.
active
- true
if the connection is alive, or false
otherwise. This method is invoked first with active
set to true
,
then a second time with active
set to false
.
java.sql.SQLException
- if this method failed to shutdown the database engine.protected final void finalize() throws java.lang.Throwable
dispose()
when this factory is garbage collected.
finalize
in class java.lang.Object
java.lang.Throwable
- if an error occured while closing the connection.protected java.sql.Connection getConnection() throws java.sql.SQLException
java.sql.SQLException
protected boolean isConnectionValid(java.sql.Connection conn)
conn
- The connection to be validated
public java.lang.String getValidationQuery()
public void setValidationQuery(java.lang.String validationQuery)
validationQuery
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |