org.geotools.referencing.factory.epsg
Class DefaultFactory

java.lang.Object
  extended byorg.geotools.factory.AbstractFactory
      extended byorg.geotools.referencing.factory.AbstractFactory
          extended byorg.geotools.referencing.factory.AbstractAuthorityFactory
              extended byorg.geotools.referencing.factory.BufferedAuthorityFactory
                  extended byorg.geotools.referencing.factory.DeferredAuthorityFactory
                      extended byorg.geotools.referencing.factory.epsg.DefaultFactory
All Implemented Interfaces:
org.opengis.referencing.AuthorityFactory, org.opengis.referencing.operation.CoordinateOperationAuthorityFactory, org.opengis.referencing.crs.CRSAuthorityFactory, org.opengis.referencing.cs.CSAuthorityFactory, org.opengis.referencing.datum.DatumAuthorityFactory, Factory, org.opengis.referencing.Factory, OptionalFactory, javax.imageio.spi.RegisterableService

public class DefaultFactory
extends DeferredAuthorityFactory

The default EPSG factory to be registered in FactoryFinder. This factory works as a proxy for 1) select an appropriate FactoryUsingSQL subclass at runtime and 2) cache CRS objects for better performances. The database connection is specified through a DataSource binded to the {@value} name in Java Naming and Directory Interfaces (JNDI). If no binding is found under that name, data sources are searched in the following directory:

META-INF/services/org.geotools.referencing.factory.epsg.DataSource
The contains a default binding using the JDBC-ODBC bridge. This default binding expects an "" database registered as an ODBC data source. See the package javadoc for installation instructions.

Users should not creates instance of this class directly. They should invoke one of FactoryFinder.getFooAuthorityFactory("EPSG") methods instead.

Since:
2.1
Version:
$Id: DefaultFactory.java 19303 2006-04-27 10:24:05Z desruisseaux $
Author:
Martin Desruisseaux
See Also:
DataSource

Field Summary
static java.lang.String DATASOURCE_NAME
          The JDBC data source name in JNDI.
 
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
DefaultFactory()
          Constructs an authority factory using the default set of factories.
DefaultFactory(Hints hints)
          Constructs an authority factory using a set of factories created from the specified hints.
 
Method Summary
protected  boolean canDisposeBackingStore(AbstractAuthorityFactory backingStore)
          Returns if the backing store can be disposed now.
protected  AbstractAuthorityFactory createBackingStore()
          Creates the backing store authority factory.
 org.opengis.metadata.citation.Citation getAuthority()
          Returns the authority for this EPSG database.
 DataSource getDataSource()
          Returns the data source for the EPSG database.
static void main(java.lang.String[] args)
          Constructs an object from the EPSG database and print its WKT (Well Know Text) to the standard output.
 void onDeregistration(javax.imageio.spi.ServiceRegistry registry, java.lang.Class category)
          Called when this factory is removed from the given of the given .
 void onRegistration(javax.imageio.spi.ServiceRegistry registry, java.lang.Class category)
          Called when this factory is added to the given of the given .
 void setDataSource(DataSource datasource)
          Set the data source for the EPSG database.
 
Methods inherited from class org.geotools.referencing.factory.DeferredAuthorityFactory
dispose, isConnected, isReady, setTimeout
 
Methods inherited from class org.geotools.referencing.factory.BufferedAuthorityFactory
createCartesianCS, createCompoundCRS, createCoordinateOperation, createCoordinateReferenceSystem, createCoordinateSystem, createCoordinateSystemAxis, createCylindricalCS, createDatum, createDerivedCRS, createEllipsoid, createEllipsoidalCS, createEngineeringCRS, createEngineeringDatum, createExtent, createFromCoordinateReferenceSystemCodes, createGeocentricCRS, createGeodeticDatum, createGeographicCRS, createImageCRS, createImageDatum, createObject, createOperationMethod, createParameterDescriptor, createPolarCS, createPrimeMeridian, createProjectedCRS, createSphericalCS, createTemporalCRS, createTemporalDatum, createTimeCS, createUnit, createVerticalCRS, createVerticalCS, createVerticalDatum, getAuthorityCodes, getBackingStoreDescription, getDescriptionText, getVendor
 
Methods inherited from class org.geotools.referencing.factory.AbstractAuthorityFactory
getImplementationHints, noSuchAuthorityCode, trimAuthority
 
