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

org.deegree.crs.configuration.deegree.xml.om
Class Parser

java.lang.Object
  extended by org.deegree.commons.xml.XMLAdapter
      extended by org.deegree.crs.configuration.resources.XMLFileResource
          extended by org.deegree.crs.configuration.deegree.xml.om.Parser
All Implemented Interfaces:
CRSParser<org.apache.axiom.om.OMElement>, CRSResource<org.apache.axiom.om.OMElement>, XLinkResolver<org.apache.axiom.om.OMElement>, XMLResource

public class Parser
extends XMLFileResource
implements CRSParser<org.apache.axiom.om.OMElement>

The CRSParser class TODO add class documentation here.

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

Field Summary
 
Fields inherited from class org.deegree.commons.xml.XMLAdapter
DEFAULT_URL, nsContext, rootElement, XLN_NS
 
Constructor Summary
Parser(DeegreeCRSProvider<org.apache.axiom.om.OMElement> provider, org.apache.axiom.om.OMElement rootElement)
           
Parser(DeegreeCRSProvider<org.apache.axiom.om.OMElement> provider, Properties properties)
           
Parser(DeegreeCRSProvider<org.apache.axiom.om.OMElement> provider, Properties properties, String defaultRootElement, String namespace)
           
 
Method Summary
 List<CRSCodeType[]> getAvailableCRSCodes()
           
protected  Helmert getConversionInfoFromID(String infoID)
           
 Ellipsoid getEllipsoidForId(String ellipsoidID)
          Tries to find a cached ellipsoid, if not found, the config will be checked.
 GeodeticDatum getGeodeticDatumForId(String datumID)
           
 PrimeMeridian getPrimeMeridianForId(String meridianID)
           
 Projection getProjectionForId(String usedProjection, GeographicCRS underlyingCRS)
           
 Transformation getTransformation(CoordinateSystem sourceCRS, CoordinateSystem targetCRS)
          Implementations should find a given transformation (chain) which transforms coordinates of the given coordinate system into coordinates of the target crs.
protected  PolynomialTransformation getTransformation(org.apache.axiom.om.OMElement transformationElement)
          Parses the transformation variables from the given crs:coordinatesystem/crs:polynomialTransformation element.
 org.apache.axiom.om.OMElement getURIAsType(String uri)
          Opens a stream to a resource which is defined by the uri.
 String getVersion()
           
 Helmert getWGS84Transformation(GeographicCRS sourceCRS)
          Implementations should find the helmert transformation which transforms coordinates of the geodetic datum into coordinates of the WGS84 datum.
protected  List<Transformation> parseAlternativeTransformations(org.apache.axiom.om.OMElement crsElement)
          Parse all polynomial transformations for a given crs.
protected  Axis[] parseAxisOrder(org.apache.axiom.om.OMElement crsElement)
          Creates an axis array for the given crs element.
protected  CoordinateSystem parseCompoundCRS(org.apache.axiom.om.OMElement crsElement)
           
 CoordinateSystem parseCoordinateSystem(org.apache.axiom.om.OMElement crsDefintion)
           
protected  CoordinateSystem parseGeocentricCRS(org.apache.axiom.om.OMElement crsElement)
           
protected  CoordinateSystem parseGeographicCRS(org.apache.axiom.om.OMElement crsElement)
           
protected  CRSIdentifiable parseIdentifiable(org.apache.axiom.om.OMElement element)
          Parses all elements of the identifiable object.
 CRSIdentifiable parseIdentifiableObject(String id)
          Gets the Element for the given id and heuristically check the localname of the resulting root Element.
protected  CoordinateSystem parseProjectedCRS(org.apache.axiom.om.OMElement crsElement)
           
protected  Projection parseProjection(org.apache.axiom.om.OMElement projectionElement, GeographicCRS underlyingCRS, Unit units)
          Parses and instantiates the projection from the given element.
protected  GeodeticDatum parseReferencedGeodeticDatum(org.apache.axiom.om.OMElement parentElement, String parentID)
          Parses the required usedDatum element from the given parentElement (probably a crs element).
 Transformation parseTransformation(org.apache.axiom.om.OMElement transformationDefinition)
          Retrieves a transformation from the resource.
