org.deegree.cs.persistence
Class CRSManager

java.lang.Object
  extended by org.deegree.commons.config.AbstractBasicResourceManager
      extended by org.deegree.cs.persistence.CRSManager
All Implemented Interfaces:
ResourceManager

public class CRSManager
extends AbstractBasicResourceManager
implements ResourceManager

Entry point for creating and retrieving CRSStore and CRSStoreProvider instances.

Version:
$Revision: $, $Date: $
Author:
Lyn Buesching, last edited by: $Author: lyn $

Field Summary
 
Fields inherited from class org.deegree.commons.config.AbstractBasicResourceManager
dir, idToState
 
Constructor Summary
CRSManager()
           
 
Method Summary
 ResourceState activate(String id)
          Activates the resource with the given identifier.
 CRSStore create(URL configURL)
          Returns an uninitialized CRSStore instance that's created from the specified CRSStore configuration document.
 ResourceState deactivate(String id)
          Deactivates the resource with the given identifier.
static void destroy()
          cleares the stored configuration
static CRSStore get(String id)
          Returns the CRSStore instance with the specified identifier or null if an assigned CRSStore is missing
static Collection<CRSStore> getAll()
          Returns all active CRSStores.
 List<CRSCodeType[]> getAvailableCRSCodes()
          This methods allows to get all available identifiers and not in the coordinatesystems themselves from all stores.
 List<ICRS> getAvailableCRSs()
          This method allows to get all ICRS from all stores.
static CRSRef getCRSRef(ICRS crs)
          Returns a CRSRef wrapping the given CRS.
static CRSRef getCRSRef(String uri)
          Returns a CRSRef instance which is not resolved.
static CRSRef getCRSRef(String uri, boolean forceXY)
          Return a CRSRef instance which is not resolved.
static Collection<String> getCrsStoreIds()
           
 Class<? extends ResourceManager>[] getDependencies()
           
 ResourceManagerMetadata getMetadata()
           
protected  ResourceProvider getProvider(File file)
           
static Transformation getTransformation(String storeId, ICRS sourceCRS, ICRS targetCRS)
          Retrieve a Transformation (chain) which transforms coordinates from the given source into the given target crs.
static Transformation getTransformation(String storeId, ICRS sourceCRS, ICRS targetCRS, List<Transformation> transformationsToBeUsed)
          Retrieve a Transformation (chain) which transforms coordinates from the given source into the given target crs.
static Transformation getTransformation(String storeId, String id)
          Get a Transformation with given id, or null if it does not exist.
static TransformationFactory getTransformationFactory(String storeId)
           
 void init(File crsDir)
          Initializes the CRSManager by loading all crs store configurations from the given directory.
static ICRS lookup(CRSCodeType codeType)
          Creates a direct ICRS instance from the given CRSCodeType not just a CRSRef, if no ICRS was found an UnknownCRSException will be thrown.
static ICRS lookup(String name)
          Creates a direct ICRS instance from the given name not just a CRSRef, if no ICRS was found an UnknownCRSException will be thrown.
static ICRS lookup(String name, boolean forceXY)
          Creates a direct ICRS instance from the given name not just a CRSRef, if no ICRS was found an UnknownCRSException will be thrown.
static ICRS lookup(String storeId, CRSCodeType crsCodeType)
          Creates a direct ICRS instance from the given CRSCodeType notjustjust a CRSRef using the given storeId, if no ICRS was found an UnknownCRSException will be thrown.
static ICRS lookup(String storeId, String name)
          Creates a direct ICRS instance from the given name using not just a CRSRef the given storeID, if no ICRS was found in the given store an UnknownCRSException will be thrown.
static ICRS lookup(String storeIdName, String name, boolean forceXY)
          Creates a direct ICRS instance with the given name not just a CRSRef using the given storeId, if no ICRS was found an UnknownCRSException will be thrown.
protected  void remove(String id)
           
 void shutdown()
          Is called upon workspace shutdown.
 void startup(DeegreeWorkspace workspace)
          Is called upon workspace startup.
 
Methods inherited from class org.deegree.commons.config.AbstractBasicResourceManager
createResource, deleteResource, getState, getStates, init
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.deegree.commons.config.ResourceManager
createResource, deleteResource, getState, getStates
 

Constructor Detail

CRSManager

public CRSManager()
Method Detail

startup

public void startup(DeegreeWorkspace workspace)
             throws ResourceInitException
Description copied from interface: ResourceManager
Is called upon workspace startup.

Specified by:
startup in interface ResourceManager
Throws:
ResourceInitException

shutdown

public void shutdown()
Description copied from interface: ResourceManager
Is called upon workspace shutdown.

Specified by:
shutdown in interface ResourceManager

destroy

public static void destroy()
cleares the stored configuration


getDependencies

