org.deegree.cs.persistence.gml
Class GMLCRSStore

java.lang.Object
  extended by org.deegree.cs.persistence.AbstractCRSStore
      extended by org.deegree.cs.persistence.gml.GMLCRSStore
All Implemented Interfaces:
CRSStore

public class GMLCRSStore
extends AbstractCRSStore

The GMLCRSProvider is a provider for a GML 3.2 backend, this may be a dictionary or a database. Note: not all of the GML3.2. features are implemented yet, but the basics (transformations, crs's, axis, units, projections) should work quite well.

Version:
$Revision: 31368 $, $Date: 2011-07-27 22:10:07 +0200 (Wed, 27 Jul 2011) $
Author:
Rutger Bezema, last edited by: $Author: lbuesching $

Nested Class Summary
 
Nested classes/interfaces inherited from class org.deegree.cs.persistence.AbstractCRSStore
AbstractCRSStore.RESOURCETYPE
 
Constructor Summary
GMLCRSStore(TransformationFactory.DSTransform prefTransformType)
           
 
Method Summary
protected  Helmert createHelmert(CRSResource id, List<Pair<CRSIdentifiable,Object>> parameterValues, ICRS source, ICRS target)
          Creates a Helmert transformation from the given parameter list.
protected  NTv2Transformation createNTv2(CRSResource id, List<Pair<CRSIdentifiable,Object>> parameterValues, ICRS source, ICRS target)
          Create an NTv2Transformation from the given parameter list.
 List<CRSCodeType[]> getAvailableCRSCodes()
          This method should be called if one is only interested in the available identifiers and not in the coordinatesystems themselves.
 List<ICRS> 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.
 ICRS getCoordinateSystem(String id)
           
 CRSResource getCRSResource(CRSCodeType id)
          This method is more general than the CRSStore.getCRSByCode(CRSCodeType), because it represents a possibility to return an arbitrary CRSResource Object from the providers backend.
 Transformation getDirectTransformation(ICRS sourceCRS, ICRS targetCRS)
          This method is should retrieve a transformation which transforms coordinates from the given source into the given target crs.
 Transformation getDirectTransformation(String uri)
          This method should retrieve a transformation with the given id.
protected  org.apache.axiom.om.OMElement getRequiredXlinkedElement(org.apache.axiom.om.OMElement propertyElement, String alternativeXPath)
          convenience method to retrieve a given required element either by resolving a optional xlink or by evaluating the required element denoted by the xpath.
protected  GMLResource getResolver()
           
 void init()
          Called by the manager to indicate that this CRSStore instance is being registered.
protected  IAxis parseAxis(org.apache.axiom.om.OMElement rootElement)
           
protected  IAxis[] parseAxisFromCSType(org.apache.axiom.om.OMElement rootElement)
          For the ellipsoidal and cartesian cs Types, this method also checks the consistency of axis (radian, radian, [metre] ) or (metre, metre, [metre] ).
protected  ICompoundCRS parseCompoundCRS(org.apache.axiom.om.OMElement rootElement)
          This methods parses the given element and maps it onto a CompoundCRS.
protected  ICRS parseCoordinateSystem(org.apache.axiom.om.OMElement rootElement)
           
protected  IGeodeticDatum parseDatum(org.apache.axiom.om.OMElement rootElement)
           
protected  IEllipsoid parseEllipsoid(org.apache.axiom.om.OMElement rootElement)
           
protected  ICRS parseGeodeticCRS(org.apache.axiom.om.OMElement rootElement)
           
 Transformation parseGMLTransformation(org.apache.axiom.om.OMElement rootElement, ICRS sourceCRS, ICRS targetCRS)
          Parses some of the gml 3.2 transformation constructs.
 CRSIdentifiable parseIdentifiedObject(org.apache.axiom.om.OMElement rootElement)
           
protected  Pair<CRSIdentifiable,Object> parseParameterValue(org.apache.axiom.om.OMElement rootElement)
           
protected  List<Pair<CRSIdentifiable,Object>> parseParameterValues(org.apache.axiom.om.OMElement rootElement)
           
protected  IPrimeMeridian parsePrimeMeridian(org.apache.axiom.om.OMElement rootElement)
           
protected  ICRS parseProjectedCRS(org.apache.axiom.om.OMElement rootElement)
           
protected  IProjection parseProjection(org.apache.axiom.om.OMElement rootElement)
          For now this method actually wraps all information in a gml:AbstractGeneralConversionType (or a derived subtype) into an CRSIdentifiable Object (used for the Projections).
 Transformation parseTransformation(org.apache.axiom.om.OMElement rootElement)
          Calls parseGMLTransformation for the catching of XMLParsingException.
protected  IUnit parseUnitOfMeasure(org.apache.axiom.om.OMElement elementContainingUOMAttribute)
          Returns the unit defined by the uomAttribute given of the given element.
protected  IVerticalCRS parseVerticalCRS(org.apache.axiom.om.OMElement rootElement)
           
protected  IVerticalDatum parseVerticalDatum(org.apache.axiom.om.OMElement rootElement)
           
protected  org.apache.axiom.om.OMElement retrieveAndResolveXLink(org.apache.axiom.om.OMElement rootElement)
          Retrieves the xlink:href of the given rootElement and use the XLinkResolver to resolve the xlink if it was given.
protected  String retrieveXLink(org.apache.axiom.om.OMElement rootElement)
          Find an xlink:href attribute and return it's value, if not found, the empty String will be returned.
 void setResolver(GMLResource newResolver)
          Set the resolver to the given resolver.
 
Methods inherited from class org.deegree.cs.persistence.AbstractCRSStore
addIdToCache, clearCache, getCachedIdentifiable, getCachedIdentifiable, getCachedIdentifiable, getCachedIdentifiable, getCachedIdentifiable, getCachedIdentifiable, getCRSByCode, getCRSByCode, getPreferedTransformationType, resolve
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GMLCRSStore

public GMLCRSStore(TransformationFactory.DSTransform prefTransformType)
Method Detail

getAvailableCRSCodes

public List<CRSCodeType[]> getAvailableCRSCodes()
                                         throws CRSConfigurationException
Description copied from interface: CRSStore
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.
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.

getAvailableCRSs

public List<ICRS> getAvailableCRSs()
                            throws CRSConfigurationException
Description copied from interface: CRSStore
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.
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.

parseCoordinateSystem

protected ICRS parseCoordinateSystem(org.apache.axiom.om.OMElement rootElement)
                              throws CRSConfigurationException
Parameters:
rootElement - containing a gml:CRS dom representation.
Returns:
a CRS instance initialized with values from the given XML-OM gml:CRS fragment or null if the given root element is null
Throws:
CRSConfigurationException - if something went wrong.

parseTransformation

public Transformation parseTransformation(org.apache.axiom.om.OMElement rootElement)
                                   throws CRSConfigurationException
Calls parseGMLTransformation for the catching of XMLParsingException.

Throws:
CRSConfigurationException

parseGMLTransformation

public Transformation parseGMLTransformation(org.apache.axiom.om.OMElement rootElement,
                                             ICRS sourceCRS,
                                             ICRS targetCRS)
                                      throws XMLParsingException,
                                             IOException
Parses some of the gml 3.2 transformation constructs. Currently only helmert transformations are supported.

Parameters:
rootElement -
sourceCRS - to be used as the source crs, if null the values from the given transformation will be parsed.
targetCRS - to be used as the target crs, if null the values from the given transformation will be parsed.
Returns:
the transformation.
Throws:
XMLParsingException
IOException

createHelmert

protected Helmert createHelmert(CRSResource id,
                                List<Pair<CRSIdentifiable,Object>> parameterValues,
                                ICRS source,
                                ICRS target)
Creates a Helmert transformation from the given parameter list.

Parameters:
id - of the transformation.
parameterValues - the list of values, the Object must be a Double (denoting a the rotation/translation/ppm of the helmert.)
source - to go from
target - to go to
Returns:
a helmert transformation matrix from the given parameter list.

createNTv2

protected NTv2Transformation createNTv2(CRSResource id,
                                        List<Pair<CRSIdentifiable,Object>> parameterValues,
                                        ICRS source,
                                        ICRS target)
Create an NTv2Transformation from the given parameter list.

Parameters:
id - of the transformation.
parameterValues - the list of values, the Object must be a String (denoting a gridshift file url.)
source - to go from
target - to go to
Returns:
an NTv2Transformation if a file was given, null otherwise.

parseIdentifiedObject

public CRSIdentifiable parseIdentifiedObject(org.apache.axiom.om.OMElement rootElement)
                                      throws XMLParsingException
Parameters:
rootElement - which is a subtype of gml:IdentifiedObject and gml:DefinitionType or gml:AbstractCRSType
Returns:
the CRSIdentifiable instance, its values are filled with the values of the given gml instance.
Throws:
XMLParsingException - if the given rootElement could not be parsed.

parseCompoundCRS

protected ICompoundCRS parseCompoundCRS(org.apache.axiom.om.OMElement rootElement)
                                 throws XMLParsingException,
                                        IOException
This methods parses the given element and maps it onto a CompoundCRS. Currently only gml:CompoundCRS 's consisting of following combination is supported: Geographic crs with a height axis can be mapped in a CompoundCRS by calling the parseGeodeticCRS(OMElement)

Parameters:
rootElement - containing a gml:CompoundCRS dom representation.
Returns:
a CompoundCRS instance initialized with values from the given XML-OM gml:CompoundCRS fragment.
Throws:
XMLParsingException
IOException

parseProjectedCRS

protected ICRS parseProjectedCRS(org.apache.axiom.om.OMElement rootElement)
                          throws XMLParsingException,
                                 IOException
Parameters:
rootElement - containing a gml:ProjectedCRS dom representation.
Returns:
a ProjectedCRS instance initialized with values from the given XML-OM gml:ProjectedCRS fragment or null if the given root element is null
Throws:
XMLParsingException - if the dom tree is not consistent or a required element is missing.
IOException - if a retrieval of an xlink of one of the subelements failed.

parseGeodeticCRS

protected ICRS parseGeodeticCRS(org.apache.axiom.om.OMElement rootElement)
                         throws XMLParsingException,
                                IOException
Parameters:
rootElement - containing a gml:GeodeticCRS dom representation.
Returns:
a CRS instance initialized with values from the given XML-OM gml:GeodeticCRS fragment or null if the given root element is null. Note the result may be a CompoundCRS, a GeographicCRS or a GeocentricCRS, depending of the definition of the CS type.
Throws:
XMLParsingException
IOException

parseDatum

protected IGeodeticDatum parseDatum(org.apache.axiom.om.OMElement rootElement)
                             throws IOException,
                                    XMLParsingException
Parameters:
rootElement - containing a gml:GeodeticDatum dom representation.
Returns:
a GeodeticDatum instance initialized with values from the given XML-OM fragment or null if the given root element is null
Throws:
XMLParsingException - if the dom tree is not consistent or a required element is missing.
IOException - if a retrieval of an xlink of one of the subelements failed.

parseAxisFromCSType

protected IAxis[] parseAxisFromCSType(org.apache.axiom.om.OMElement rootElement)
                               throws XMLParsingException,
                                      IOException
For the ellipsoidal and cartesian cs Types, this method also checks the consistency of axis (radian, radian, [metre] ) or (metre, metre, [metre] ). If the conditions are not met, an xml parsing exception will be thrown as well.

Parameters:
rootElement - containing a (Ellipsoidal, Spherical, Cartesian) CS type dom representation.
Returns:
a Axis array instance initialized with values from the given XML-OM fragment or null if the given root element is null
Throws:
XMLParsingException - if the dom tree is not consistent or a required element is missing.
IOException - if a retrieval of an xlink of one of the subelements failed.

parseAxis

protected IAxis parseAxis(org.apache.axiom.om.OMElement rootElement)
                   throws XMLParsingException
Parameters:
rootElement - containing an gml:CoordinateSystemAxis type dom representation.
Returns:
an Axis instance initialized with values from the given XML-OM fragment or null if the given root element is null if the axis could not be mapped it's orientation will be Axis.AO_OTHER
Throws:
XMLParsingException - if the dom tree is not consistent or a required element is missing.

parseEllipsoid

protected IEllipsoid parseEllipsoid(org.apache.axiom.om.OMElement rootElement)
                             throws XMLParsingException
Parameters:
rootElement - containing a gml:Ellipsoid dom representation.
Returns:
a Ellipsoid instance initialized with values from the given XML-OM fragment or null if the given root element is null
Throws:
XMLParsingException - if the dom tree is not consistent or a required element is missing.

parsePrimeMeridian

protected IPrimeMeridian parsePrimeMeridian(org.apache.axiom.om.OMElement rootElement)
                                     throws XMLParsingException
Parameters:
rootElement - to create the pm from.
Returns:
PrimeMeridian.GREENWICH or the appropriate pm if a longitude is defined.
Throws:
XMLParsingException

parseVerticalCRS

protected IVerticalCRS parseVerticalCRS(org.apache.axiom.om.OMElement rootElement)
                                 throws XMLParsingException,
                                        IOException
Parameters:
rootElement - containing a gml:VerticalCRS dom representation.
Returns:
a VerticalCRS instance initialized with values from the given XML-OM fragment or null if the given root element is null
Throws:
IOException
XMLParsingException - if the dom tree is not consistent or a required element is missing.

parseVerticalDatum

protected IVerticalDatum parseVerticalDatum(org.apache.axiom.om.OMElement rootElement)
                                     throws XMLParsingException
Parameters:
rootElement - containing a gml:VerticalDatum dom representation.
Returns:
a VerticalDatum instance initialized with values from the given XML-OM fragment or null if the given root element is null
Throws:
XMLParsingException - if the dom tree is not consistent or a required element is missing.

parseProjection

protected IProjection parseProjection(org.apache.axiom.om.OMElement rootElement)
                               throws XMLParsingException,
                                      IOException
For now this method actually wraps all information in a gml:AbstractGeneralConversionType (or a derived subtype) into an CRSIdentifiable Object (used for the Projections).

Parameters:
rootElement - a gml:GeneralConversion element
Returns:
a Projection (Conversion) containing the mapped values from the given gml:Conversion XML-OM-representation.
Throws:
XMLParsingException - if the dom tree is not consistent or a required element is missing.
IOException

parseParameterValues

protected List<Pair<CRSIdentifiable,Object>> parseParameterValues(org.apache.axiom.om.OMElement rootElement)
                                                           throws XMLParsingException,
                                                                  IOException
Parameters:
rootElement - which should contain a list of parameter Value properties.
Returns:
a list of Pairs containing the parsed OperationParamter and the value as a double, converted to the units defined in the value element, or the empty list if the rootElement is null or no parameterValues were found.
Throws:
XMLParsingException - if the dom tree is not consistent or a required element is missing.
IOException

parseParameterValue

protected Pair<CRSIdentifiable,Object> parseParameterValue(org.apache.axiom.om.OMElement rootElement)
                                                    throws XMLParsingException,
                                                           IOException
Parameters:
rootElement - containing a parameter Value property.
Returns:
a Pair containing the parsed OperationParamter and the value as a double or null if the rootElement is null
Throws:
XMLParsingException - if the dom tree is not consistent or a required element is missing.
IOException

parseUnitOfMeasure

protected IUnit parseUnitOfMeasure(org.apache.axiom.om.OMElement elementContainingUOMAttribute)
                            throws XMLParsingException
Returns the unit defined by the uomAttribute given of the given element. This method will use a 'colon' heuristic to determine if the given uom is actually an urn (and thus represents an xlink-type). This will then be resolved and mapped onto an unit.

Parameters:
elementContainingUOMAttribute - an element containing the 'uom' attribute which will be mapped onto a known unit.
Returns:
the mapped Unit or null if the given uomAttribute is empty or null, or no appropriate mapping could be found.
Throws:
XMLParsingException

getRequiredXlinkedElement

protected org.apache.axiom.om.OMElement getRequiredXlinkedElement(org.apache.axiom.om.OMElement propertyElement,
                                                                  String alternativeXPath)
                                                           throws XMLParsingException,
                                                                  IOException
convenience method to retrieve a given required element either by resolving a optional xlink or by evaluating the required element denoted by the xpath.

Parameters:
propertyElement - to resolve an xlink from.
alternativeXPath - denoting a path to the required node starting from the given propertyElement.
Returns:
the dom-element in the xlink:href attribute of the given propertyElement or the required alternativeXPath element.
Throws:
XMLParsingException - if the given propertyElement is null or the resulting xml dom-tree could not be parsed or the alternative xpath does not result in an Element.
IOException - if the xlink could not be properly resolved

retrieveAndResolveXLink

protected org.apache.axiom.om.OMElement retrieveAndResolveXLink(org.apache.axiom.om.OMElement rootElement)
                                                         throws IOException
Retrieves the xlink:href of the given rootElement and use the XLinkResolver to resolve the xlink if it was given.

Parameters:
rootElement - to retrieve and resolve
Returns:
the resolved xlink:href attribute as an XML-OM element or null if the xlink could not be resolved (or was not given) or the rootElement is null.
Throws:
IOException

retrieveXLink

protected String retrieveXLink(org.apache.axiom.om.OMElement rootElement)
Find an xlink:href attribute and return it's value, if not found, the empty String will be returned.

Parameters:
rootElement - to get the attribute from.
Returns:
the trimmed xlink:href attribute value or the empty String if not found or the rootElement is null;

getDirectTransformation

public Transformation getDirectTransformation(ICRS sourceCRS,
                                              ICRS targetCRS)
                                       throws CRSConfigurationException
Description copied from interface: CRSStore
This method is should retrieve a transformation 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.

getCRSResource

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

Parameters:
id - string representation of the resource to retrieve
Returns:
the CRSResource 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.

init

public void init()
Description copied from interface: CRSStore
Called by the manager to indicate that this CRSStore instance is being registered.


setResolver

public void setResolver(GMLResource newResolver)
Set the resolver to the given resolver.

Parameters:
newResolver -

getResolver

protected GMLResource getResolver()
Returns:
the resolver for a type.

getCoordinateSystem

public ICRS getCoordinateSystem(String id)
Specified by:
getCoordinateSystem in class AbstractCRSStore
Returns:

getDirectTransformation

public Transformation getDirectTransformation(String uri)
                                       throws CRSConfigurationException
Description copied from interface: CRSStore
This method should retrieve a transformation with the given id. If a transformation with the given id could not be found null should be returned.

Parameters:
uri - the id of the transformation
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.


Copyright © 2011. All Rights Reserved.