protected  Unit parseUnit(org.apache.axiom.om.OMElement parent)
          Parses a unit from the given xml-parent.
 
Methods inherited from class org.deegree.crs.configuration.resources.XMLFileResource
getProvider
 
Methods inherited from class org.deegree.commons.xml.XMLAdapter
evaluateXPath, getElement, getElements, getNamespaceContext, getNode, getNodeAsBoolean, getNodeAsDouble, getNodeAsFloat, getNodeAsInt, getNodeAsQName, getNodeAsString, getNodeAsURL, getNodeAsVersion, getNodes, getNodesAsQNames, getNodesAsStrings, getRequiredElement, getRequiredElements, getRequiredNode, getRequiredNodeAsBoolean, getRequiredNodeAsDouble, getRequiredNodeAsFloat, getRequiredNodeAsInteger, getRequiredNodeAsQName, getRequiredNodeAsString, getRequiredNodeAsURL, getRequiredNodeAsVersion, getRequiredNodes, getRootElement, getSchemas, getSystemId, hasSchemas, load, load, load, load, load, maybeWriteElement, maybeWriteElementNS, parseBoolean, parseDouble, parseFloat, parseInt, parseQName, parseSimpleLink, parseURL, resolve, setRootElement, setSystemId, toString, writeElement, writeElement, writeElement, writeElement, writeElement, writeOptionalAttribute, writeOptionalElement, writeOptionalNSAttribute
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Parser

public Parser(DeegreeCRSProvider<org.apache.axiom.om.OMElement> provider,
              org.apache.axiom.om.OMElement rootElement)
Parameters:
provider - to be used for callback.
rootElement - to be used for the configuration.

Parser

public Parser(DeegreeCRSProvider<org.apache.axiom.om.OMElement> provider,
              Properties properties)
Parameters:
provider -
properties -

Parser

public Parser(DeegreeCRSProvider<org.apache.axiom.om.OMElement> provider,
              Properties properties,
              String defaultRootElement,
              String namespace)
Parameters:
provider -
properties -
defaultRootElement -
namespace -
Method Detail

parseCoordinateSystem

public CoordinateSystem parseCoordinateSystem(org.apache.axiom.om.OMElement crsDefintion)
                                       throws CRSConfigurationException
Specified by:
parseCoordinateSystem in interface CRSParser<org.apache.axiom.om.OMElement>
Parameters:
crsDefintion - to be parsed
Returns:
an instance of the given crs or null if the crsDefinition is null or could not be mapped to a valid type.
Throws:
CRSConfigurationException - if something went wrong while constructing the crs.

getURIAsType

public org.apache.axiom.om.OMElement getURIAsType(String uri)
                                           throws IOException
Description copied from interface: XLinkResolver
Opens a stream to a resource which is defined by the uri.

Specified by:
getURIAsType in interface XLinkResolver<org.apache.axiom.om.OMElement>
Parameters:
uri - to locate
Returns:
an opened InputStream to the given resource or null if no resource was found.
Throws:
IOException - If an error occurred while locating or opening the resource.

getWGS84Transformation

public Helmert getWGS84Transformation(GeographicCRS sourceCRS)
Description copied from interface: CRSResource
Implementations should find the helmert transformation which transforms coordinates of the geodetic datum into coordinates of the WGS84 datum. If no such transformation could be found, the implementation should return null

Specified by:
getWGS84Transformation in interface CRSResource<org.apache.axiom.om.OMElement>
Parameters:
sourceCRS - to retrieve the transformation for.
Returns:
the Helmert transformation or null if no such transformation was defined.

getVersion

public String getVersion()
                  throws CRSConfigurationException
Specified by:
getVersion in interface CRSParser<org.apache.axiom.om.OMElement>
Returns:
the version of the root element of the empty string if no version attribute was found in the root element.
Throws:
CRSConfigurationException - if the root element is empty

parseIdentifiable

