|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectFactory
ReferencingFactory
AbstractAuthorityFactory
DirectAuthorityFactory
DirectEpsgFactory
@ThreadSafe public class DirectEpsgFactory
A CRS authority 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 accepts names as well as numerical identifiers. For example
"NTF (Paris) / France I" and "27581" both fetch 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(String) method.
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.
Because the primary distribution format for the EPSG database is MS-Access, this class uses SQL statements formatted for the MS-Access syntax. For usage with an other database software, a dialect-specific subclass must be used.
ThreadedEpsgFactory,
List of authority codes
| referencing/geotk-referencing (download) | View source code for this class |
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class Factory |
|---|
Factory.Availability, Factory.Organizer |
| Field Summary | |
|---|---|
protected Connection |
connection
The connection to the EPSG database. |
| Fields inherited from class DirectAuthorityFactory |
|---|
factories |
| Fields inherited from class AbstractAuthorityFactory |
|---|
nameFactory |
| Fields inherited from class ReferencingFactory |
|---|
LOGGER |
| Fields inherited from class Factory |
|---|
EMPTY_HINTS, hints |
| Constructor Summary | |
|---|---|
DirectEpsgFactory(Hints userHints,
Connection connection)
Creates a factory using the given connection. |
|
| Method Summary | |
|---|---|
protected String |
adaptSQL(String statement)
Invoked when a new PreparedStatement is about to be created from a SQL string. |
CoordinateOperation |
createCoordinateOperation(String code)
Returns a coordinate operation from a code. |
CoordinateReferenceSystem |
createCoordinateReferenceSystem(String code)
Returns a coordinate reference system from a code. |
CoordinateSystem |
createCoordinateSystem(String code)
Returns a coordinate system from a code. |
CoordinateSystemAxis |
createCoordinateSystemAxis(String code)
Returns a coordinate system axis from a code. |
Datum |
createDatum(String code)
Returns a datum from a code. |
Ellipsoid |
createEllipsoid(String code)
Returns an ellipsoid from a code. |
Extent |
createExtent(String code)
Returns an area of use. |
Set<CoordinateOperation> |
createFromCoordinateReferenceSystemCodes(String sourceCode,
String targetCode)
Creates operations from coordinate reference system codes. |
IdentifiedObject |
createObject(String code)
Returns an arbitrary object from a code. |
OperationMethod |
createOperationMethod(String code)
Returns an operation method from a code. |
ParameterDescriptor<?> |
createParameterDescriptor(String code)
Returns a parameter descriptor from a code. |
PrimeMeridian |
createPrimeMeridian(String code)
Returns a prime meridian, relative to Greenwich. |
Unit<?> |
createUnit(String code)
Returns an unit from a code. |
protected void |
dispose(boolean shutdown)
Closes the JDBC connection used by this factory. |
protected void |
finalize()
Invokes dispose(false) when this factory is garbage collected. |
Citation |
getAuthority()
Returns the authority for this EPSG database. |
Set<String> |
getAuthorityCodes(Class<? extends IdentifiedObject> type)
Returns the set of authority codes of the given type. |
String |
getBackingStoreDescription()
Returns a description of the database engine. |
InternationalString |
getDescriptionText(String code)
Gets a description of the object corresponding to a code. |
IdentifiedObjectFinder |
getIdentifiedObjectFinder(Class<? extends IdentifiedObject> type)
Returns a finder which can be used for looking up unidentified objects. |
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. |
| Methods inherited from class ReferencingFactory |
|---|
ensureNonNull, getVendor |
| Methods inherited from class Factory |
|---|
availability, equals, hasCompatibleHints, hashCode, setOrdering, toString |
| Methods inherited from class Object |
|---|
clone, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface CRSAuthorityFactory |
|---|
createCompoundCRS, createDerivedCRS, createEngineeringCRS, createGeocentricCRS, createGeographicCRS, createImageCRS, createProjectedCRS, createTemporalCRS, createVerticalCRS |
| Methods inherited from interface CSAuthorityFactory |
|---|
createCartesianCS, createCylindricalCS, createEllipsoidalCS, createPolarCS, createSphericalCS, createTimeCS, createVerticalCS |
| Methods inherited from interface DatumAuthorityFactory |
|---|
createEngineeringDatum, createGeodeticDatum, createImageDatum, createTemporalDatum, createVerticalDatum |
| Methods inherited from interface Factory |
|---|
getVendor |
| Field Detail |
|---|
protected final Connection connection
dispose(boolean) method, or when this
DirectEpsgFactory instance if garbage collected.
| Constructor Detail |
|---|
public DirectEpsgFactory(Hints userHints,
Connection connection)
Note: we recommend to avoid keeping the connection open for a long time. An easy
way to get the connection created only when first needed and closed automatically after
a short timeout is to instantiate this DirectEpsgFactory class only in a
ThreadedAuthorityFactory. This approach also
gives concurrency and caching services in bonus.
userHints - The underlying factories used for objects creation,
or null for the default ones.connection - The connection to the underlying EPSG database.| Method Detail |
|---|
public Citation getAuthority()
getAuthority in interface AuthorityFactorygetAuthority in class AbstractAuthorityFactory
public String getBackingStoreDescription()
throws FactoryException
getBackingStoreDescription in class AbstractAuthorityFactorynull.
FactoryException - if the database's metadata can't be fetched.public Map<RenderingHints.Key,?> getImplementationHints()
VERSION.
getImplementationHints in class DirectAuthorityFactory
public Set<String> getAuthorityCodes(Class<? extends IdentifiedObject> type)
throws 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(type).containsAll(others)
getAuthorityCodes in interface AuthorityFactorytype - The spatial reference objects type (may be Object.class).
FactoryException - if access to the underlying database failed.
public InternationalString getDescriptionText(String code)
throws NoSuchAuthorityCodeException,
FactoryException
getDescriptionText in interface AuthorityFactorycode - 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 createObject(String code)
throws NoSuchAuthorityCodeException,
FactoryException
createCoordinateReferenceSystem,
createCoordinateSystem, createDatum,
createEllipsoid, or createUnit methods
according the object type.
createObject in interface AuthorityFactorycreateObject in class AbstractAuthorityFactorycode - The EPSG value.
NoSuchAuthorityCodeException - if this method can't find the requested code.
FactoryException - if some other kind of failure occurred in the backing
store. This exception usually have SQLException as its cause.
public Unit<?> createUnit(String code)
throws NoSuchAuthorityCodeException,
FactoryException
createUnit in interface CSAuthorityFactorycreateUnit in class AbstractAuthorityFactorycode - Value allocated by authority.
NoSuchAuthorityCodeException - if this method can't find the requested code.
FactoryException - if some other kind of failure occurred in the backing
store. This exception usually have SQLException as its cause.
public Ellipsoid createEllipsoid(String code)
throws NoSuchAuthorityCodeException,
FactoryException
createEllipsoid in interface DatumAuthorityFactorycreateEllipsoid in class AbstractAuthorityFactorycode - The EPSG value.
NoSuchAuthorityCodeException - if this method can't find the requested code.
FactoryException - if some other kind of failure occurred in the backing
store. This exception usually have SQLException as its cause.
public PrimeMeridian createPrimeMeridian(String code)
throws NoSuchAuthorityCodeException,
FactoryException
createPrimeMeridian in interface DatumAuthorityFactorycreatePrimeMeridian in class AbstractAuthorityFactorycode - Value allocated by authority.
NoSuchAuthorityCodeException - if this method can't find the requested code.
FactoryException - if some other kind of failure occurred in the backing
store. This exception usually have SQLException as its cause.
public Extent createExtent(String code)
throws NoSuchAuthorityCodeException,
FactoryException
createExtent in class AbstractAuthorityFactorycode - Value allocated by authority.
NoSuchAuthorityCodeException - if this method can't find the requested code.
FactoryException - if some other kind of failure occurred in the backing
store. This exception usually have SQLException as its cause.
public Datum createDatum(String code)
throws NoSuchAuthorityCodeException,
FactoryException
createDatum in interface DatumAuthorityFactorycreateDatum in class AbstractAuthorityFactorycode - Value allocated by authority.
NoSuchAuthorityCodeException - if this method can't find the requested code.
FactoryException - if some other kind of failure occurred in the backing
store. This exception usually have SQLException as its cause.VerticalDatumType.GEOIDAL. We don't know yet how
to maps the exact vertical datum type from the EPSG database.
public CoordinateSystemAxis createCoordinateSystemAxis(String code)
throws NoSuchAuthorityCodeException,
FactoryException
createCoordinateSystemAxis in interface CSAuthorityFactorycreateCoordinateSystemAxis in class AbstractAuthorityFactorycode - Value allocated by authority.
NoSuchAuthorityCodeException - if the specified code was not found.
FactoryException - if the object creation failed for some other reason.
public CoordinateSystem createCoordinateSystem(String code)
throws NoSuchAuthorityCodeException,
FactoryException
createCoordinateSystem in interface CSAuthorityFactorycreateCoordinateSystem in class AbstractAuthorityFactorycode - Value allocated by authority.
NoSuchAuthorityCodeException - if this method can't find the requested code.
FactoryException - if some other kind of failure occurred in the backing
store. This exception usually have SQLException as its cause.
public CoordinateReferenceSystem createCoordinateReferenceSystem(String code)
throws NoSuchAuthorityCodeException,
FactoryException
createCoordinateReferenceSystem in interface CRSAuthorityFactorycreateCoordinateReferenceSystem in class AbstractAuthorityFactorycode - Value allocated by authority.
NoSuchAuthorityCodeException - if this method can't find the requested code.
FactoryException - if some other kind of failure occurred in the backing
store. This exception usually have SQLException as its cause.
public ParameterDescriptor<?> createParameterDescriptor(String code)
throws NoSuchAuthorityCodeException,
FactoryException
createParameterDescriptor in class AbstractAuthorityFactorycode - 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 occurred in the backing
store. This exception usually have SQLException as its cause.
public OperationMethod createOperationMethod(String code)
throws NoSuchAuthorityCodeException,
FactoryException
createOperationMethod in interface CoordinateOperationAuthorityFactorycreateOperationMethod in class AbstractAuthorityFactorycode - 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 occurred in the backing
store. This exception usually have SQLException as its cause.
public CoordinateOperation createCoordinateOperation(String code)
throws NoSuchAuthorityCodeException,
FactoryException
createCoordinateOperation in interface CoordinateOperationAuthorityFactorycreateCoordinateOperation in class AbstractAuthorityFactorycode - Value allocated by authority.
NoSuchAuthorityCodeException - if this method can't find the requested code.
FactoryException - if some other kind of failure occurred in the backing
store. This exception usually have SQLException as its cause.
public Set<CoordinateOperation> createFromCoordinateReferenceSystemCodes(String sourceCode,
String targetCode)
throws FactoryException
createFromCoordinateReferenceSystemCodes in interface CoordinateOperationAuthorityFactorycreateFromCoordinateReferenceSystemCodes in class AbstractAuthorityFactorysourceCode - Coded value of source coordinate reference system.targetCode - Coded value of target coordinate reference system.
sourceCRS to targetCRS.
FactoryException - if the object creation failed.
public IdentifiedObjectFinder getIdentifiedObjectFinder(Class<? extends IdentifiedObject> type)
throws FactoryException
getIdentifiedObjectFinder in class AbstractAuthorityFactorytype - The type of objects to look for.
FactoryException - if the finder can not be created.protected 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 a syntax specific to this particular database
software (for example "SELECT * FROM [Coordinate Reference System]"). When a
subclass targets another database vendor, it must overrides this method in order to adapt
the local SQL syntax. For example a subclass connecting to a PostgreSQL
database could replace the watching braces ('[' and ']') by the quote
character ('"').
The default implementation returns the given statement unchanged.
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
does not need to check 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 occurred while inspecting the code.protected void dispose(boolean shutdown)
dispose in class AbstractAuthorityFactoryshutdown - false for normal disposal, or true if
this method is invoked during the process of a JVM shutdown.protected final void finalize()
dispose(false) when this factory is garbage collected.
finalize in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||