org.geotools.referencing.factory.epsg
Class FactoryUsingWKT

java.lang.Object
  extended by org.geotools.factory.AbstractFactory
      extended by org.geotools.referencing.factory.ReferencingFactory
          extended by org.geotools.referencing.factory.AbstractAuthorityFactory
              extended by org.geotools.referencing.factory.BufferedAuthorityFactory
                  extended by org.geotools.referencing.factory.DeferredAuthorityFactory
                      extended by org.geotools.referencing.factory.epsg.FactoryUsingWKT
All Implemented Interfaces:
javax.imageio.spi.RegisterableService, BufferedFactory, Factory, OptionalFactory, org.opengis.referencing.AuthorityFactory, org.opengis.referencing.crs.CRSAuthorityFactory
Direct Known Subclasses:
EsriExtension, UnnamedExtension

public class FactoryUsingWKT
extends DeferredAuthorityFactory
implements org.opengis.referencing.crs.CRSAuthorityFactory

Authority factory for Coordinate Reference Systems beyong the one defined in the EPSG database. This factory is used as a fallback when a requested code is not found in the EPSG database, or when there is no connection at all to the EPSG database. The additional CRS are defined as Well Known Text in a property file located by default in the org.geotools.referencing.factory.epsg package, and whose name should be "epsg.properties". If no property file is found, the factory won't be activated. The property file can also be located in a custom directory; See getDefinitionsURL() for more details.