protected CRSIdentifiable parseIdentifiable(org.apache.axiom.om.OMElement element)
                                     throws CRSConfigurationException
Parses all elements of the identifiable object.

Parameters:
element - the xml-representation of the id-object
Returns:
the identifiable object or null if no id was given.
Throws:
CRSConfigurationException

parseAxisOrder

protected Axis[] parseAxisOrder(org.apache.axiom.om.OMElement crsElement)
                         throws CRSConfigurationException
Creates an axis array for the given crs element.

Parameters:
crsElement - to be parsed
Returns:
an Array of axis defining their order.
Throws:
CRSConfigurationException - if a required element could not be found, or an xmlParsingException occurred, or the axisorder uses names which were not defined in the axis elements.

parseTransformation

public Transformation parseTransformation(org.apache.axiom.om.OMElement transformationDefinition)
Retrieves a transformation from the resource.

Specified by:
parseTransformation in interface CRSParser<org.apache.axiom.om.OMElement>
Parameters:
transformationDefinition -
Returns:
the parsed transformation or null if no transformation could be parsed.

parseAlternativeTransformations

protected List<Transformation> parseAlternativeTransformations(org.apache.axiom.om.OMElement crsElement)
Parse all polynomial transformations for a given crs.

Parameters:
crsElement - to parse the transformations for.
Returns:
the list of transformations or the empty list if no transformations were found. Never null.

getTransformation

protected PolynomialTransformation getTransformation(org.apache.axiom.om.OMElement transformationElement)
Parses the transformation variables from the given crs:coordinatesystem/crs:polynomialTransformation element. If the class attribute is given, this method will try to invoke an instance of the given class, if it fails null will be returned.

Parameters:
transformationElement - to parse the values from.
Returns:
the instantiated transformation or null if it could not be instantiated.

parseUnit

protected Unit parseUnit(org.apache.axiom.om.OMElement parent)
                  throws CRSConfigurationException
Parses a unit from the given xml-parent.

Parameters:
parent - xml-node to parse the unit from.
Returns:
the unit object.
Throws:
CRSConfigurationException - if the unit object could not be created.

parseProjectedCRS

protected CoordinateSystem parseProjectedCRS(org.apache.axiom.om.OMElement crsElement)
                                      throws CRSConfigurationException
Parameters:
crsElement - from which the crs is to be created (using chached datums, conversioninfos and projections).
Returns:
a projected coordinatesystem based on the given xml-element.
Throws:
CRSConfigurationException - if a required element could not be found, or an xmlParsingException occurred.

parseGeographicCRS

protected CoordinateSystem parseGeographicCRS(org.apache.axiom.om.OMElement crsElement)
                                       throws CRSConfigurationException
Parameters:
crsElement - from which the crs is to be created (using cached datums, conversioninfos and projections).
Returns:
a geographic coordinatesystem based on the given xml-element.
Throws:
CRSConfigurationException - if a required element could not be found, or an xmlParsingException occurred.

parseGeocentricCRS

protected CoordinateSystem parseGeocentricCRS(org.apache.axiom.om.OMElement crsElement)
                                       throws CRSConfigurationException
Parameters:
crsElement - from which the crs is to be created (using cached datums, conversioninfos and projections).
Returns:
a geocentric coordinatesystem based on the given xml-element.
Throws:
CRSConfigurationException - if a required element could not be found, or an xmlParsingException occurred.

parseCompoundCRS

protected CoordinateSystem parseCompoundCRS(org.apache.axiom.om.OMElement crsElement)
Parameters:
crsElement - from which the crs is to be created.
Returns:
a compound coordinatesystem based on the given xml-element.
Throws:
CRSConfigurationException - if a required element could not be found, or an xmlParsingException occurred.

parseReferencedGeodeticDatum

protected GeodeticDatum parseReferencedGeodeticDatum(org.apache.axiom.om.OMElement parentElement,
                                                     String parentID)
                                              throws CRSConfigurationException
Parses the required usedDatum element from the given parentElement (probably a crs element).

