public abstract class AbstractEpsgFactory extends AbstractCachedAuthorityFactory
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 makes use of a provided ObjectCache
, and may be deployed in stand aline
fashion; or as a worker for a MultiEpsgFactory
.
This class is abstract - please see the subclasses for dialect specific implementations:
AccessDialectEpsgFactory
AnsiDialectEpsgFactory
OracleDialectEpsgFactory
"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.Modifier and Type | Field and Description |
---|---|
protected DataSource |
dataSource
A DataSource to the EPSG database being used.
|
cache, factories
LOGGER
hints, MAXIMUM_PRIORITY, MINIMUM_PRIORITY, NORMAL_PRIORITY, priority
Constructor and Description |
---|
AbstractEpsgFactory(Hints userHints) |
AbstractEpsgFactory(Hints userHints,
Connection connection)
Constructs an authority factory using the specified connection.
|
AbstractEpsgFactory(Hints userHints,
DataSource dataSource) |
Modifier and Type | Method and Description |
---|---|
protected abstract String |
adaptSQL(String statement)
Invoked when a new
PreparedStatement is about to be created from a SQL string. |
void |
connect()
Connect to the database in anticipation of of use.
|
void |
disconnect()
Disconnect from the database, and remain idle.
|
void |
dispose()
Disposes any resources hold by this object.
|
protected void |
finalize()
Invokes
dispose() when this factory is garbage collected. |
protected Set<String> |
generateAuthorityCodes(Class type)
Returns the set of authority codes of the given type.
|
CoordinateOperation |
generateCoordinateOperation(String code)
Returns a coordinate operation from a code.
|
CoordinateReferenceSystem |
generateCoordinateReferenceSystem(String code)
Returns a coordinate reference system from a code.
|
CoordinateSystem |
generateCoordinateSystem(String code)
Returns a coordinate system from a code.
|
CoordinateSystemAxis |
generateCoordinateSystemAxis(String code)
Returns a coordinate system axis from a code.
|
Datum |
generateDatum(String code)
Returns a datum from a code.
|
Ellipsoid |
generateEllipsoid(String code)
Returns an ellipsoid from a code.
|
Extent |
generateExtent(String code)
Returns an area of use.
|
Set |
generateFromCoordinateReferenceSystemCodes(String sourceCode,
String targetCode)
Creates operations from coordinate reference system codes.
|
IdentifiedObject |
generateObject(String code)
Returns an arbitrary object from a code.
|
OperationMethod |
generateOperationMethod(String code)
Returns an operation method from a code.
|
ParameterDescriptor |
generateParameterDescriptor(String code)
Returns a parameter descriptor from a code.
|
PrimeMeridian |
generatePrimeMeridian(String code)
Returns a prime meridian, relative to Greenwich.
|
Unit<?> |
generateUnit(String code)
Returns an unit from a code.
|
Citation |
getAuthority()
Returns the authority for this EPSG database.
|
String |
getBackingStoreDescription()
Returns a description of the database engine.
|
protected Connection |
getConnection()
Access to the connection used by this EpsgFactory.
|
InternationalString |
getDescriptionText(String code)
Gets a description of the object corresponding to a code.
|
Map<RenderingHints.Key,?> |
getImplementationHints()
Returns the implementation hints for this factory.
|
protected boolean |
isPrimaryKey(String code)
Returns
true if the specified code may be a primary key in some table. |
protected void |
shutdown(boolean active)
Shutdown the database engine.
|
createCartesianCS, createCompoundCRS, createCoordinateOperation, createCoordinateReferenceSystem, createCoordinateSystem, createCoordinateSystemAxis, createCylindricalCS, createDatum, createDerivedCRS, createEllipsoid, createEllipsoidalCS, createEngineeringCRS, createEngineeringDatum, createFromCoordinateReferenceSystemCodes, createGeocentricCRS, createGeodeticDatum, createGeographicCRS, createImageCRS, createImageDatum, createObject, createPolarCS, createPrimeMeridian, createProjectedCRS, createSphericalCS, createTemporalCRS, createTemporalDatum, createTimeCS, createUnit, createVerticalCRS, createVerticalCS, createVerticalDatum, getAuthorityCodes, getIdentifiedObjectFinder, noSuchAuthorityCode, toKey, trimAuthority
createExtent, createOperationMethod, createParameterDescriptor, noSuchAuthorityCode
ensureNonNull, getVendor
addImplementationHints, equals, getPriority, hashCode, onDeregistration, onRegistration, toString
protected DataSource dataSource
public AbstractEpsgFactory(Hints userHints) throws FactoryException
FactoryException
public AbstractEpsgFactory(Hints userHints, DataSource dataSource)
public AbstractEpsgFactory(Hints userHints, Connection connection)
userHints
- The underlying factories used for objects creation.connection
- The connection to the underlying EPSG database.public Citation getAuthority()
getAuthority
in interface AuthorityFactory
getAuthority
in class AbstractCachedAuthorityFactory
public String getBackingStoreDescription() throws FactoryException
getBackingStoreDescription
in class AbstractAuthorityFactory
null
.FactoryException
- if the database's metadata can't be fetched.public Map<RenderingHints.Key,?> getImplementationHints()
VERSION
.getImplementationHints
in interface Factory
getImplementationHints
in class AbstractFactory
protected Set<String> generateAuthorityCodes(Class type) throws FactoryException
generateAuthorityCodes
in class AbstractCachedAuthorityFactory
type
- The spatial reference objects type (may be Object.class
).FactoryException
- if access to the underlying database failed.public InternationalString getDescriptionText(String code) throws FactoryException
getDescriptionText
in interface AuthorityFactory
getDescriptionText
in class AbstractCachedAuthorityFactory
code
- Value allocated by authority.null
if the object corresponding to the
specified code
has no description.NoSuchAuthorityCodeException
- if the specified code
was not found.FactoryException
- if the query failed for some other reason.public IdentifiedObject generateObject(String code) throws FactoryException
AbstractCachedAuthorityFactory.createCoordinateReferenceSystem(java.lang.String)
, AbstractCachedAuthorityFactory.createCoordinateSystem(java.lang.String)
, AbstractCachedAuthorityFactory.createDatum(java.lang.String)
,
AbstractCachedAuthorityFactory.createEllipsoid(java.lang.String)
, or AbstractCachedAuthorityFactory.createUnit(java.lang.String)
methods according the object type.generateObject
in class AbstractCachedAuthorityFactory
code
- The EPSG value.NoSuchAuthorityCodeException
- if this method can't find the requested code.FactoryException
- if some other kind of failure occured in the backing store. This
exception usually have SQLException
as its cause.public Unit<?> generateUnit(String code) throws FactoryException
generateUnit
in class AbstractCachedAuthorityFactory
code
- Value allocated by authority.NoSuchAuthorityCodeException
- if this method can't find the requested code.FactoryException
- if some other kind of failure occured in the backing store. This
exception usually have SQLException
as its cause.public Ellipsoid generateEllipsoid(String code) throws FactoryException
generateEllipsoid
in class AbstractCachedAuthorityFactory
code
- The EPSG value.NoSuchAuthorityCodeException
- if this method can't find the requested code.FactoryException
- if some other kind of failure occured in the backing store. This
exception usually have SQLException
as its cause.public PrimeMeridian generatePrimeMeridian(String code) throws FactoryException
generatePrimeMeridian
in class AbstractCachedAuthorityFactory
code
- Value allocated by authority.NoSuchAuthorityCodeException
- if this method can't find the requested code.FactoryException
- if some other kind of failure occured in the backing store. This
exception usually have SQLException
as its cause.public Extent generateExtent(String code) throws FactoryException
code
- Value allocated by authority.NoSuchAuthorityCodeException
- if this method can't find the requested code.FactoryException
- if some other kind of failure occured in the backing store. This
exception usually have SQLException
as its cause.public Datum generateDatum(String code) throws FactoryException
generateDatum
in class AbstractCachedAuthorityFactory
code
- Value allocated by authority.NoSuchAuthorityCodeException
- if this method can't find the requested code.FactoryException
- if some other kind of failure occured in the backing store. This
exception usually have SQLException
as its cause.public CoordinateSystemAxis generateCoordinateSystemAxis(String code) throws FactoryException
generateCoordinateSystemAxis
in class AbstractCachedAuthorityFactory
code
- Value allocated by authority.NoSuchAuthorityCodeException
- if the specified code
was not found.FactoryException
- if the object creation failed for some other reason.public CoordinateSystem generateCoordinateSystem(String code) throws FactoryException
generateCoordinateSystem
in class AbstractCachedAuthorityFactory
code
- Value allocated by authority.NoSuchAuthorityCodeException
- if this method can't find the requested code.FactoryException
- if some other kind of failure occured in the backing store. This
exception usually have SQLException
as its cause.public CoordinateReferenceSystem generateCoordinateReferenceSystem(String code) throws FactoryException
generateCoordinateReferenceSystem
in class AbstractCachedAuthorityFactory
code
- Value allocated by authority.NoSuchAuthorityCodeException
- if this method can't find the requested code.FactoryException
- if some other kind of failure occured in the backing store. This
exception usually have SQLException
as its cause.public ParameterDescriptor generateParameterDescriptor(String code) throws FactoryException
code
- The parameter descriptor code allocated by EPSG authority.NoSuchAuthorityCodeException
- if this method can't find the requested code.FactoryException
- if some other kind of failure occured in the backing store. This
exception usually have SQLException
as its cause.public OperationMethod generateOperationMethod(String code) throws FactoryException
code
- The operation method code allocated by EPSG authority.NoSuchAuthorityCodeException
- if this method can't find the requested code.FactoryException
- if some other kind of failure occured in the backing store. This
exception usually have SQLException
as its cause.public CoordinateOperation generateCoordinateOperation(String code) throws FactoryException
generateCoordinateOperation
in class AbstractCachedAuthorityFactory
code
- Value allocated by authority.NoSuchAuthorityCodeException
- if this method can't find the requested code.FactoryException
- if some other kind of failure occured in the backing store. This
exception usually have SQLException
as its cause.public Set generateFromCoordinateReferenceSystemCodes(String sourceCode, String targetCode) throws FactoryException
generateFromCoordinateReferenceSystemCodes
in class AbstractCachedAuthorityFactory
sourceCode
- Coded value of source coordinate reference system.targetCode
- Coded value of target coordinate reference system.FactoryException
- if the object creation failed.protected abstract String adaptSQL(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(String code) throws 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.FactoryException
- if an unexpected error occured while inspecting the code.public void dispose() throws FactoryException
dispose
in class AbstractCachedAuthorityFactory
FactoryException
- if an error occurred while closing the connection.public void connect() throws FactoryException
FactoryException
public void disconnect() throws FactoryException
FactoryException
protected Connection getConnection() throws SQLException
SQLException
protected void shutdown(boolean active) throws SQLException
ThreadedEpsgFactory
at
JVM shutdown: one time before the connection is closed, and a second time
after. This shutdown hook is useful 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 sufficient 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
.SQLException
- if this method failed to shutdown the database engine.Copyright © 1996–2019 Geotools. All rights reserved.