org.geotoolkit.referencing.factory.wkt
Class WKTParsingAuthorityFactory

Object
  extended by Factory
      extended by ReferencingFactory
          extended by AbstractAuthorityFactory
              extended by DirectAuthorityFactory
                  extended by WKTParsingAuthorityFactory
All Implemented Interfaces:
AuthorityFactory, Factory
Direct Known Subclasses:
DirectPostgisFactory, PropertyAuthorityFactory

@ThreadSafe
public class WKTParsingAuthorityFactory
extends DirectAuthorityFactory

A CRS Authority Factory that manages object creation by parsing Well Known Text (WKT) strings. The strings may be loaded from property files or be queried in a database (for example the "spatial_ref_sys" table in a PostGIS database).

This base implementation expects a map of (code, WKT) entries, where the authority codes are the keys and WKT strings are the values. If the map is backed by a store which may throw checked exceptions (for example a connection to a PostGIS database), then it shall wrap the checked exceptions in BackingStoreExceptions.


Declaring more than one authority
There is usually only one authority for a given instance of WKTParsingAuthorityFactory, but more authorities can be given to the constructor if the CRS objects to create should have more than one identifier, each with the same code but different namespace. For example a factory for CRS defined by ESRI uses the "ESRI" namespace, but also the "EPSG" namespace because those CRS are used as extension of the EPSG database. Consequently the same CRS can be identified as both "ESRI:53001" and "EPSG:53001", where "53001" is a unused code in the official EPSG database.


Caching of CRS objects
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 should be wrapped in CachingAuthorityFactory.

Since:
3.10 (derived from 3.00)
Version:
3.14
Author:
Jody Garnett (Refractions), Rueben Schulz (UBC), Martin Desruisseaux (IRD, Geomatys)
Module:
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
 
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
WKTParsingAuthorityFactory(Hints userHints, Map<String,String> definitions, Citation... authorities)
          Creates a factory for the specified authorities using the definitions in the given map.
 
Method Summary
 ConformanceResult availability()
          Returns whatever this factory is ready for use.
 CoordinateReferenceSystem createCoordinateReferenceSystem(String code)
          Returns a coordinate reference system from a code.
 IdentifiedObject createObject(String code)
          Returns an arbitrary object from a code.
protected  void dispose(boolean shutdown)
          Releases resources immediately instead of waiting for the garbage collector.
 Citation getAuthority()
          Returns the authority.
 Set<String> getAuthorityCodes(Class<? extends IdentifiedObject> type)
          Returns the set of authority codes of the given type.
 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.
protected  String trimAuthority(String code)
          Trims the authority scope, if presents.
 
Methods inherited from class DirectAuthorityFactory
getImplementationHints
 
Methods inherited from class AbstractAuthorityFactory
createCartesianCS, createCompoundCRS, createCoordinateOperation, createCoordinateSystem, createCoordinateSystemAxis, createCylindricalCS, createDatum, createDerivedCRS, createEllipsoid, createEllipsoidalCS, createEngineeringCRS, createEngineeringDatum, createExtent, createFromCoordinateReferenceSystemCodes, createGeocentricCRS, createGeodeticDatum, createGeographicCRS, createImageCRS, createImageDatum, createOperationMethod, createParameterDescriptor, createPolarCS, createPrimeMeridian, createProjectedCRS, createSphericalCS, createTemporalCRS, createTemporalDatum, createTimeCS, createUnit, createVerticalCRS, createVerticalCS, createVerticalDatum, getBackingStoreDescription, noSuchAuthorityCode
 
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 Factory
getVendor
 

Constructor Detail

WKTParsingAuthorityFactory

public WKTParsingAuthorityFactory(Hints userHints,
                                  Map<String,String> definitions,
                                  Citation... authorities)
Creates a factory for the specified authorities using the definitions in the given map. There is usually only one authority, but more can be given when the objects to create should have more than one identifier, each with the same code but different namespace. See the class javadoc for more details.

Parameters:
userHints - An optional set of hints, or null for the default ones.
definitions - The object definitions as a map with authority codes as keys and WKT strings as values.
authorities - The organizations or parties responsible for definition and maintenance of the database.
Method Detail

availability

public ConformanceResult availability()
Returns whatever this factory is ready for use. The factory is considered ready if the map given at construction time is not empty and the factory has not yet been disposed.

Overrides:
availability in class Factory
Since:
3.03

getAuthority

public Citation getAuthority()
Returns the authority. The default implementation returns the first citation given to the constructor, or a modified version of that citation if many of them were given to the constructor. In the later case, the returned citation will have a set of identifiers which is the union of identifiers of all citations given to the constructor.

Specified by:
getAuthority in interface AuthorityFactory
Specified by:
getAuthority in class AbstractAuthorityFactory

getAuthorityCodes

public Set<String> getAuthorityCodes(Class<? extends IdentifiedObject> type)
                              throws FactoryException
Returns the set of authority codes of the given type. The type argument specifies the base class. For example if this factory is an instance of CRSAuthorityFactory, then:

The default implementation filters the set of codes based on the "PROJCS" and "GEOGCS" at the start of the WKT strings.

Parameters:
type - The spatial reference objects type (can be IdentifiedObject.class).
Returns:
The set of authority codes for spatial reference objects of the given type. If this factory doesn't contains any object of the given type, then this method returns an empty set.
Throws:
FactoryException - if access to the underlying database failed.

getDescriptionText

public InternationalString getDescriptionText(String code)
                                       throws NoSuchAuthorityCodeException,
                                              FactoryException
Gets a description of the object corresponding to a code.

Parameters:
code - Value allocated by authority.
Returns:
A description of the object, or null if the object corresponding to the specified code has no description.
Throws:
NoSuchAuthorityCodeException - if the specified code was not found.
FactoryException - if the query failed for some other reason.

createObject

public IdentifiedObject createObject(String code)
                              throws NoSuchAuthorityCodeException,
                                     FactoryException
Returns an arbitrary object from a code. If the object type is know at compile time, it is recommended to invoke the most precise method instead of this one.

Specified by:
createObject in interface AuthorityFactory
Overrides:
createObject in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Throws:
NoSuchAuthorityCodeException - if the specified code was not found.
FactoryException - if the object creation failed for some other reason.

createCoordinateReferenceSystem

public CoordinateReferenceSystem createCoordinateReferenceSystem(String code)
                                                          throws NoSuchAuthorityCodeException,
                                                                 FactoryException
Returns a coordinate reference system from a code. If the object type is know at compile time, it is recommended to invoke the most precise method instead of this one.

Overrides:
createCoordinateReferenceSystem in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The coordinate reference system for the given code.
Throws:
NoSuchAuthorityCodeException - if the specified code was not found.
FactoryException - if the object creation failed for some other reason.

trimAuthority

protected String trimAuthority(String code)
Trims the authority scope, if presents. If more than one authority were given at construction time, then any of them may appears as the scope in the supplied code.

Overrides:
trimAuthority in class AbstractAuthorityFactory
Parameters:
code - The code to trim.
Returns:
The code without the authority scope.

getIdentifiedObjectFinder

public IdentifiedObjectFinder getIdentifiedObjectFinder(Class<? extends IdentifiedObject> type)
                                                 throws FactoryException
Returns a finder which can be used for looking up unidentified objects.

Overrides:
getIdentifiedObjectFinder in class AbstractAuthorityFactory
Parameters:
type - The type of objects to look for. Should be a GeoAPI interface like GeographicCRS.class, but this method accepts also implementation class. If the type is unknown, use IdentifiedObject.class. A more accurate type may help to speed up the search, since it reduces the amount of tables to scan in some implementations (for example the factories backed by EPSG databases).
Returns:
A finder to use for looking up unidentified objects.
Throws:
FactoryException - if the finder can not be created.

dispose

protected void dispose(boolean shutdown)
Releases resources immediately instead of waiting for the garbage collector.

Overrides:
dispose in class AbstractAuthorityFactory


Copyright © 2009-2011 Geotoolkit.org. All Rights Reserved.