deegree 2.5 (2011/06/29 09:44 build-8-official)

org.deegree.crs.configuration.gml
Class GMLCRSProvider

java.lang.Object
  extended by org.deegree.crs.configuration.AbstractCRSProvider<org.w3c.dom.Element>
      extended by org.deegree.crs.configuration.gml.GMLCRSProvider
All Implemented Interfaces:
CRSProvider

public class GMLCRSProvider
extends AbstractCRSProvider<org.w3c.dom.Element>

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: 27765 $, $Date: 2010-11-04 07:50:32 +0100 (Do, 04 Nov 2010) $
Author:
Rutger Bezema, last edited by: $Author: lbuesching $

Nested Class Summary
 
Nested classes/interfaces inherited from class org.deegree.crs.configuration.AbstractCRSProvider
AbstractCRSProvider.SupportedProjectionParameters, AbstractCRSProvider.SupportedProjections, AbstractCRSProvider.SupportedTransformationParameters, AbstractCRSProvider.SupportedTransformations
 
Constructor Summary
GMLCRSProvider(java.util.Properties properties)
          The 'default constructor' which will be called by the CRSConfiguration
 
Method Summary
 boolean canExport()
           
 void export(java.lang.StringBuilder sb, java.util.List<CoordinateSystem> crsToExport)
          Exports the crs to the implemented format.
 java.util.List<java.lang.String> getAvailableCRSIds()
          This method should be called if one is only interested in the available identifiers and not in the coordinatesystems themselves.
 java.util.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.
 Identifiable getIdentifiable(java.lang.String id)
          This method is more general than the CRSProvider.getCRSByID(String), because it represents a possibility to return an arbitrary Identifiable Object from the providers backend.
