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

org.deegree.model.feature
Class GMLFeatureDocument

java.lang.Object
  extended by org.deegree.framework.xml.XMLFragment
      extended by org.deegree.ogcbase.GMLDocument
          extended by org.deegree.model.feature.GMLFeatureDocument
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
GMLFeatureCollectionDocument

public class GMLFeatureDocument
extends GMLDocument

Parser and wrapper class for GML feature documents.

Validation
Has validation capabilities: if the schema is provided or the document contains a reference to a schema the structure of the generated features is checked. If no schema information is available, feature + property types are heuristically determined from the feature instance in the document (guessing of simple property types can be turned off, because it may cause unwanted effects).

XLinks
Has some basic understanding of XLink: Supports internal XLinks (i.e. the content for a feature is given by a reference to a feature element in the same document). No support for external XLinks yet.

Propagation of srsName attribute

Version:
$Revision: 18195 $, $Date: 2009-06-18 17:55:39 +0200 (Do, 18. Jun 2009) $
Author:
Markus Schneider , last edited by: $Author: mschneider $
See Also:
Serialized Form

Field Summary
protected  Map<String,Feature> featureMap
           
protected  Map<URI,GMLSchema> gmlSchemaMap
           
protected  Collection<XLinkedFeatureProperty> xlinkPropertyList
           
 
Fields inherited from class org.deegree.framework.xml.XMLFragment
DEFAULT_URL, nsContext, XLNNS
 
Constructor Summary
GMLFeatureDocument()
          Creates a new instance of GMLFeatureDocument.
GMLFeatureDocument(boolean guessSimpleTypes)
          Creates a new instance of GMLFeatureDocument.
 
Method Summary
protected  FeatureType getFeatureType(QualifiedName ftName)
          Returns the feature type with the given name.
protected  Map<URI,GMLSchema> getGMLSchemas()
          Determines and retrieves the GML schemas that the document refers to.
protected  GMLSchema getSchemaForNamespace(URI ns)
          Returns the GML schema for the given namespace.
 Feature parseFeature()
          Returns the object representation for the root feature element.
protected  Feature parseFeature(Element element)
          Returns the object representation for the given feature element.
protected  Feature parseFeature(Element element, String srsName)
          Returns the object representation for the given feature element.
 Feature parseFeature(String defaultSRS)
          Returns the object representation for the root feature element.
protected  String parseFeatureId(Element featureElement)
          Parses the feature id attribute from the given feature element.
 FeatureProperty parseProperty(Element propertyElement, FeatureType ft)
          Returns the object representation for the given property element.
 FeatureProperty parseProperty(Element propertyElement, FeatureType ft, String srsName)
          Returns the object representation for the given property element.
protected  void resolveXLinkReferences()
           
 void setSchemas(Map<URI,GMLSchema> gmlSchemaMap)
          Explicitly sets the GML schema information that the document must comply to.
 
Methods inherited from class org.deegree.ogcbase.GMLDocument
parseEnvelope, parseGrid, parsePos, parseTimePosition
 
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
 

Field Detail

gmlSchemaMap

protected Map<URI,GMLSchema> gmlSchemaMap

featureMap

protected Map<String,Feature> featureMap

xlinkPropertyList

protected Collection<XLinkedFeatureProperty> xlinkPropertyList
Constructor Detail

GMLFeatureDocument

public GMLFeatureDocument()
Creates a new instance of GMLFeatureDocument.

Simple types encountered during parsing are "guessed", i.e. the parser tries to convert the values to double, integer, calendar, etc. However, this may lead to unwanted results, e.g. a property value of "054604" is converted to "54604".


GMLFeatureDocument

public GMLFeatureDocument(boolean guessSimpleTypes)
Creates a new instance of GMLFeatureDocument.

Parameters:
guessSimpleTypes - set to true, if simple types should be "guessed" during parsing
Method Detail

setSchemas