Parameters:
parentElement - to parse the required usedDatum element from.
parentID - optional for an appropriate error message.
Returns:
the Datum.
Throws:
CRSConfigurationException - if a parsing error occurred, the node was not defined or an illegal id reference (not found) was given.

getGeodeticDatumForId

public GeodeticDatum getGeodeticDatumForId(String datumID)
                                    throws CRSConfigurationException
Specified by:
getGeodeticDatumForId in interface CRSParser<org.apache.axiom.om.OMElement>
Parameters:
datumID -
Returns:
the
Throws:
CRSConfigurationException

getPrimeMeridianForId

public PrimeMeridian getPrimeMeridianForId(String meridianID)
                                    throws CRSConfigurationException
Specified by:
getPrimeMeridianForId in interface CRSParser<org.apache.axiom.om.OMElement>
Parameters:
meridianID - the id to search for.
Returns:
the primeMeridian with given id or null
Throws:
CRSConfigurationException - if the longitude was not set or the units could not be parsed.

getEllipsoidForId

public Ellipsoid getEllipsoidForId(String ellipsoidID)
                            throws CRSConfigurationException
Tries to find a cached ellipsoid, if not found, the config will be checked.

Specified by:
getEllipsoidForId in interface CRSParser<org.apache.axiom.om.OMElement>
Parameters:
ellipsoidID -
Returns:
an ellipsoid or null if no ellipsoid with given id was found, or the id was null or empty.
Throws:
CRSConfigurationException - if something went wrong.

getConversionInfoFromID

protected Helmert getConversionInfoFromID(String infoID)
                                   throws CRSConfigurationException
Parameters:
infoID - to get the conversioninfo from.
Returns:
the configured wgs84 conversion info parameters.
Throws:
CRSConfigurationException

parseProjection

protected Projection parseProjection(org.apache.axiom.om.OMElement projectionElement,
                                     GeographicCRS underlyingCRS,
                                     Unit units)
                              throws CRSConfigurationException
Parses and instantiates the projection from the given element.

Parameters:
projectionElement - to create the projection from.
underlyingCRS - of the projected crs
units - of the projected crs
Returns:
the configured projection or null if not defined or found.
Throws:
CRSConfigurationException

getTransformation

public Transformation getTransformation(CoordinateSystem sourceCRS,
                                        CoordinateSystem targetCRS)
Description copied from interface: CRSResource
Implementations should find a given transformation (chain) which transforms coordinates of the given coordinate system into coordinates of the target crs. If no such transformation could be found, the implementation should return null

Specified by:
getTransformation in interface CRSResource<org.apache.axiom.om.OMElement>
Parameters:
sourceCRS - start point of the transformation.
targetCRS - end point of the transformations
Returns:
the Transformation or null if no such transformation was defined.

parseIdentifiableObject

public CRSIdentifiable parseIdentifiableObject(String id)
Gets the Element for the given id and heuristically check the localname of the resulting root Element. This version supports following local names (see schema):
  • ellipsoid
  • geodeticDatum
  • projectedCRS
  • geographicCRS
  • compoundCRS
  • geocentricCRS
  • primeMeridian
  • wgs84Transformation

Specified by:
parseIdentifiableObject in interface CRSParser<org.apache.axiom.om.OMElement>
Parameters:
id - to look for.
Returns:
the instantiated CRSIdentifiable or null if it could not be parsed.

getAvailableCRSCodes

public List<CRSCodeType[]> getAvailableCRSCodes()
                                         throws CRSConfigurationException
Specified by:
getAvailableCRSCodes in interface CRSParser<org.apache.axiom.om.OMElement>
Returns:
all available codetypes
Throws:
CRSConfigurationException

getProjectionForId

public Projection getProjectionForId(String usedProjection,
                                     GeographicCRS underlyingCRS)
Specified by:
getProjectionForId in interface CRSParser<org.apache.axiom.om.OMElement>
Parameters:
usedProjection - of the projection
underlyingCRS - of the projection
Returns:
the projection denoted by the given id, or null if no such projection could be loaded.

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

]]>