public Class<? extends ResourceManager>[] getDependencies()
Specified by:
getDependencies in interface ResourceManager
Returns:
an empty array if there are no dependencies

init

public void init(File crsDir)
Initializes the CRSManager by loading all crs store configurations from the given directory. If null, or directory does not exist the default will be used.

Parameters:
crsDir -

create

public CRSStore create(URL configURL)
                throws CRSStoreException
Returns an uninitialized CRSStore instance that's created from the specified CRSStore configuration document.

Parameters:
configURL - URL of the configuration document, must not be null
Returns:
corresponding CRSStore instance, not yet initialized, never null
Throws:
CRSStoreException - if the creation fails, e.g. due to a configuration error

getAll

public static Collection<CRSStore> getAll()
Returns all active CRSStores.

Returns:
the CRSStores instance, may be empty but never null

get

public static CRSStore get(String id)
Returns the CRSStore instance with the specified identifier or null if an assigned CRSStore is missing

Parameters:
id - identifier of the CRSStore instance
Returns:
the corresponding CRSStore instance or the default CRSStore instance if no such instance has been created or null if the default one could also not be created.

getCrsStoreIds

public static Collection<String> getCrsStoreIds()

getMetadata

public ResourceManagerMetadata getMetadata()
Specified by:
getMetadata in interface ResourceManager
Returns:
a metadata object, may be null

getAvailableCRSs

public List<ICRS> getAvailableCRSs()
                            throws CRSConfigurationException
This method allows to get all ICRS from all stores.

Returns:
all configured CRSs.
Throws:
CRSConfigurationException - if the implementation was confronted by an exception and could not deliver the requested crs. This exception should not be thrown if no CoordinateSystems were found, in the latter case an empty List ( a list with size == 0 ) should be returned.

getAvailableCRSCodes

public List<CRSCodeType[]> getAvailableCRSCodes()
                                         throws CRSConfigurationException
This methods allows to get all available identifiers and not in the coordinatesystems themselves from all stores.

Returns:
the identifiers of all configured CRSs.
Throws:
CRSConfigurationException - if the implementation was confronted by an exception and could not deliver the requested crs. This exception should not be thrown if no CoordinateSystems were found, in the latter case an empty List ( a list with size == 0 ) should be returned.

getCRSRef

public static CRSRef getCRSRef(String uri)
Returns a CRSRef instance which is not resolved.

Parameters:
uri - the uri of the resource which is used to resolve the reference
Returns:
an unresolved CRSRef instance

getCRSRef

public static CRSRef getCRSRef(String uri,
                               boolean forceXY)
Return a CRSRef instance which is not resolved.

Parameters:
uri - the uri of the resource which is used to resolve the reference
forceXY - flag indicating if the axis order should be as configured or xy
Returns:
an unresolved CRSRef instance

getCRSRef

public static CRSRef getCRSRef(ICRS crs)
Returns a CRSRef wrapping the given CRS. The uri of the reference is set to the id of the given ICRS

Parameters:
crs - the ICRS to wrap
Returns:

lookup

public static ICRS lookup(String name)
                   throws UnknownCRSException
Creates a direct ICRS instance from the given name not just a CRSRef, if no ICRS was found an UnknownCRSException will be thrown. All configured CRSStores will be considered and the first match returned.

Parameters:
name - of the crs, e.g. EPSG:4326
Returns:
a direct ICRS instance corresponding to the given name not just a CRSRef, using all configured CRSStores.
Throws:
UnknownCRSException - if a ICRS with the name is not known

lookup

public static ICRS lookup(String name,
                          boolean forceXY)
                   throws UnknownCRSException
Creates a direct ICRS instance from the given name not just a CRSRef, if no ICRS was found an UnknownCRSException will be thrown. All configured CRSStores will be considered and the first match returned.

Parameters:
name - of the crs, e.g. EPSG:4326
forceXY - true if the axis order of the coordinate system should be x/y (EAST/NORTH; WEST/SOUTH); false id the defined axis order should be used
Returns:
a direct ICRS instance corresponding to the given name not just a CRSRef, using all configured CRSStores.
Throws:
UnknownCRSException - if a ICRS with the name is not known

lookup

public static ICRS lookup(CRSCodeType codeType)
                   throws UnknownCRSException
Creates a direct ICRS instance from the given CRSCodeType not just a CRSRef, if no ICRS was found an UnknownCRSException will be thrown. All configured CRSStores will be considered and the first match returned.

Parameters:
codeType - the CodeType of the CRS to return
Returns:
a direct ICRS instance with the given CodeType not just a CRSRef
Throws:
UnknownCRSException - if a ICRS with the name is not known

lookup

public static ICRS lookup(String storeId,
                          String name)
                   throws UnknownCRSException
Creates a direct ICRS instance from the given name using not just a CRSRef the given storeID, if no ICRS was found in the given store an UnknownCRSException will be thrown.

Parameters:
storeId - identifier of the CRSStore looking for the ICRS with the given name, may be null if in all CRSStores should be searched
name - of the crs, e.g. EPSG:31466
Returns:
a direct ICRS instance not just a CRSRef corresponding to the given name from the CRSStore with the given id
Throws:
UnknownCRSException - if a ICRS with the name is not known

lookup

public static ICRS lookup(String storeIdName,
                          String name,
                          boolean forceXY)
                   throws UnknownCRSException
Creates a direct ICRS instance with the given name not just a CRSRef using the given storeId, if no ICRS was found an UnknownCRSException will be thrown.

Parameters:
storeId - identifier of the store, looking for the ICRS instance, may be null if in all CRSStores should be searched
name - of the crs, e.g. EPSG:31466
forceXY - true if the axis order of the coordinate system should be x/y (EAST/NORTH; WEST/SOUTH); false id the defined axis order should be used
Returns:
a direct ICRS instance not just a CRSRef corresponding to the given name from the CRSStore with the given id
Throws:
UnknownCRSException - if a ICRS with the name is not known

lookup

public static ICRS lookup(String storeId,
                          CRSCodeType crsCodeType)
                   throws UnknownCRSException
Creates a direct ICRS instance from the given CRSCodeType notjustjust a CRSRef using the given storeId, if no ICRS was found an UnknownCRSException will be thrown.

Parameters:
storeId - identifier of the store, looking for the ICRS instance, may be null if in all CRSStores should be searched
crsCodeType - the CRSCodeType of the ICRS to return
Returns:
a real ICRS not just a reference.
Throws:
UnknownCRSException - if a ICRS with the name is not known

getTransformationFactory

public static final TransformationFactory getTransformationFactory(String storeId)
Parameters:
storeId - identifier of the CRSStore instance, may be null, then the first transformation factory will be returned
Returns:
the TransformationFactory instance assigned to the store with the given id or the first one in the list of TransformationFactorys if no such instance has been created or null if no TransformationFactory instance could be found.

getTransformation

public static Transformation getTransformation(String storeId,
                                               String id)
Get a Transformation with given id, or null if it does not exist.

Parameters:
storeId - identifier of the store, looking for the Transformation, may be null if in all CRSStores should be searched
id - of the Transformation
Returns:
the identified Transformation or null if no such transformation is found.

getTransformation

public static Transformation getTransformation(String storeId,
                                               ICRS sourceCRS,
                                               ICRS targetCRS)
                                        throws IllegalArgumentException,
                                               TransformationException
Retrieve a Transformation (chain) which transforms coordinates from the given source into the given target crs. If no such Transformation could be found or the implementation does not support inverse lookup of transformations null will be returned.

Parameters:
storeId - identifier of the store, looking for the Transformation, may be null if in all CRSStores should be searched
sourceCRS - start ICRS of the transformation (chain)
targetCRS - end ICRS of the transformation (chain).
Returns:
the given Transformation or null if no such transformation was found.
Throws:
TransformationException
IllegalArgumentException

getTransformation

public static Transformation getTransformation(String storeId,
                                               ICRS sourceCRS,
                                               ICRS targetCRS,
                                               List<Transformation> transformationsToBeUsed)
                                        throws IllegalArgumentException,
                                               TransformationException
Retrieve a Transformation (chain) which transforms coordinates from the given source into the given target crs. If no such Transformation could be found or the implementation does not support inverse lookup of transformations null will be returned.

Parameters:
storeId - identifier of the store, looking for the Transformation, may be null if in all CRSStores should be searched
sourceCRS - start ICRS of the transformation (chain)
targetCRS - end ICRS of the transformation (chain).
transformationsToBeUsed - a list of transformations which must be used on the resulting transformation chain, may be null or empty
Returns:
the given Transformation or null if no such transformation was found.
Throws:
TransformationException
IllegalArgumentException

activate

public ResourceState activate(String id)
Description copied from interface: ResourceManager
Activates the resource with the given identifier.

Specified by:
activate in interface ResourceManager
Parameters:
id - resource identifier, must not be null
Returns:
resource state after activation (may be unsuccessful), but never null

deactivate

public ResourceState deactivate(String id)
Description copied from interface: ResourceManager
Deactivates the resource with the given identifier.

Specified by:
deactivate in interface ResourceManager
Parameters:
id - resource identifier, must not be null
Returns:
resource state after deactivation (may be unsuccessful), but never null

getProvider

protected ResourceProvider getProvider(File file)
Specified by:
getProvider in class AbstractBasicResourceManager

remove

protected void remove(String id)
Specified by:
remove in class AbstractBasicResourceManager


Copyright © 2011. All Rights Reserved.