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

org.deegree.model.spatialschema
Class GMLGeometryAdapter

java.lang.Object
  extended by org.deegree.model.spatialschema.GMLGeometryAdapter

public class GMLGeometryAdapter
extends java.lang.Object

Adapter class for converting GML geometries to deegree geometries and vice versa. Some logical problems result from the fact that an envelope isn't a geometry according to ISO 19107 (where the deegree geometry model is based on) but according to GML2/3 specification it is.
So if the wrap(..) method is called with an envelope a Surface will be returned representing the envelops shape. To export an Envelope to a GML box/envelope two specialized export methods are available.
The export method(s) doesn't return a DOM element as one may expect but a StringBuffer. This is done because the transformation from deegree geometries to GML mainly is required when a GML representation of a geometry shall be serialized to a file or to a network connection. For both cases the string representation is required and it is simply faster to create the string directly instead of first creating a DOM tree that after this must be serialized to a string.
In future version geometries will be serialized to a stream.

Version:
$Revision: 23371 $, $Date: 2010-04-01 10:32:28 +0200 (Do, 01 Apr 2010) $
Author:
Andreas Poth, Markus Schneider, last edited by: $Author: rbezema $

Field Summary
static CoordinateSystem EPSG4326
          This differs from GeographiCRS.WGS84 in the identifiers (equals fails for WGS84.equals(EPSG4326)).
 
Constructor Summary
GMLGeometryAdapter()
           
 
Method Summary
static java.lang.StringBuffer export(Geometry geometry)
          Creates a GML representation from the passed Geometry.
static java.io.PrintWriter export(Geometry geometry, java.io.OutputStream os)
          Writes the GML representation of the given Geometry to the given OutputStream.
static java.io.PrintWriter export(Geometry geometry, java.io.OutputStream os, java.lang.String id)
           
static java.io.PrintWriter export(Geometry geometry, java.io.PrintWriter pw)
          Writes the GML representation of the given Geometry to the given PrintWriter.
static java.io.PrintWriter export(Geometry geometry, java.io.PrintWriter pw, java.lang.String id)
           
static java.lang.StringBuffer export(Geometry geometry, java.lang.String id)
           
static java.lang.StringBuffer exportAsBox(Envelope envelope)
          creates a GML representation from the passed Envelope.
static java.lang.StringBuffer exportAsEnvelope(Envelope envelope)
          creates a GML representation from the passed Envelope.
static void exportMultiGeometry(MultiGeometry multiGeometry, java.io.PrintWriter pw)
          Exports the given MultiGeometry as a gml:MultiGeometry element.
static void exportMultiGeometry(MultiGeometry multiGeometry, java.io.PrintWriter pw, java.lang.String id)
          Exports the given MultiGeometry as a gml:MultiGeometry element.
static boolean isGeometrieSupported(java.lang.String localName)
          Returns true if the given localName !
static boolean swap(Envelope env)
           
static Geometry wrap(org.w3c.dom.Element gml)
          Deprecated. this method cannot provide default SRS information, please use wrap(Element,String) instead
static Geometry wrap(org.w3c.dom.Element element, java.lang.String srsName)
          Parses the given DOM element of a GML geometry and returns a corresponding deegree Geometry object.
static Geometry wrap(java.lang.String gml)
          Deprecated. this method cannot provide default SRS information, please use wrap(String,String) instead
static Geometry wrap(java.lang.String gml, java.lang.String srsName)
          Converts the given string representation of a GML geometry object to a corresponding deegree Geometry.
static Envelope wrapBox(org.w3c.dom.Element element)
          Deprecated. this method cannot provide default SRS information, please use wrapBox(Element,String) instead
static Envelope wrapBox(org.w3c.dom.Element element, java.lang.String srsName)
          Returns an instance of Envelope created from the passed gml:Box or gml:Envelope element.
static Surface wrapBoxAsSurface(org.w3c.dom.Element element, java.lang.String srsName)
          Returns a Surface created from the given gml:Box element.
static CompositeSurface wrapCompositeSurface(org.w3c.dom.Element element, java.lang.String srsName)
          Returns an instance of CompositeSurface created from the passed gml:CompositeSurface element.
static Curve wrapCurveAsCurve(org.w3c.dom.Element element, java.lang.String srsName)
          Returns an instance of Curve created from the passed gml:Curve element.
static Curve wrapLinearRing(org.w3c.dom.Element element, java.lang.String srsName)
          Parses the given gml:LinearRing element as a Curve.
static Curve wrapLineString(org.w3c.dom.Element element, java.lang.String srsName)
          Returns a Curve instance created from the passed gml:LineString element.
static MultiCurve wrapMultiCurveAsMultiCurve(org.w3c.dom.Element element, java.lang.String srsName)
          Parses the given gml:MultiCurve element as a MultiCurve.
static MultiGeometry wrapMultiGeometry(org.w3c.dom.Element element, java.lang.String srsName)
          Creates an instance of MultiGeometry from the passed gml:MultiGeometry element.
static MultiCurve wrapMultiLineString(org.w3c.dom.Element element, java.lang.String srsName)
          Returns a MultiCurve instance created from the passed gml:MultiLineString element.
static MultiPoint wrapMultiPoint(org.w3c.dom.Element element, java.lang.String srsName)
          Returns a MultiPoint instance created from the passed gml:MultiPoint element.
static MultiSurface wrapMultiPolygon(org.w3c.dom.Element element, java.lang.String srsName)
          Returns a MultiSurface instance created from the passed gml:MultiPolygon element.
static MultiSurface wrapMultiSurfaceAsMultiSurface(org.w3c.dom.Element element, java.lang.String srsName)
          Parses the given gml:MultiSurface element as a MultiSurface.
static Point wrapPoint(org.w3c.dom.Element element, java.lang.String srsName)
          Returns a Point instance created from the passed gml:Point element.
static Surface wrapPolygon(org.w3c.dom.Element element, java.lang.String srsName)
          Parses the given gml:Polygon element as a Surface.
static Curve wrapRing(org.w3c.dom.Element element, java.lang.String srsName)
          Parses the given gml:Ring element as a Curve.
static Surface wrapSurfaceAsSurface(org.w3c.dom.Element element, java.lang.String srsName)
          Returns an instance of Surface created from the passed gml:Surface element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EPSG4326

public static CoordinateSystem EPSG4326
This differs from GeographiCRS.WGS84 in the identifiers (equals fails for WGS84.equals(EPSG4326)).

Constructor Detail

GMLGeometryAdapter

public GMLGeometryAdapter()
Method Detail

isGeometrieSupported

public static boolean isGeometrieSupported(java.lang.String localName)
Returns true if the given localName != null or empty and matches one of the following:

Parameters:
localName - name to check
Returns:
true if localName equals (ignore-case) one of the above strings

wrap

public static Geometry wrap(org.w3c.dom.Element element,
                            java.lang.String srsName)
                     throws GeometryException
Parses the given DOM element of a GML geometry and returns a corresponding deegree Geometry object.

Notice that GML boxes will be converted to surfaces because in ISO 19107 envelopes are no geometries. Rings are returned as Curve objects.

Currently, the following geometry elements are supported:

Geometry element name
(in gml namespace)
Return type
(deegree Geometry)
Box/Envelope Envelope
CompositeSurface CompositeSurface
Curve Curve
LinearRing Curve
LineString Curve
MultiCurve MultiCurve
MultiGeometry MultiGeometry
MultiLineString MultiCurve
MultiPoint MultiPoint
MultiPolygon MultiSurface
MultiSurface MultiSurface
Point/Center Point
Polygon Surface
Ring Curve
Surface Surface

Parameters:
element - gml geometry element
srsName - default SRS for the geometry
Returns:
corresponding Geometry instance
Throws:
GeometryException - if type unsupported or parsing / conversion failed

wrap

public static Geometry wrap(java.lang.String gml,
                            java.lang.String srsName)
                     throws GeometryException,
                            XMLParsingException
Converts the given string representation of a GML geometry object to a corresponding deegree Geometry. Notice that GML Boxes will be converted to Surfaces because in ISO 19107 Envelopes are no geometries.

Parameters:
gml -
srsName - default SRS for the geometry (may be overwritten in geometry elements)
Returns:
corresponding geometry object
Throws:
GeometryException
XMLParsingException
See Also:
wrap(Element, String)

wrapBox

public static Envelope wrapBox(org.w3c.dom.Element element,
                               java.lang.String srsName)
                        throws XMLParsingException,
                               InvalidGMLException,
                               UnknownCRSException
Returns an instance of Envelope created from the passed gml:Box or gml:Envelope element.

Parameters:
element - gml:Box or gml:Envelope element
srsName - default SRS for the geometry
Returns:
instance of Envelope
Throws:
XMLParsingException
InvalidGMLException
UnknownCRSException

wrapCurveAsCurve

public static Curve wrapCurveAsCurve(org.w3c.dom.Element element,
                                     java.lang.String srsName)
                              throws XMLParsingException,
                                     GeometryException,
                                     UnknownCRSException
Returns an instance of Curve created from the passed gml:Curve element.

Parameters:
element - gml:Curve element
srsName - default SRS for the geometry
Returns:
corresponding Curve instance
Throws:
XMLParsingException
GeometryException
UnknownCRSException

wrapSurfaceAsSurface

public static Surface wrapSurfaceAsSurface(org.w3c.dom.Element element,
                                           java.lang.String srsName)
                                    throws XMLParsingException,
                                           GeometryException,
                                           UnknownCRSException
Returns an instance of Surface created from the passed gml:Surface element.

Parameters:
element -
srsName - default SRS for the geometry
Returns:
Surface
Throws:
XMLParsingException
GeometryException
UnknownCRSException

wrapPoint

public static Point wrapPoint(org.w3c.dom.Element element,
                              java.lang.String srsName)
                       throws XMLParsingException,
                              InvalidGMLException,
                              UnknownCRSException
Returns a Point instance created from the passed gml:Point element.

Parameters:
element - gml:Point element
srsName - default SRS for the geometry
Returns:
instance of Point
Throws:
XMLParsingException
InvalidGMLException
UnknownCRSException

wrapLineString

public static Curve wrapLineString(org.w3c.dom.Element element,
                                   java.lang.String srsName)
                            throws XMLParsingException,
                                   GeometryException,
                                   InvalidGMLException,
                                   UnknownCRSException
Returns a Curve instance created from the passed gml:LineString element.

Parameters:
element - gml:LineString element
srsName - default SRS for the geometry
Returns:
instance of Curve
Throws:
XMLParsingException
GeometryException
InvalidGMLException
UnknownCRSException

wrapPolygon

public static Surface wrapPolygon(org.w3c.dom.Element element,
                                  java.lang.String srsName)
                           throws XMLParsingException,
                                  GeometryException,
                                  InvalidGMLException,
                                  UnknownCRSException
Parses the given gml:Polygon element as a Surface.

Parameters:
element - gml:Polygon element
srsName - default SRS for the geometry
Returns:
corresponding Surface instance
Throws:
XMLParsingException
GeometryException
InvalidGMLException
UnknownCRSException

wrapLinearRing

public static Curve wrapLinearRing(org.w3c.dom.Element element,
                                   java.lang.String srsName)
                            throws XMLParsingException,
                                   GeometryException,
                                   InvalidGMLException,
                                   UnknownCRSException
Parses the given gml:LinearRing element as a Curve.

Parameters:
element -
srsName -
Returns:
a polygon containing the ring
Throws:
XMLParsingException
GeometryException
InvalidGMLException
UnknownCRSException

wrapRing

public static Curve wrapRing(org.w3c.dom.Element element,
                             java.lang.String srsName)
                      throws XMLParsingException,
                             GeometryException,
                             UnknownCRSException,
                             InvalidGMLException
Parses the given gml:Ring element as a Curve.

Parameters:
element - gml:Ring element
srsName - default SRS for the geometry
Returns:
corresponding Curve instance
Throws:
XMLParsingException
GeometryException
UnknownCRSException
InvalidGMLException

wrapMultiPoint

public static MultiPoint wrapMultiPoint(org.w3c.dom.Element element,
                                        java.lang.String srsName)
                                 throws XMLParsingException,
                                        InvalidGMLException,
                                        UnknownCRSException
Returns a MultiPoint instance created from the passed gml:MultiPoint element.

Parameters:
element - gml:MultiPoint element
srsName - default SRS for the geometry
Returns:
instance of MultiPoint
Throws:
XMLParsingException
InvalidGMLException
UnknownCRSException

wrapMultiLineString

public static MultiCurve wrapMultiLineString(org.w3c.dom.Element element,
                                             java.lang.String srsName)
                                      throws XMLParsingException,
                                             GeometryException,
                                             InvalidGMLException,
                                             UnknownCRSException
Returns a MultiCurve instance created from the passed gml:MultiLineString element.

Parameters:
element - gml:MultiLineString element
srsName - default SRS for the geometry
Returns:
instance of MultiCurve
Throws:
XMLParsingException
GeometryException
InvalidGMLException
UnknownCRSException

wrapMultiCurveAsMultiCurve

public static MultiCurve wrapMultiCurveAsMultiCurve(org.w3c.dom.Element element,
                                                    java.lang.String srsName)
                                             throws XMLParsingException,
                                                    GeometryException,
                                                    UnknownCRSException,
                                                    InvalidGMLException
Parses the given gml:MultiCurve element as a MultiCurve.

Parameters:
element - gml:MultiCurve element
srsName - default SRS for the geometry
Returns:
corresponding MultiCurve instance
Throws:
XMLParsingException
GeometryException
UnknownCRSException
InvalidGMLException

wrapMultiSurfaceAsMultiSurface

public static MultiSurface wrapMultiSurfaceAsMultiSurface(org.w3c.dom.Element element,
                                                          java.lang.String srsName)
                                                   throws XMLParsingException,
                                                          GeometryException,
                                                          UnknownCRSException,
                                                          InvalidGMLException
Parses the given gml:MultiSurface element as a MultiSurface.

Parameters:
element - gml:MultiSurface element
srsName - default SRS for the geometry
Returns:
corresponding MultiSurface instance
Throws:
XMLParsingException
GeometryException
UnknownCRSException
InvalidGMLException

wrapMultiPolygon

public static MultiSurface wrapMultiPolygon(org.w3c.dom.Element element,
                                            java.lang.String srsName)
                                     throws XMLParsingException,
                                            GeometryException,
                                            InvalidGMLException,
                                            UnknownCRSException
Returns a MultiSurface instance created from the passed gml:MultiPolygon element.

Parameters:
element - gml:MultiPolygon element
srsName - default SRS for the geometry
Returns:
instance of MultiCurve
Throws:
XMLParsingException
GeometryException
InvalidGMLException
UnknownCRSException

wrapMultiGeometry

public static MultiGeometry wrapMultiGeometry(org.w3c.dom.Element element,
                                              java.lang.String srsName)
                                       throws XMLParsingException,
                                              UnknownCRSException,
                                              GeometryException
Creates an instance of MultiGeometry from the passed gml:MultiGeometry element.

Parameters:
element - gml:MultiGeometry element
srsName - default SRS for the geometry
Returns:
MultiSurface
Throws:
XMLParsingException
GeometryException
UnknownCRSException
GeometryException

wrapBoxAsSurface

public static Surface wrapBoxAsSurface(org.w3c.dom.Element element,
                                       java.lang.String srsName)
                                throws XMLParsingException,
                                       GeometryException,
                                       InvalidGMLException,
                                       UnknownCRSException
Returns a Surface created from the given gml:Box element. This method is useful because an Envelope that would normally be created from a Box isn't a geometry in context of ISO 19107.

Parameters:
element - gml:Box element
srsName -
Returns:
instance of Surface
Throws:
XMLParsingException
GeometryException
InvalidGMLException
UnknownCRSException

wrapCompositeSurface

public static CompositeSurface wrapCompositeSurface(org.w3c.dom.Element element,
                                                    java.lang.String srsName)
Returns an instance of CompositeSurface created from the passed gml:CompositeSurface element. TODO

Parameters:
element -
srsName - default SRS for the geometry
Returns:
CompositeSurface

export

public static java.io.PrintWriter export(Geometry geometry,
                                         java.io.OutputStream os)
                                  throws GeometryException
Writes the GML representation of the given Geometry to the given OutputStream.

Currently, the Geometry realizations are handled:

Parameters:
geometry - geometry to be exported
os - target OutputStream
Returns:
a PrintWriter created from the OutputStream
Throws:
GeometryException

export

public static java.io.PrintWriter export(Geometry geometry,
                                         java.io.OutputStream os,
                                         java.lang.String id)
                                  throws GeometryException
Parameters:
geometry -
os -
id -
Returns:
a PrintWriter created from the OutputStream
Throws:
GeometryException

export

public static java.io.PrintWriter export(Geometry geometry,
                                         java.io.PrintWriter pw)
                                  throws GeometryException
Writes the GML representation of the given Geometry to the given PrintWriter.

Currently, the Geometry realizations are handled:

Parameters:
geometry - geometry to be exported
pw - target PrintWriter
Returns:
same as input PrintWriter
Throws:
GeometryException

export

public static java.io.PrintWriter export(Geometry geometry,
                                         java.io.PrintWriter pw,
                                         java.lang.String id)
                                  throws GeometryException
Parameters:
geometry -
pw -
id -
Returns:
same as input PrintWriter
Throws:
GeometryException

export

public static java.lang.StringBuffer export(Geometry geometry)
                                     throws GeometryException
Creates a GML representation from the passed Geometry.

Parameters:
geometry -
Returns:
a string buffer containing the XML
Throws:
GeometryException

export

public static java.lang.StringBuffer export(Geometry geometry,
                                            java.lang.String id)
                                     throws GeometryException
Parameters:
geometry -
id -
Returns:
a string buffer containing the XML
Throws:
GeometryException

exportAsBox

public static java.lang.StringBuffer exportAsBox(Envelope envelope)
creates a GML representation from the passed Envelope. This method is required because in ISO 19107 Envelops are no geometries.

Parameters:
envelope -
Returns:
the stringbuffer filled with the envelope.

exportAsEnvelope

public static java.lang.StringBuffer exportAsEnvelope(Envelope envelope)
creates a GML representation from the passed Envelope. This method is required because in ISO 19107 Envelops are no geometries.

Parameters:
envelope -
Returns:
the String representation of the given envelope

exportMultiGeometry

public static void exportMultiGeometry(MultiGeometry multiGeometry,
                                       java.io.PrintWriter pw)
                                throws GeometryException
Exports the given MultiGeometry as a gml:MultiGeometry element.

Parameters:
multiGeometry -
pw -
Throws:
GeometryException

exportMultiGeometry

public static void exportMultiGeometry(MultiGeometry multiGeometry,
                                       java.io.PrintWriter pw,
                                       java.lang.String id)
                                throws GeometryException
Exports the given MultiGeometry as a gml:MultiGeometry element.

Parameters:
multiGeometry -
pw -
id -
Throws:
GeometryException

wrap

@Deprecated
public static Geometry wrap(java.lang.String gml)
                     throws GeometryException,
                            XMLParsingException
Deprecated. this method cannot provide default SRS information, please use wrap(String,String) instead

Converts the string representation of a GML geometry object to a corresponding Geometry. Notice that GML Boxes will be converted to Surfaces because in ISO 19107 Envelopes are no geometries.

Parameters:
gml -
Returns:
corresponding geometry object
Throws:
GeometryException
XMLParsingException

wrap

@Deprecated
public static Geometry wrap(org.w3c.dom.Element gml)
                     throws GeometryException
Deprecated. this method cannot provide default SRS information, please use wrap(Element,String) instead

Converts a GML geometry object to a corresponding Geometry. Notice that GML Boxes will be converted to Surfaces because in ISO 19107 Envelops are no geometries.

Currently, the following conversions are supported:

Parameters:
gml -
Returns:
the corresponding Geometry
Throws:
GeometryException - if type unsupported or conversion failed

wrapBox

@Deprecated
public static Envelope wrapBox(org.w3c.dom.Element element)
                        throws XMLParsingException,
                               InvalidGMLException,
                               UnknownCRSException
Deprecated. this method cannot provide default SRS information, please use wrapBox(Element,String) instead

returns a Envelope created from Box element

Parameters:
element -
Returns:
instance of Envelope
Throws:
XMLParsingException
InvalidGMLException
UnknownCRSException

swap

public static boolean swap(Envelope env)
Parameters:
env -
Returns:
true, if configuration and environment say yes to swapping

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