This factory can also be used to provide custom extensions or overrides to a main EPSG factory. In order to provide a custom extension file, override the getDefinitionsURL() method. In order to make the factory be an override, change the default priority by using the two arguments constructor (this factory defaults to ThreadedEpsgFactory.PRIORITY - 10, so it's used as an extension).

Since:
2.1
Version:
$Id: FactoryUsingWKT.java 31445 2008-09-07 18:14:23Z desruisseaux $
Author:
Martin Desruisseaux, Jody Garnett, Rueben Schulz, Andrea Aime

Field Summary
protected static int DEFAULT_PRIORITY
          Deprecated. We will try to replace the priority mechanism by a better one in a future Geotools version.
static java.lang.String FILENAME
          The default filename to read.
 
Fields inherited from class org.geotools.referencing.factory.ReferencingFactory
LOGGER
 
Fields inherited from class org.geotools.factory.AbstractFactory
hints, MAXIMUM_PRIORITY, MINIMUM_PRIORITY, NORMAL_PRIORITY, priority
 
Constructor Summary
  FactoryUsingWKT()
          Constructs an authority factory using the default set of factories.
  FactoryUsingWKT(Hints userHints)
          Constructs an authority factory using a set of factories created from the specified hints.
protected FactoryUsingWKT(Hints userHints, int priority)
          Constructs an authority factory using the specified hints and priority.
 
Method Summary
protected  AbstractAuthorityFactory createBackingStore()
          Creates the backing store authority factory.
protected  org.opengis.metadata.citation.Citation[] getAuthorities()
          Returns the set of authorities to use as identifiers for the CRS to be created.
 org.opengis.metadata.citation.Citation getAuthority()
          Returns the authority.
protected  java.net.URL getDefinitionsURL()
          Returns the URL to the property file that contains CRS definitions.
static void main(java.lang.String[] args)
          Prints a list of codes that duplicate the ones provided in the ThreadedEpsgFactory.
protected  java.util.Set reportDuplicatedCodes(java.io.PrintWriter out)
          Prints a list of codes that duplicate the ones provided by ThreadedEpsgFactory.
protected  java.util.Set reportInstantiationFailures(java.io.PrintWriter out)
          Prints a list of CRS that can't be instantiated.
 
Methods inherited from class org.geotools.referencing.factory.DeferredAuthorityFactory
canDisposeBackingStore, dispose, exit, isAvailable, isConnected, 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, getIdentifiedObjectFinder, getVendor
 
Methods inherited from class org.geotools.referencing.factory.AbstractAuthorityFactory
noSuchAuthorityCode, trimAuthority
 
Methods inherited from class org.geotools.referencing.factory.ReferencingFactory
ensureNonNull
 
Methods inherited from class org.geotools.factory.AbstractFactory
addImplementationHints, equals, getImplementationHints, getPriority, hashCode, onDeregistration, onRegistration, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.opengis.referencing.crs.CRSAuthorityFactory
createCompoundCRS, createCoordinateReferenceSystem, createDerivedCRS, createEngineeringCRS, createGeocentricCRS, createGeographicCRS, createImageCRS, createProjectedCRS, createTemporalCRS, createVerticalCRS
 
Methods inherited from interface org.opengis.referencing.AuthorityFactory
createObject, getAuthorityCodes, getDescriptionText
 
Methods inherited from interface org.opengis.referencing.Factory
getVendor
 
Methods inherited from interface org.geotools.factory.Factory
getImplementationHints
 

Field Detail

FILENAME

public static final java.lang.String FILENAME
The default filename to read. The default FactoryUsingWKT implementation will search for the first occurence of this file in the following places:

The filename part before the extension ("epsg") denotes the authority namespace where to register the content of this file. The user-directory given by the system property may contains other property files for other authorities, like "esri.properties", but those additional authorities are not handled by the default FactoryUsingWKT class.

See Also:
getDefinitionsURL(), Constant Field Values

DEFAULT_PRIORITY

protected static final int DEFAULT_PRIORITY
Deprecated. We will try to replace the priority mechanism by a better one in a future Geotools version.
Default priority for this factory.

Since:
2.4
See Also:
Constant Field Values
Constructor Detail

FactoryUsingWKT

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


FactoryUsingWKT

public FactoryUsingWKT(Hints userHints)
Constructs an authority factory using a set of factories created from the specified hints. This constructor recognizes the CRS, CS, DATUM and MATH_TRANSFORM FACTORY hints.


FactoryUsingWKT

protected FactoryUsingWKT(Hints userHints,
                          int priority)
Constructs an authority factory using the specified hints and priority.

Method Detail

getAuthority

public org.opengis.metadata.citation.Citation getAuthority()
Returns the authority. The default implementation returns the first citation returned by getAuthorities(), with the addition of identifiers from all additional authorities returned by the above method.

Specified by:
getAuthority in interface org.opengis.referencing.AuthorityFactory
Overrides:
getAuthority in class BufferedAuthorityFactory
See Also:
getAuthorities()

getAuthorities

protected org.opengis.metadata.citation.Citation[] getAuthorities()
Returns the set of authorities to use as identifiers for the CRS to be created. This set is given to the properties-backed factory constructor.

The default implementation returns a singleton containing only EPSG. Subclasses should override this method in order to enumerate all relevant authorities, with EPSG in last position. For example EsriExtension returns {ESRI, EPSG}.

Since:
2.4

getDefinitionsURL

protected java.net.URL getDefinitionsURL()
Returns the URL to the property file that contains CRS definitions. The default implementation performs the following search path:

Returns:
The URL, or null if none.

createBackingStore

protected AbstractAuthorityFactory createBackingStore()
                                               throws org.opengis.referencing.FactoryException
Creates the backing store authority factory.

Specified by:
createBackingStore in class DeferredAuthorityFactory
Returns:
The backing store to uses in createXXX(...) methods.
Throws:
FactoryNotFoundException - if the no epsg.properties file has been found.
org.opengis.referencing.FactoryException - if the constructor failed to find or read the file. This exception usually has an IOException as its cause.

reportDuplicatedCodes

protected java.util.Set reportDuplicatedCodes(java.io.PrintWriter out)
                                       throws org.opengis.referencing.FactoryException
Prints a list of codes that duplicate the ones provided by ThreadedEpsgFactory. This is used for implementation of main method in order to check the content of the "epsg.properties" file (or whatever property file used as backing store for this factory) from the command line.

Parameters:
out - The writer where to print the report.
Returns:
The set of duplicated codes.
Throws:
org.opengis.referencing.FactoryException - if an error occured.
Since:
2.4

reportInstantiationFailures

protected java.util.Set reportInstantiationFailures(java.io.PrintWriter out)
                                             throws org.opengis.referencing.FactoryException
Prints a list of CRS that can't be instantiated. This is used for implementation of main method in order to check the content of the "epsg.properties" file (or whatever property file used as backing store for this factory) from the command line.

Parameters:
out - The writer where to print the report.
Returns:
The set of codes that can't be instantiated.
Throws:
org.opengis.referencing.FactoryException - if an error occured while fetching authority codes.
Since:
2.4

main

public static void main(java.lang.String[] args)
                 throws org.opengis.referencing.FactoryException
Prints a list of codes that duplicate the ones provided in the ThreadedEpsgFactory. The factory tested is the one registered in ReferencingFactoryFinder. By default, this is this FactoryUsingWKT class backed by the "epsg.properties" property file. This method can be invoked from the command line in order to check the content of the property file. Valid arguments are:

-testTry to instantiate all CRS and reports any failure to do so.
-duplicatedList all codes from the WKT factory that are duplicating a code from the SQL factory.

Parameters:
args - Command line arguments.
Throws:
org.opengis.referencing.FactoryException - if an error occured.
Since:
2.4


Copyright © 1996-2010 Geotools. All Rights Reserved.