Methods inherited from class org.geotools.referencing.factory.AbstractFactory
ensureNonNull
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.geotools.factory.Factory
getImplementationHints
 

Field Detail

DATASOURCE_NAME

public static final java.lang.String DATASOURCE_NAME
The JDBC data source name in JNDI.

See Also:
Constant Field Values
Constructor Detail

DefaultFactory

public DefaultFactory()
Constructs an authority factory using the default set of factories.


DefaultFactory

public DefaultFactory(Hints hints)
Constructs an authority factory using a set of factories created from the specified hints. This constructor recognizes the CRS, CS, DATUM and MATH_TRANSFORM hints. In addition, the FactoryGroup.HINT_KEY hint may be used as a low-level substitute for all the above.

Method Detail

getAuthority

public org.opengis.metadata.citation.Citation getAuthority()
Returns the authority for this EPSG database. This authority will contains the database version in the edition attribute, together with the edition date.

Specified by:
getAuthority in interface org.opengis.referencing.AuthorityFactory
Overrides:
getAuthority in class BufferedAuthorityFactory

getDataSource

public final DataSource getDataSource()
                               throws java.sql.SQLException
Returns the data source for the EPSG database. Note: invoking this method may force immediate connection to the EPSG database.

Returns:
The data source.
Throws:
java.sql.SQLException - if the connection to the EPSG database failed.

setDataSource

public void setDataSource(DataSource datasource)
                   throws java.sql.SQLException
Set the data source for the EPSG database. If an other EPSG database was already in use, it will be disconnected. Users should not invoke this method on the factory returned by FactoryFinder, since it would have a system-wide effect.

Parameters:
datasource - The new datasource.
Throws:
java.sql.SQLException - if an error occured.

createBackingStore

protected AbstractAuthorityFactory createBackingStore()
                                               throws org.opengis.referencing.FactoryException
Creates the backing store authority factory. This method try to connect to the EPSG database from the {@value} data source. If no data source were found for that name, implementation declared in are tested.

Specified by:
createBackingStore in class DeferredAuthorityFactory
Returns:
The backing store to uses in methods.
Throws:
org.opengis.referencing.FactoryException - if the constructor failed to connect to the EPSG database. This exception usually has a SQLException as its cause.

canDisposeBackingStore

protected boolean canDisposeBackingStore(AbstractAuthorityFactory backingStore)
Returns if the backing store can be disposed now. This method is invoked automatically after the amount of time specified by DeferredAuthorityFactory.setTimeout(long) if the factory were not used during that time.

Overrides:
canDisposeBackingStore in class DeferredAuthorityFactory
Parameters:
backingStore - The backing store in process of being disposed.

onRegistration

public void onRegistration(javax.imageio.spi.ServiceRegistry registry,
                           java.lang.Class category)
Called when this factory is added to the given of the given . The object may already be registered under another category.

Specified by:
onRegistration in interface javax.imageio.spi.RegisterableService
Overrides:
onRegistration in class AbstractAuthorityFactory
Parameters:
registry - a where this factory has been registered.
category - a object indicating the registry category under which this object has been registered.
See Also:
AbstractFactory.MINIMUM_PRIORITY, AbstractFactory.MAXIMUM_PRIORITY, FactoryFinder

onDeregistration

public void onDeregistration(javax.imageio.spi.ServiceRegistry registry,
                             java.lang.Class category)
Called when this factory is removed from the given of the given . The object may still be registered under another category.

Specified by:
onDeregistration in interface javax.imageio.spi.RegisterableService
Overrides:
onDeregistration in class AbstractFactory
Parameters:
registry - A service registry from which this object is being (wholly or partially) deregistered.
category - The registry category from which this object is being deregistered.

main

public static void main(java.lang.String[] args)
Constructs an object from the EPSG database and print its WKT (Well Know Text) to the standard output. This method can be invoked from the command line. For example:
 java org.geotools.referencing.factory.epsg.DefaultFactory 4181
 
Should print:
 GEOGCS["Luxembourg 1930", DATUM["Luxembourg 1930", etc...
 
The following optional arguments are supported:
charset
Sets the console encoding for this application output. This value has no impact on the data exchanged with the EPSG database.
Output the math transforms between every pairs of CRS.

Parameters:
args - A list of EPSG code to display. An arbitrary number of codes can be specified on the command line.


Copyright © GeoTools. All Rights Reserved.