deegree 2.3 (2010/04/09 10:10 build-4-official)

org.deegree.crs.configuration.deegree
Class CRSParser

java.lang.Object
  extended by org.deegree.framework.xml.XMLFragment
      extended by org.deegree.crs.configuration.resources.XMLFileResource
          extended by org.deegree.crs.configuration.deegree.CRSParser
All Implemented Interfaces:
Serializable, CRSResource<Element>, XMLResource, XLinkResolver<Element>
Direct Known Subclasses:
CRSParser_0_1_0

public class CRSParser
extends XMLFileResource

The CRSParser class TODO add class documentation here.

Version:
$Revision: 20382 $, $Date: 2009-10-27 12:27:31 +0100 (Di, 27. Okt 2009) $
Author:
Rutger Bezema, last edited by: $Author: mschneider $
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.deegree.framework.xml.XMLFragment
DEFAULT_URL, nsContext, XLNNS
 
Constructor Summary
CRSParser(DeegreeCRSProvider provider, Element rootElement)
           
CRSParser(DeegreeCRSProvider provider, Properties properties)
           
CRSParser(DeegreeCRSProvider provider, Properties properties, String defaultRootElement, String namespace)
           
 
Method Summary
protected
<T extends Identifiable>
T
checkForUniqueness(List<T> uniqueList, Map<String,String> mapping, T toBeChecked)
           
protected  Helmert getConversionInfoFromID(String infoID)
           
protected  Ellipsoid getEllipsoidFromID(String ellipsoidID)
          Tries to find a cached ellipsoid, if not found, the config will be checked.
protected  GeodeticDatum getGeodeticDatumFromID(String datumID)
           
protected  PrimeMeridian getPrimeMeridianFromID(String meridianID)
           
 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(Element transformationElement)
          Parses the transformation variables from the given crs:coordinatesystem/crs:polynomialTransformation element.
 Element 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<PolynomialTransformation> parseAlternativeTransformations(Element crsElement)
          Parse all polynomial transformations for a given crs.
protected  Axis[] parseAxisOrder(Element crsElement)
          Creates an axis array for the given crs element.
protected  CoordinateSystem parseCompoundCRS(Element crsElement)
           
 CoordinateSystem parseCoordinateSystem(Element crsDefintion)
           
protected  CoordinateSystem parseGeocentricCRS(Element crsElement)
           
protected  CoordinateSystem parseGeographicCRS(Element crsElement)
           
protected  Identifiable parseIdentifiable(Element element)
          Parses all elements of the identifiable object.
 Identifiable parseIdentifiableObject(String id)
          Gets the Element for the given id and heuristically check the localname of the resulting root Element.
protected  CoordinateSystem parseProjectedCRS(Element crsElement)
           
protected  Projection parseProjection(Element projectionElement, GeographicCRS underlyingCRS, Unit units)
          Parses and instantiates the projection from the given element.
protected  GeodeticDatum parseReferencedGeodeticDatum(Element parentElement, String parentID)
          Parses the required usedDatum element from the given parentElement (probably a crs element).
 Transformation parseTransformation(Element transformationDefinition)
          Retrieves a transformation from the resource.
protected  Unit parseUnit(Element 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.framework.xml.XMLFragment
getAsPrettyString, getAsString, getAttachedSchemas, getQualifiedName, getRootElement, getSystemId, hasSchema, load, load, load, parseQualifiedName, parseSimpleLink, prettyPrint, prettyPrint, resolve, setRootElement, setSystemId, setSystemId, toString, write, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CRSParser

public CRSParser(DeegreeCRSProvider provider,
                 Element rootElement)
Parameters:
provider - to be used for callback.
rootElement - to be used for the configuration.

CRSParser

public CRSParser(DeegreeCRSProvider provider,
                 Properties properties)
Parameters:
provider -
properties -

CRSParser

public CRSParser(DeegreeCRSProvider provider,
                 Properties properties,
                 String defaultRootElement,
                 String namespace)
Parameters:
provider -
properties -
defaultRootElement -
namespace -
Method Detail

parseCoordinateSystem

public CoordinateSystem parseCoordinateSystem(Element crsDefintion)
                                       throws CRSConfigurationException
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 Element getURIAsType(String uri)
                     throws IOException
Description copied from interface: XLinkResolver
Opens a stream to a resource which is defined by the uri.

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

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
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 Identifiable parseIdentifiable(Element 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(Element 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(Element transformationDefinition)
Retrieves a transformation from the resource.

Parameters:
transformationDefinition -
Returns:
the parsed transformation or null if no transformation could be parsed.

parseAlternativeTransformations

protected List<PolynomialTransformation> parseAlternativeTransformations(Element 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(Element 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(Element 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(Element 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(Element 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(Element 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(Element 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(Element 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.

getGeodeticDatumFromID

protected GeodeticDatum getGeodeticDatumFromID(String datumID)
                                        throws CRSConfigurationException
Parameters:
datumID -
Returns:
the
Throws:
CRSConfigurationException

getPrimeMeridianFromID

protected PrimeMeridian getPrimeMeridianFromID(String meridianID)
                                        throws CRSConfigurationException
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.

getEllipsoidFromID

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

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(Element 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

checkForUniqueness

protected <T extends Identifiable> T checkForUniqueness(List<T> uniqueList,
                                                        Map<String,String> mapping,
                                                        T toBeChecked)
Type Parameters:
T - should be at least of Type Identifiable.
Parameters:
uniqueList - to check against
mapping - to added the id of T to if it is found duplicate.
toBeChecked - to check.
Returns:
the cached T if found or the given identifiable.

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

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 Identifiable 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

Parameters:
id - to look for.
Returns:
the instantiated Identifiable or null if it could not be parsed.

deegree 2.3 (2010/04/09 10:10 build-4-official)

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