protected  org.w3c.dom.Element getRequiredXlinkedElement(org.w3c.dom.Element propertyElement, java.lang.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.
 java.util.List<java.lang.String[]> getSortedAvailableCRSIds()
          This method should be called if one is only interested in the available identifiers and not in the coordinatesystems themselves.
 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.
 java.util.List<Transformation> getTransformations()
           
protected  Axis parseAxis(org.w3c.dom.Element rootElement)
           
protected  Axis[] parseAxisFromCSType(org.w3c.dom.Element rootElement)
          For the ellipsoidal and cartesian cs Types, this method also checks the consistency of axis (radian, radian, [metre] ) or (metre, metre, [metre] ).
protected  CompoundCRS parseCompoundCRS(org.w3c.dom.Element rootElement)
          This methods parses the given element and maps it onto a CompoundCRS.
protected  CoordinateSystem parseCoordinateSystem(org.w3c.dom.Element rootElement)
           
protected  GeodeticDatum parseDatum(org.w3c.dom.Element rootElement)
           
protected  Ellipsoid parseEllipsoid(org.w3c.dom.Element rootElement)
           
protected  CoordinateSystem parseGeodeticCRS(org.w3c.dom.Element rootElement)
           
protected  Transformation parseGMLTransformation(org.w3c.dom.Element rootElement)
          Parses some of the gml 3.2 transformation constructs.
 Identifiable parseIdentifiedObject(org.w3c.dom.Element rootElement)
           
protected  Pair<Identifiable,Pair<Unit,java.lang.Double>> parseParameterValue(org.w3c.dom.Element rootElement)
           
protected  java.util.List<Pair<Identifiable,Pair<Unit,java.lang.Double>>> parseParameterValues(org.w3c.dom.Element rootElement)
           
protected  PrimeMeridian parsePrimeMeridian(org.w3c.dom.Element rootElement)
           
protected  CoordinateSystem parseProjectedCRS(org.w3c.dom.Element rootElement)
           
protected  Projection parseProjection(org.w3c.dom.Element rootElement, GeographicCRS underlyingCRS)
          For now this method actually wraps all information in a gml:AbstractGeneralConversionType (or a derived subtype) into an Identifiable Object (used for the Projections).
 Transformation parseTransformation(org.w3c.dom.Element rootElement)
          Calls parseGMLTransformation for the catching of XMLParsingException.
protected  Unit parseUnitOfMeasure(org.w3c.dom.Element elementContainingUOMAttribute)
          Returns the unit defined by the uomAttribute given of the given element.
protected  VerticalCRS parseVerticalCRS(org.w3c.dom.Element rootElement)
           
protected  VerticalDatum parseVerticalDatum(org.w3c.dom.Element rootElement)
           
protected  org.w3c.dom.Element retrieveAndResolveXLink(org.w3c.dom.Element rootElement)
          Retrieves the xlink:href of the given rootElement and use the XLinkResolver to resolve the xlink if it was given.
protected  java.lang.String retrieveXLink(org.w3c.dom.Element rootElement)
          Find an xlink:href attribute and return it's value, if not found, the empty String will be returned.
 
Methods inherited from class org.deegree.crs.configuration.AbstractCRSProvider
addIdToCache, clearCache, getCachedIdentifiable, getCachedIdentifiable, getCachedIdentifiable, getCachedIdentifiable, getCRSByID, getResolver, mapProjectionParameters, mapProjections, mapTransformation, mapTransformationParameters, setResolver
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GMLCRSProvider

public GMLCRSProvider(java.util.Properties properties)
The 'default constructor' which will be called by the CRSConfiguration

Parameters:
properties - the properties which can hold information about the configuration of this GML provider.
Method Detail

canExport

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

export

public void export(java.lang.StringBuilder sb,
                   java.util.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()

getSortedAvailableCRSIds

public java.util.List<java.lang.String[]> getSortedAvailableCRSIds()
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:
a list of string arrays. Each string array contains the identifiers of one configured CRS.

getAvailableCRSIds

public java.util.List<java.lang.String> getAvailableCRSIds()
                                                    throws CRSConfigurationException
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.
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 java.util.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(org.w3c.dom.Element rootElement)
                                          throws CRSConfigurationException
Specified by:
parseCoordinateSystem in class AbstractCRSProvider<org.w3c.dom.Element>
Parameters:
rootElement - containing a gml:CRS dom representation.
Returns:
a CoordinateSystem instance initialized with values from the given xml-dom gml:CRS fragment or null if the given root element is null
Throws:
CRSConfigurationException - if something went wrong.

parseTransformation

public Transformation parseTransformation(org.w3c.dom.Element rootElement)
                                   throws CRSConfigurationException
Calls parseGMLTransformation for the catching of XMLParsingException.

Specified by:
parseTransformation in class AbstractCRSProvider<org.w3c.dom.Element>
Parameters:
rootElement - 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

parseGMLTransformation

protected Transformation parseGMLTransformation(org.w3c.dom.Element rootElement)
                                         throws XMLParsingException,
                                                java.io.IOException
Parses some of the gml 3.2 transformation constructs. Currently only helmert transformations are supported.

Parameters:
rootElement -
Returns:
the transformation.
Throws:
XMLParsingException
java.io.IOException

parseIdentifiedObject

public Identifiable parseIdentifiedObject(org.w3c.dom.Element rootElement)
                                   throws XMLParsingException
Parameters:
rootElement - which is a subtype of gml:IdentifiedObject and gml:DefinitionType or gml:AbstractCRSType
Returns:
the Identifiable 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 CompoundCRS parseCompoundCRS(org.w3c.dom.Element rootElement)
                                throws XMLParsingException,
                                       java.io.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(Element)

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

parseProjectedCRS

protected CoordinateSystem parseProjectedCRS(org.w3c.dom.Element rootElement)
                                      throws XMLParsingException,
                                             java.io.IOException
Parameters:
rootElement - containing a gml:ProjectedCRS dom representation.
Returns:
a ProjectedCRS instance initialized with values from the given xml-dom 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.
java.io.IOException - if a retrieval of an xlink of one of the subelements failed.

parseGeodeticCRS

protected CoordinateSystem parseGeodeticCRS(org.w3c.dom.Element rootElement)
                                     throws XMLParsingException,
                                            java.io.IOException
Parameters:
rootElement - containing a gml:GeodeticCRS dom representation.
Returns:
a CoordinateSystem instance initialized with values from the given xml-dom 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
java.io.IOException

parseDatum

protected GeodeticDatum parseDatum(org.w3c.dom.Element rootElement)
                            throws java.io.IOException,
                                   XMLParsingException
Parameters:
rootElement - containing a gml:GeodeticDatum dom representation.
Returns:
a GeodeticDatum instance initialized with values from the given xml-dom 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.
java.io.IOException - if a retrieval of an xlink of one of the subelements failed.

parseAxisFromCSType

protected Axis[] parseAxisFromCSType(org.w3c.dom.Element rootElement)
                              throws XMLParsingException,
                                     java.io.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-dom 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.
java.io.IOException - if a retrieval of an xlink of one of the subelements failed.

parseAxis

protected Axis parseAxis(org.w3c.dom.Element rootElement)
                  throws XMLParsingException
Parameters:
rootElement - containing an gml:CoordinateSystemAxis type dom representation.
Returns:
an Axis instance initialized with values from the given xml-dom 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 Ellipsoid parseEllipsoid(org.w3c.dom.Element rootElement)
                            throws XMLParsingException
Parameters:
rootElement - containing a gml:Ellipsoid dom representation.
Returns:
a Ellipsoid instance initialized with values from the given xml-dom 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 PrimeMeridian parsePrimeMeridian(org.w3c.dom.Element 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 VerticalCRS parseVerticalCRS(org.w3c.dom.Element rootElement)
                                throws XMLParsingException,
                                       java.io.IOException
Parameters:
rootElement - containing a gml:VerticalCRS dom representation.
Returns:
a VerticalCRS instance initialized with values from the given xml-dom fragment or null if the given root element is null
Throws:
java.io.IOException
XMLParsingException - if the dom tree is not consistent or a required element is missing.

parseVerticalDatum

protected VerticalDatum parseVerticalDatum(org.w3c.dom.Element rootElement)
                                    throws XMLParsingException
Parameters:
rootElement - containing a gml:VerticalDatum dom representation.
Returns:
a VerticalDatum instance initialized with values from the given xml-dom 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 Projection parseProjection(org.w3c.dom.Element rootElement,
                                     GeographicCRS underlyingCRS)
                              throws XMLParsingException,
                                     java.io.IOException
For now this method actually wraps all information in a gml:AbstractGeneralConversionType (or a derived subtype) into an Identifiable Object (used for the Projections).

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

parseParameterValues

protected java.util.List<Pair<Identifiable,Pair<Unit,java.lang.Double>>> parseParameterValues(org.w3c.dom.Element rootElement)
                                                                                       throws XMLParsingException,
                                                                                              java.io.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.
java.io.IOException

parseParameterValue

protected Pair<Identifiable,Pair<Unit,java.lang.Double>> parseParameterValue(org.w3c.dom.Element rootElement)
                                                                      throws XMLParsingException,
                                                                             java.io.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.
java.io.IOException

parseUnitOfMeasure

protected Unit parseUnitOfMeasure(org.w3c.dom.Element 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.w3c.dom.Element getRequiredXlinkedElement(org.w3c.dom.Element propertyElement,
                                                        java.lang.String alternativeXPath)
                                                 throws XMLParsingException,
                                                        java.io.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.
java.io.IOException - if the xlink could not be properly resolved

retrieveAndResolveXLink

protected org.w3c.dom.Element retrieveAndResolveXLink(org.w3c.dom.Element rootElement)
                                               throws java.io.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-dom element or null if the xlink could not be resolved (or was not given) or the rootElement is null.
Throws:
java.io.IOException

getIdentifiable

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

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

retrieveXLink

protected java.lang.String retrieveXLink(org.w3c.dom.Element 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;

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.

getTransformations

public java.util.List<Transformation> getTransformations()
Returns:
a list of all available transformations

deegree 2.5 (2011/06/29 09:44 build-8-official)

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