public void setSchemas(Map<URI,GMLSchema> gmlSchemaMap)
Explicitly sets the GML schema information that the document must comply to.

This overrides any schema information that the document refers to.

Parameters:
gmlSchemaMap - key: namespace URI, value: GMLSchema

parseFeature

public Feature parseFeature()
                     throws XMLParsingException,
                            UnknownCRSException
Returns the object representation for the root feature element.

Returns:
object representation for the root feature element.
Throws:
XMLParsingException
UnknownCRSException

parseFeature

public Feature parseFeature(String defaultSRS)
                     throws XMLParsingException,
                            UnknownCRSException
Returns the object representation for the root feature element.

Parameters:
defaultSRS - default SRS for all a descendant geometry properties
Returns:
object representation for the root feature element.
Throws:
XMLParsingException
UnknownCRSException

parseFeature

protected Feature parseFeature(Element element)
                        throws XMLParsingException,
                               UnknownCRSException
Returns the object representation for the given feature element.

Parameters:
element - feature element
Returns:
object representation for the given feature element.
Throws:
XMLParsingException
UnknownCRSException

parseFeature

protected Feature parseFeature(Element element,
                               String srsName)
                        throws XMLParsingException,
                               UnknownCRSException
Returns the object representation for the given feature element.

Parameters:
element - feature element
srsName - default SRS for all descendant geometry properties
Returns:
object representation for the given feature element
Throws:
XMLParsingException
UnknownCRSException

parseProperty

public FeatureProperty parseProperty(Element propertyElement,
                                     FeatureType ft)
                              throws XMLParsingException,
                                     UnknownCRSException
Returns the object representation for the given property element.

Parameters:
propertyElement - property element
ft - feature type of the feature that the property belongs to
Returns:
object representation for the given property element
Throws:
XMLParsingException
UnknownCRSException

parseProperty

public FeatureProperty parseProperty(Element propertyElement,
                                     FeatureType ft,
                                     String srsName)
                              throws XMLParsingException,
                                     UnknownCRSException
Returns the object representation for the given property element.

Parameters:
propertyElement - property element
ft - feature type of the feature that the property belongs to
srsName - default SRS for all a descendant geometry properties
Returns:
object representation for the given property element.
Throws:
XMLParsingException
UnknownCRSException

resolveXLinkReferences

protected void resolveXLinkReferences()
                               throws XMLParsingException
Throws:
XMLParsingException

getGMLSchemas

protected Map<URI,GMLSchema> getGMLSchemas()
                                    throws XMLParsingException,
                                           UnknownCRSException
Determines and retrieves the GML schemas that the document refers to.

Returns:
the GML schemas that are attached to the document, keys are URIs (namespaces), values are GMLSchemas.
Throws:
XMLParsingException
UnknownCRSException

getSchemaForNamespace

protected GMLSchema getSchemaForNamespace(URI ns)
                                   throws XMLParsingException,
                                          UnknownCRSException
Returns the GML schema for the given namespace.

Parameters:
ns -
Returns:
the GML schema for the given namespace if it is declared, null otherwise.
Throws:
XMLParsingException
UnknownCRSException

getFeatureType

protected FeatureType getFeatureType(QualifiedName ftName)
                              throws XMLParsingException,
                                     UnknownCRSException
Returns the feature type with the given name.

If schema information is available and a feature type with the given name is not defined, an XMLParsingException is thrown.

Parameters:
ftName - feature type to look up
Returns:
the feature type with the given name if it is declared, null otherwise.
Throws:
XMLParsingException
UnknownCRSException

parseFeatureId

protected String parseFeatureId(Element featureElement)
Parses the feature id attribute from the given feature element.

Looks after 'gml:id' (GML 3 style) first, if no such attribute is present, the 'fid' (GML 2 style) attribute is used.

Parameters:
featureElement -
Returns:
the feature id, this is "" if neither a 'gml:id' nor a 'fid' attribute is present

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