org.geotoolkit.referencing.factory.wkt
Class AuthorityFactoryProvider

Object
  extended by AuthorityFactoryProvider

public class AuthorityFactoryProvider
extends Object

Convenience class for creating CRSAuthorityFactory instances using custom CRS definitions. Most methods in this class expect the Coordinate Reference System (CRS) definitions to be provided in Well Known Text (WKT) form, since this is often the easiest way to define custom CRS.

The following example creates a factory for ESRI codes. The CRS are defined in a properties file in the same directory than the class invoking the method (replace MyClass by the name of your class):

URL definitionURL = MyClass.class.getResource("myfile.properties");
AuthorityFactoryProvider provider = new AuthorityFactoryProvider();
CRSAuthorityFactory factory = provider.createFromProperties(Citations.ESRI, definitionURL);
The following example creates a factory which use the definitions provided in the "spatial_ref_sys" table of a PostGIS database:
final PGSimpleDataSource ds = new PGSimpleDataSource();
ds.setServerName("myServer");
ds.setDatabaseName("myDatabase");
ds.setUser("myUsername");
ds.setPassword("myPassword");
AuthorityFactoryProvider provider = new AuthorityFactoryProvider();
CRSAuthorityFactory factory = provider.createFromPostGIS(ds);

Since:
3.10
Version:
3.10
Author:
Martin Desruisseaux (Geomatys)
Module:
referencing/geotk-referencing (download)    View source code for this class

Constructor Summary
AuthorityFactoryProvider()
          Creates a new instance which will use the default hints.
AuthorityFactoryProvider(Hints hints)
          Creates a new instance which will use the given hints.
 
Method Summary
 CRSAuthorityFactory createFromPostGIS(DataSource datasource)
          Creates a factory for the specified PostGIS database.
 CRSAuthorityFactory createFromProperties(Citation authority, URL definitionFile)
          Creates a factory for the specified authority using the definitions declared in the given properties file.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AuthorityFactoryProvider

public AuthorityFactoryProvider()
Creates a new instance which will use the default hints.


AuthorityFactoryProvider

public AuthorityFactoryProvider(Hints hints)
Creates a new instance which will use the given hints.

Parameters:
hints - The user hints, or null if none.
Method Detail

createFromProperties

public CRSAuthorityFactory createFromProperties(Citation authority,
                                                URL definitionFile)
                                         throws FactoryException
Creates a factory for the specified authority using the definitions declared in the given properties file. The property file is specified by an URL, which is typically obtained by invoking Class.getResource(String).

Parameters:
authority - The organization or party responsible for CRS definition.
definitionFile - URL to the definition file.
Returns:
A new authority factory backed by the given authority file.
Throws:
FactoryException - If the authority factory can not be created, typically because the given definition file was not found.

createFromPostGIS

public CRSAuthorityFactory createFromPostGIS(DataSource datasource)
                                      throws FactoryException
Creates a factory for the specified PostGIS database. The factory returned by this method implements the Disposable interface. Invoking its dispose() method closes any JDBC connection which may be open.

Parameters:
datasource - Provides connection to the PostGIS database.
Returns:
A new authority factory backed by the given PostGIS database.
Throws:
FactoryException - If the authority factory can not be created.


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