|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.geotools.factory.AbstractFactory org.geotools.referencing.factory.AbstractFactory org.geotools.referencing.factory.AbstractAuthorityFactory org.geotools.referencing.factory.epsg.FactoryUsingSQL
Default implementation for a coordinate reference system factory backed by the EPSG database. 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 method will send a new
query to the EPSG database. For caching, this factory should be wrapped in some buffered factory
like DefaultFactory
.
This factory accepts names as well as numerical identifiers. For example
"NTF (Paris) / France I" and 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.
This factory uses the MS-Access dialect of SQL, because the primary distribution format for the
EPSG database is MS-Access. For translating this SQL dialect into an other one, subclasses
should override the adaptSQL(java.lang.String)
method.
Field Summary | |
protected java.sql.Connection |
connection
The connection to the EPSG database. |
Fields inherited from class org.geotools.referencing.factory.AbstractAuthorityFactory |
factories |
Fields inherited from class org.geotools.referencing.factory.AbstractFactory |
LOGGER |
Fields inherited from class org.geotools.factory.AbstractFactory |
hints, MAXIMUM_PRIORITY, MINIMUM_PRIORITY, NORMAL_PRIORITY, priority |
Constructor Summary | |
FactoryUsingSQL(FactoryGroup factories,
java.sql.Connection connection)
Deprecated. Use FactoryUsingSQL(Hints,Connection) instead. |
|
FactoryUsingSQL(Hints hints,
java.sql.Connection connection)
Constructs an authority factory using the specified connection. |
Method Summary | |
protected 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.units.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 |
getAuthorityCodes(java.lang.Class type)
Returns the set of authority codes of the given type. |
java.lang.String |
getBackingStoreDescription()
Returns a description of the database engine. |
org.opengis.util.InternationalString |
getDescriptionText(java.lang.String code)
Gets a description of the object corresponding to a code. |
protected boolean |
isPrimaryKey(java.lang.String code)
Returns if the specified code may be a primary key in some table. |
protected void |
shutdown(boolean active)
Shutdown the database engine. |
Methods inherited from class org.geotools.referencing.factory.AbstractFactory |
ensureNonNull, getVendor |
Methods inherited from class org.geotools.factory.AbstractFactory |
onDeregistration |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.opengis.referencing.Factory |
getVendor |
Field Detail |
protected final java.sql.Connection connection
Constructor Detail |
public FactoryUsingSQL(FactoryGroup factories, java.sql.Connection connection)
FactoryUsingSQL(Hints,Connection)
instead.
factories
- The underlying factories used for objects creation.connection
- The connection to the underlying EPSG database.public FactoryUsingSQL(Hints hints, java.sql.Connection connection)
hints
- The underlying factories used for objects creation.connection
- The connection to the underlying EPSG database.Method 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
org.opengis.referencing.FactoryException
- if the database's metadata can't be fetched.public java.util.Set getAuthorityCodes(java.lang.Class 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)
type
- The spatial reference objects type (may be ).
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
code
- Value allocated by authority.
org.opengis.referencing.NoSuchAuthorityCodeException
- if the specified 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.units.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)
VerticalDatumType.GEOIDAL
. We don't know yet how
to maps the exact vertical datum type from the EPSG database.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 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.
org.opengis.referencing.FactoryException
- if the object creation failed.protected 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]
"). If the
EPSG database is ported to an other software, then this method should be overriden in order
to adapt the 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
When this method returns , some 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 primary key. Both should fetch the same object.
If this method returns in all cases, then this factory never search for matching names. In such case, an appropriate exception will be thrown in 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.
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
DefaultFactory
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:
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
- if the connection is alive, or
otherwise. This method is invoked first with set to ,
then a second time with set to .
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.
java.lang.Throwable
- if an error occured while closing the connection.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |