org.deegree_impl.model.feature
Class GMLFeatureAdapter

java.lang.Object
  extended byorg.deegree_impl.model.feature.GMLFeatureAdapter

public class GMLFeatureAdapter
extends java.lang.Object

Version:
$Revision: 1.7 $
Author:
Andreas Poth

Field Summary
private static java.util.HashMap crsMap
           
 
Constructor Summary
GMLFeatureAdapter()
           
 
Method Summary
private static GM_Envelope createBoundedBy(org.w3c.dom.Element element)
          returns the boundingbox of the feature
private static Feature createFeature(org.w3c.dom.Element element)
          creates an instance of a deegree feature from a contrete gml:_Feature node
private static FeatureType createFeatureType(org.w3c.dom.Element element)
          returns an instance of a FeatureType describig the passed feature (element)
private static GM_Object createGeometry(org.w3c.dom.Element element)
           
private static GM_Curve createLineString(org.w3c.dom.Element element)
          returns an instance of a curve created from the passed
private static GM_MultiCurve createMultiLineString(org.w3c.dom.Element element)
          returns an instance of a multi point created from the passed
private static GM_MultiPoint createMultiPoint(org.w3c.dom.Element element)
          returns an instance of a multi point created from the passed
private static GM_MultiSurface createMultiSurface(org.w3c.dom.Element element)
          returns an instance of a multi point created from the passed
private static GM_Point createPoint(org.w3c.dom.Element element)
          returns an instance of a point created from the passed
private static GM_Surface createPolygon(org.w3c.dom.Element element)
          returns an instance of a surface created from the passed
private static GM_Position createPositionFromCoord(org.w3c.dom.Element element)
          returns an instance of GM_Position created from the passed coord
static GM_Position[] createPositionFromCoordinates(org.w3c.dom.Element element)
          returns an array of GM_Positions created from the passed coordinates
static void export(FeatureCollection fc, java.util.Map namespaces, java.util.Map prefixes, java.util.Map schemaRef, java.io.OutputStream os)
          exports an instance of a FeatureCollection to the passed OutputStream formatted as GML.
static void export(FeatureCollection fc, java.util.Map namespaces, java.util.Map prefixes, java.util.Map schemaRef, java.io.OutputStream os, java.lang.String charsetName)
          exports an instance of a FeatureCollection to the passed OutputStream formatted as GML.
static void export(FeatureCollection fc, java.io.OutputStream os)
          exports an instance of a FeatureCollection to the passed OutputStream formatted as GML.
static void export(Feature feature, java.util.Map prefixes, java.io.PrintWriter pw)
          exports a Feature to the passed PrintWriter
private static CS_CoordinateSystem getCRS(java.lang.String name)
          returns an instance of CS_CoordinateSystem corrsponding to the passed crs name
private static boolean isFeatureCollection(org.w3c.dom.Element element)
          returns true if the passed element encapsulates a feature collection
private static boolean isGeometryProperty(org.w3c.dom.Element element)
          returns true if the submitted element contains just excatly one childelement that have to be a geometry
static void main(java.lang.String[] args)
           
private static void openRootElement(Feature feature, java.util.Map namespaces, java.util.Map prefixes, java.util.Map schemaRef, java.io.PrintWriter pw)
          Opens a PrintWriter from the passed OutputStream and writes the XML header and the opening root element of the GML document to it
private static void printFeatureCollection(FeatureCollection fc, java.util.Map prefixes, java.io.PrintWriter pw)
          prints the passed FeatureCollection to the also passed PrintWriter formatted as GMLs
private static void printGeometry(GM_Object geo, java.io.PrintWriter pw)
          prints the passed geometry to the also passed PrintWriter formatted as GML
static FeatureCollection wrap(org.w3c.dom.Element root)
           
static FeatureCollection wrap(java.io.Reader reader)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

crsMap

private static java.util.HashMap crsMap
Constructor Detail

GMLFeatureAdapter

public GMLFeatureAdapter()
Method Detail

wrap

public static FeatureCollection wrap(java.io.Reader reader)
                              throws java.io.IOException,
                                     XMLParsingException,
                                     GM_Exception
Parameters:
reader -
Returns:
Throws:
java.io.IOException
XMLParsingException
GM_Exception

wrap

public static FeatureCollection wrap(org.w3c.dom.Element root)
                              throws XMLParsingException,
                                     GM_Exception
Parameters:
root - root element of a GML document
Returns:
instance of a FeatureCollection
Throws:
XMLParsingException
GM_Exception

export

public static void export(FeatureCollection fc,
                          java.io.OutputStream os)
                   throws java.io.IOException,
                          FeatureException
exports an instance of a FeatureCollection to the passed OutputStream formatted as GML. Uses UTF-8 as character set for the created XML/GML

Parameters:
fc - feature collection to export
os - output stream to write to
Throws:
java.io.IOException
FeatureException

export

public static void export(FeatureCollection fc,
                          java.util.Map namespaces,
                          java.util.Map prefixes,
                          java.util.Map schemaRef,
                          java.io.OutputStream os)
                   throws java.io.IOException,
                          FeatureException
exports an instance of a FeatureCollection to the passed OutputStream formatted as GML. The passed Maps may be empty but they are not allowed to be null. Uses UTF-8 as character set for the created XML/GML

Parameters:
fc - feature collection to export
namespaces - namespaces of the different feature types contained in the feature collection.
prefixes - prefixes of the elements to be used. gml: will be used for GML-namespace; xlink: will be used for XLink ns.
schemaRef - references to the application schemas the features of the collection beloangs to. The feature type names will be used as keys
os - output stream to write to
Throws:
java.io.IOException
FeatureException

export

public static void export(FeatureCollection fc,
                          java.util.Map namespaces,
                          java.util.Map prefixes,
                          java.util.Map schemaRef,
                          java.io.OutputStream os,
                          java.lang.String charsetName)
                   throws java.io.IOException,
                          FeatureException
exports an instance of a FeatureCollection to the passed OutputStream formatted as GML. The passed Maps may be empty but they are not allowed to be null.

Parameters:
fc - feature collection to export
namespaces - namespaces of the different feature types contained in the feature collection.
prefixes - prefixes of the elements to be used. gml: will be used for GML-namespace; xlink: will be used for XLink ns.
schemaRef - references to the application schemas the features of the collection beloangs to. The feature type names will be used as keys
os - output stream to write to
charsetName - The name of the used charset/encoding
Throws:
java.io.IOException
FeatureException

openRootElement

private static void openRootElement(Feature feature,
                                    java.util.Map namespaces,
                                    java.util.Map prefixes,
                                    java.util.Map schemaRef,
                                    java.io.PrintWriter pw)
                             throws java.io.IOException,
                                    FeatureException
Opens a PrintWriter from the passed OutputStream and writes the XML header and the opening root element of the GML document to it

Parameters:
feature - feature to export
namespaces - namespaces of the different feature types contained in the feature collection.
prefixes - prefixes of the elements to be used. gml: will be used for GML-namespace; xlink: will be used for XLink ns.
schemaRef - references to the application schemas the features of the collection beloangs to. The feature type names will be used as keys
pw - PrintWriter to write to
Throws:
java.io.IOException
FeatureException

export

public static void export(Feature feature,
                          java.util.Map prefixes,
                          java.io.PrintWriter pw)
                   throws java.io.IOException,
                          FeatureException
exports a Feature to the passed PrintWriter

Parameters:
feature - feature to export
prefixes - prefixes of the elements to be used. gml: will be used for GML-namespace; xlink: will be used for XLink ns.
pw - PrintWriter to write to
Throws:
java.io.IOException
FeatureException

printFeatureCollection

private static void printFeatureCollection(FeatureCollection fc,
                                           java.util.Map prefixes,
                                           java.io.PrintWriter pw)
                                    throws java.io.IOException,
                                           FeatureException
prints the passed FeatureCollection to the also passed PrintWriter formatted as GMLs

Parameters:
fc - feature collection to print/export
prefixes - Map containing prefixes for the XML Elements to create
pw - target of the printing/export
Throws:
java.io.IOException
FeatureException

printGeometry

private static void printGeometry(GM_Object geo,
                                  java.io.PrintWriter pw)
                           throws FeatureException
prints the passed geometry to the also passed PrintWriter formatted as GML

Parameters:
geo - geometry to print/extport
pw - target of the printing/export
Throws:
FeatureException

createFeature

private static Feature createFeature(org.w3c.dom.Element element)
                              throws XMLParsingException,
                                     GM_Exception
creates an instance of a deegree feature from a contrete gml:_Feature node

Parameters:
element -
Returns:
instance of Feature
Throws:
XMLParsingException
GM_Exception

createFeatureType

private static FeatureType createFeatureType(org.w3c.dom.Element element)
                                      throws XMLParsingException
returns an instance of a FeatureType describig the passed feature (element)

Parameters:
element -
Returns:
instance of FeatureType
Throws:
XMLParsingException

isFeatureCollection

private static boolean isFeatureCollection(org.w3c.dom.Element element)
returns true if the passed element encapsulates a feature collection


isGeometryProperty

private static boolean isGeometryProperty(org.w3c.dom.Element element)
returns true if the submitted element contains just excatly one childelement that have to be a geometry


createBoundedBy

private static GM_Envelope createBoundedBy(org.w3c.dom.Element element)
                                    throws XMLParsingException
returns the boundingbox of the feature

Parameters:
element -
Returns:
instance of GM_Envelope
Throws:
XMLParsingException

createGeometry

private static GM_Object createGeometry(org.w3c.dom.Element element)
                                 throws XMLParsingException,
                                        GM_Exception
Parameters:
element -
Returns:
Throws:
XMLParsingException
GM_Exception

createPositionFromCoord

private static GM_Position createPositionFromCoord(org.w3c.dom.Element element)
                                            throws XMLParsingException
returns an instance of GM_Position created from the passed coord

Parameters:
element -
Returns:
instance of GM_Position
Throws:
XMLParsingException

createPositionFromCoordinates

public static GM_Position[] createPositionFromCoordinates(org.w3c.dom.Element element)
                                                   throws XMLParsingException
returns an array of GM_Positions created from the passed coordinates

Parameters:
element -
Returns:
instance of GM_Position[]
Throws:
XMLParsingException

getCRS

private static CS_CoordinateSystem getCRS(java.lang.String name)
returns an instance of CS_CoordinateSystem corrsponding to the passed crs name

Parameters:
name - name of the crs
Returns:

createPoint

private static GM_Point createPoint(org.w3c.dom.Element element)
                             throws XMLParsingException
returns an instance of a point created from the passed

Parameters:
element -
Returns:
instance of GM_Point
Throws:
XMLParsingException

createLineString

private static GM_Curve createLineString(org.w3c.dom.Element element)
                                  throws XMLParsingException,
                                         GM_Exception
returns an instance of a curve created from the passed

Parameters:
element -
Returns:
instance of GM_Curve
Throws:
XMLParsingException
GM_Exception

createPolygon

private static GM_Surface createPolygon(org.w3c.dom.Element element)
                                 throws XMLParsingException,
                                        GM_Exception
returns an instance of a surface created from the passed

Parameters:
element -
Returns:
instance of GM_Surface
Throws:
XMLParsingException
GM_Exception

createMultiPoint

private static GM_MultiPoint createMultiPoint(org.w3c.dom.Element element)
                                       throws XMLParsingException,
                                              GM_Exception
returns an instance of a multi point created from the passed

Parameters:
element -
Returns:
instance of GM_MultiPoint
Throws:
XMLParsingException
GM_Exception

createMultiLineString

private static GM_MultiCurve createMultiLineString(org.w3c.dom.Element element)
                                            throws XMLParsingException,
                                                   GM_Exception
returns an instance of a multi point created from the passed

Parameters:
element -
Returns:
instance of GM_MultiCurve
Throws:
XMLParsingException
GM_Exception

createMultiSurface

private static GM_MultiSurface createMultiSurface(org.w3c.dom.Element element)
                                           throws XMLParsingException,
                                                  GM_Exception
returns an instance of a multi point created from the passed

Parameters:
element -
Returns:
instance of GM_MultiCurve
Throws:
XMLParsingException
GM_Exception

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception