deegree-core-3.0-pre-nightly (2010/03/05 00:01) - official

org.deegree.crs.configuration.deegree.xml
Class DeegreeCRSProvider<T>

java.lang.Object
  extended by org.deegree.crs.configuration.AbstractCRSProvider<T>
      extended by org.deegree.crs.configuration.deegree.xml.DeegreeCRSProvider<T>
Type Parameters:
T - The return type of the XLinkResolver.getURIAsType(String) method
All Implemented Interfaces:
CRSProvider

public class DeegreeCRSProvider<T>
extends AbstractCRSProvider<T>

The DeegreeCRSProvider reads the deegree crs-config (based on it's own xml-schema) and creates the CRS's (and their datums, conversion info's, ellipsoids and projections) if requested.

Attention, although urn's are case-sensitive, the deegreeCRSProvider is not. All incoming id's are toLowerCased!

Automatic loading of projection/transformation classes

It is possible to create your own projection/transformation classes, which can be automatically loaded.

You can achieve this loading by supplying the class attribute to a crs:projectedCRS/crs:projection or crs:coordinateSystem/crs:transformation element in the 'deegree-crs-configuration.xml'. This attribute must contain the full class name (with package), e.g. <crs:projection class='my.package.and.projection.Implementation'>

Because the loading is done with reflections your classes must sustain following criteria:

Projections

  1. It must be a sub class of Projection
  2. A constructor with following signature must be supplied:
    public MyProjection(
        GeographicCRS underlyingCRS,
        double falseNorthing,
        double falseEasting,
        javax.vecmath.Point2d naturalOrigin,
        Unit units,
        double scale,
        java.util.List<org.w3c.dom.Element> yourProjectionElements
    );

    The first six parameters are common to all projections (for an explanation of their meaning take a look at Projection). The last list, will contain all xml-dom elements you supplied in the deegree configuration (child elements of the crs:projection/crs:MyProjection), thus relieving you of the parsing of the deegree-crs-configuration.xml document.

Transformations

  1. It must be a sub class of PolynomialTransformation
  2. A constructor with following signature must be supplied:
    public MyTransformation(
        java.util.list<Double> aValues,
        java.util.list<Double> bValues,
        CoordinateSystem targetCRS,
        java.util.List<org.w3c.dom.Element> yourTransformationElements
    );

    The first three parameters are common to all polynomial values (for an explanation of their meaning take a look at PolynomialTransformation). Again, the last list, will contain all xml-dom elements you supplied in the deegree configuration (child elements of the crs:transformation/crs:MyTransformation), thus relieving you of the parsing of the deegree-crs-configuration.xml document.

Version:
$Revision: 22633 $, $Date: 2010-02-19 11:29:55 +0100 (Fr, 19 Feb 2010) $
Author:
Rutger Bezema, last edited by: $Author: rbezema $

Nested Class Summary
 
Nested classes/interfaces inherited from class org.deegree.crs.configuration.AbstractCRSProvider
AbstractCRSProvider.SupportedProjectionParameters, AbstractCRSProvider.SupportedProjections, AbstractCRSProvider.SupportedTransformationParameters, AbstractCRSProvider.SupportedTransformations
 
Method Summary
 boolean canExport()
           
 void export(StringBuilder sb, List<CoordinateSystem> crsToExport)
          Exports the crs to the implemented format.
 List<CRSCodeType> getAvailableCRSCodes()
          This method should be called if one is only interested in the available identifiers and not in the coordinatesystems themselves.
 List<CoordinateSystem> getAvailableCRSs()
          This method should be called to see if the provider is able to create all defined crs's, thus verifying the correctness of the configuration.
 Ellipsoid getEllipsoidForId(String ellipsoidId)
           
 GeodeticDatum getGeodeticDatumForId(String datumId)
           
 CRSIdentifiable getIdentifiable(CRSCodeType id)
          This method is more general than the CRSProvider.getCRSByCode(CRSCodeType), because it represents a possibility to return an arbitrary CRSIdentifiable Object from the providers backend.
static DeegreeCRSProvider<?> getInstance(Properties properties)
           
 PrimeMeridian getPrimeMeridianForId(String pMeridianId)
           
 Projection getProjection(String usedProjection, GeographicCRS underlyingCRS)
           
 CRSParser<T> getResolver()
           
 Transformation getTransformation(CoordinateSystem sourceCRS, CoordinateSystem targetCRS)
          This method is should retrieve a transformation (chain) which transforms coordinates from the given source into the given target crs.
static void main(String[] args)
          Checks if the time of creating all crs's
protected  CoordinateSystem parseCoordinateSystem(T crsDefinition)
           
 Transformation parseTransformation(T transformationDefinition)
           
 
Methods inherited from class org.deegree.crs.configuration.AbstractCRSProvider
addIdToCache, getCachedIdentifiable, getCachedIdentifiable, getCachedIdentifiable, getCachedIdentifiable, getCachedIdentifiable, getCachedIdentifiable, getCachedIdentifiable, getCRSByCode, mapProjectionParameters, mapProjections, mapTransformation, mapTransformationParameters, setResolver
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

canExport

public boolean canExport()
Returns:
true if this provider can export a given crs.

export

public void export(StringBuilder sb,
                   List<CoordinateSystem> crsToExport)
Description copied from interface: CRSProvider
Exports the crs to the implemented format. Try calling CRSProvider.canExport() before executing this method.

Parameters:
sb - the StringBuilder which will contain the exported version of the given crs.
crsToExport - the CoordinateSystems to export.
See Also:
CRSProvider.canExport()

getResolver

public CRSParser<T> getResolver()
Overrides:
getResolver in class AbstractCRSProvider<T>
Returns:
the casted resolver of the super class.

getAvailableCRSCodes

public List<CRSCodeType> getAvailableCRSCodes()
Description copied from interface: CRSProvider
This method should be called if one is only interested in the available identifiers and not in the coordinatesystems themselves.

Returns:
the identifiers of all configured CRSs.

getAvailableCRSs

public List<CoordinateSystem> getAvailableCRSs()
Description copied from interface: CRSProvider
This method should be called to see if the provider is able to create all defined crs's, thus verifying the correctness of the configuration.

Returns:
all configured CRSs.

parseCoordinateSystem

protected CoordinateSystem parseCoordinateSystem(T crsDefinition)
                                          throws CRSConfigurationException
Specified by:
parseCoordinateSystem in class AbstractCRSProvider<T>
Parameters:
crsDefinition - containing the definition of a crs in the understood type.
Returns:
a CoordinateSystem instance initialized with values from the given type definition fragment or null if the given crsDefinition is null or not known.
Throws:
CRSConfigurationException - if an error was found in the given crsDefintion

parseTransformation

public Transformation parseTransformation(T transformationDefinition)
                                   throws CRSConfigurationException
Specified by:
parseTransformation in class AbstractCRSProvider<T>
Parameters:
transformationDefinition - containing the parameters needed to build a Transformation.
Returns:
a Transformation instance initialized with values from the given definition or null if the given transformationDefintion is null. If the parsed transformation is not supported or a NotSupportedTransformation will be returned.
Throws:
CRSConfigurationException - if an error was found in the given crsDefintion

getTransformation

public Transformation getTransformation(CoordinateSystem sourceCRS,
                                        CoordinateSystem targetCRS)
                                 throws CRSConfigurationException
Description copied from interface: CRSProvider
This method is should 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 should be returned.

Parameters:
sourceCRS - start of the transformation (chain)
targetCRS - end point of the transformation (chain).
Returns:
the Transformation Object or null if no such Object was found.
Throws:
CRSConfigurationException - if the implementation was confronted by an exception and could not deliver the requested Object. This exception should not be thrown no Transformation was found, in this case null should be returned.

getIdentifiable

public CRSIdentifiable getIdentifiable(CRSCodeType id)
                                throws CRSConfigurationException
Description copied from interface: CRSProvider
This method is more general than the CRSProvider.getCRSByCode(CRSCodeType), because it represents a possibility to return an arbitrary CRSIdentifiable Object from the providers backend.

Parameters:
id - string representation of the resource to retrieve
Returns:
the CRSIdentifiable Object or null if no such Object was found.
Throws:
CRSConfigurationException - if the implementation was confronted by an exception and could not deliver the requested Object. This exception should not be thrown if the given id wasn't found, in this case null should be returned.

getProjection

public Projection getProjection(String usedProjection,
                                GeographicCRS underlyingCRS)
Parameters:
usedProjection -
underlyingCRS -
Returns:
the Projection parsed from the configuration or null if no projection with given id was found.

getGeodeticDatumForId

public GeodeticDatum getGeodeticDatumForId(String datumId)
Parameters:
datumId -
Returns:
the datum denoted by given id or null if no datum with given id was found.

getEllipsoidForId

public Ellipsoid getEllipsoidForId(String ellipsoidId)
Parameters:
ellipsoidId -
Returns:
the ellipsoid denoted by given id or null if no ellipsoid with given id was found.

getPrimeMeridianForId

public PrimeMeridian getPrimeMeridianForId(String pMeridianId)
Parameters:
pMeridianId -
Returns:
the PrimeMeridian denoted by given id or null if no PrimeMeridian with given id was found.

getInstance

public static DeegreeCRSProvider<?> getInstance(Properties properties)
Parameters:
properties -
Returns:
a deegree stax or om based crs provider instance.

main

public static void main(String[] args)
Checks if the time of creating all crs's

Parameters:
args -

deegree-core-3.0-pre-nightly (2010/03/05 00:01) - official

an open source project founded by lat/lon, Bonn, Germany.
For more information visit: http://www.deegree.org

]]>