|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectFactory
ReferencingFactory
AbstractAuthorityFactory
DirectAuthorityFactory
WKTParsingAuthorityFactory
DirectPostgisFactory
public class DirectPostgisFactory
An authority factory creating CRS from the "spatial_ref_sys" table in a spatial
SQL database. This class is called DirectPostgisFactory because
of some assumptions more suitable to PostGIS, like the default authority if none were explicitly defined. But this class should be usable with other OGC
compliant spatial database as well.
This factory doesn't cache any result. Any call to a createFoo method will
trig a new WKT parsing. For adding caching service, this factory needs to be wrapped
in a CachingAuthorityFactory instance. The
AuthorityFactoryProvider
convenience class can be used for that purpose.
| 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 | |
|---|---|
static String |
AUTHORITY_COLUMN
The standard name ("auth_name") of the column containing the authority names. |
static String |
CODE_COLUMN
The standard name ("auth_srid") of the column containing the authority codes. |
static String |
PRIMARY_KEY
The primary key column, which is "srid". |
static String |
TABLE
The standard name of the table containing CRS definitions, which is "spatial_ref_sys". |
static String |
WKT_COLUMN
The standard name ("srtext") of the column containing the WKT definitions. |
| 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 | |
|---|---|
DirectPostgisFactory(Hints hints,
Connection connection)
Creates a factory using the given connection. |
|
| Method Summary | |
|---|---|
protected void |
dispose(boolean shutdown)
Closes the JDBC connection used by this factory. |
Set<String> |
getAuthorityCodes(Class<? extends IdentifiedObject> category)
Returns the authority codes defined in the database for the given type. |
String |
getBackingStoreDescription()
Returns a description of the underlying backing store. |
Integer |
getPrimaryKey(Class<? extends IdentifiedObject> type,
String code)
Returns the primary key for the specified authority code. |
Citation |
getPrimaryKeyAuthority()
Returns the authority which is responsible for the maintenance of the primary keys. |
| Methods inherited from class WKTParsingAuthorityFactory |
|---|
availability, createCoordinateReferenceSystem, createObject, getAuthority, getDescriptionText, getIdentifiedObjectFinder, trimAuthority |
| Methods inherited from class DirectAuthorityFactory |
|---|
getImplementationHints |
| Methods inherited from class ReferencingFactory |
|---|
ensureNonNull, getVendor |
| Methods inherited from class Factory |
|---|
equals, hasCompatibleHints, hashCode, setOrdering, toString |
| Methods inherited from class Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface CRSAuthorityFactory |
|---|
createCompoundCRS, createCoordinateReferenceSystem, createDerivedCRS, createEngineeringCRS, createGeocentricCRS, createGeographicCRS, createImageCRS, createProjectedCRS, createTemporalCRS, createVerticalCRS |
| Methods inherited from interface AuthorityFactory |
|---|
createObject, getAuthority, getDescriptionText |
| Methods inherited from interface Factory |
|---|
getVendor |
| Field Detail |
|---|
public static final String TABLE
public static final String PRIMARY_KEY
public static final String AUTHORITY_COLUMN
public static final String CODE_COLUMN
public static final String WKT_COLUMN
| Constructor Detail |
|---|
public DirectPostgisFactory(Hints hints,
Connection connection)
throws SQLException
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 DirectPostgisFactory class only in a
ThreadedAuthorityFactory. This approach also
gives concurrency and caching services in bonus.
hints - The hints, or null if none.connection - The connection to the database.
SQLException - If an error occurred while fetching metadata from the database.| Method Detail |
|---|
public String getBackingStoreDescription()
throws FactoryException
getBackingStoreDescription in class AbstractAuthorityFactorynull.
FactoryException - if a failure occurs while fetching the engine description.public Citation getPrimaryKeyAuthority()
The default implementation returns Citations.POSTGIS in all cases.
getPrimaryKey(Class, String)
public Set<String> getAuthorityCodes(Class<? extends IdentifiedObject> category)
throws FactoryException
getAuthorityCodes in interface AuthorityFactorygetAuthorityCodes in class WKTParsingAuthorityFactorycategory - The type of objects to search for (typically
CoordinateReferenceSystem.class).
FactoryException - if an error occurred while querying the database.
public Integer getPrimaryKey(Class<? extends IdentifiedObject> type,
String code)
throws NoSuchAuthorityCodeException,
FactoryException
"EPSG:4326", then this method searches for a row
with the given authority ("EPSG") in the "auth_name" column and the
given integer code (4326) in the "auth_srid" column. If such row is found,
then the value of its "srid" column is returned.
If the supplied code does not contain an authority part (e.g. "4326"),
then this method parses the code as an integer. This is consistent with common practice
where the spatial CRS table contains entries from a single authority with primary keys
identical to the authority codes. This is also consistent with the codes returned by the
getAuthorityCodes(Class) method.
type - The type of the object being created (usually
CoordinateReferenceSystem.class).code - The authority code to convert to primary key value.
NoSuchAuthorityCodeException - if a code can't be parsed as an integer or can't
be found in the database.
FactoryException - if an error occurred while querying the database.getPrimaryKeyAuthority()protected void dispose(boolean shutdown)
dispose in class WKTParsingAuthorityFactory
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||