deegree 2.2 (2008/12/22 11:33 build-3038-official)

org.deegree.model.spatialschema
Class GMLGeometryAdapter

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

public class GMLGeometryAdapter
extends Object

Adapter class for converting GML geometries to deegree geometries and vice versa. Some logical problems results 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: 11344 $, $Date: 2008-04-22 13:38:48 +0200 (Di, 22 Apr 2008) $
Author:
Andreas Poth, last edited by: $Author: rbezema $

Constructor Summary
GMLGeometryAdapter()
           
 
Method Summary
static StringBuffer export(Geometry geometry)
          Creates a GML representation from the passed Geometry.
static PrintWriter export(Geometry geometry, OutputStream target)
          Creates a GML representation from the passed Geometry
static StringBuffer exportAsBox(Envelope envelope)
          creates a GML representation from the passed Envelope.
static StringBuffer exportAsEnvelope(Envelope envelope)
          creates a GML representation from the passed Envelope.
static Geometry wrap(Element gml)
          Deprecated. this method cannot provide default SRS information, please use wrap(Element,String) instead
static Geometry wrap(Element element, String srsName)
          Converts the given DOM representation of a GML geometry to a corresponding Geometry.
static Geometry wrap(String gml)
          Deprecated. this method cannot provide default SRS information, please use wrap(String,String) instead
static Geometry wrap(String gml, String srsName)
          Converts the given string representation of a GML geometry object to a corresponding Geometry.
static Envelope wrapBox(Element element)
          Deprecated. this method cannot provide default SRS information, please use wrapBox(Element,String) instead
static Envelope wrapBox(Element element, String srsName)
          Returns an instance of Envelope created from the passed gml:Box or gml:Envelope element.
protected static Curve wrapCurveAsCurve(Element element, String srsName)
          Returns an instance of Curve created from the passed gml:Curve element.
protected static MultiCurve wrapMultiCurveAsMultiCurve(Element element, String srsName)
          Returns an instance of MultiCurve created from the passed gml:MultiCurve element.
protected static MultiSurface wrapMultiSurfaceAsMultiSurface(Element element, String srsName)
          Returns an instance of MultiSurface created from the passed gml:MultiSurface element.
protected static Surface wrapSurfaceAsSurface(Element element, 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
 

Constructor Detail

GMLGeometryAdapter

public GMLGeometryAdapter()
Method Detail

wrap

public static Geometry wrap(String gml,
                            String srsName)
                     throws GeometryException,
                            XMLParsingException
Converts the given 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 -
srsName - default SRS for the geometry (may be overwritten in geometry elements)
Returns:
corresponding geometry object
Throws:
GeometryException
XMLParsingException

wrap

public static Geometry wrap(Element element,
                            String srsName)
                     throws GeometryException
Converts the given DOM representation of a GML geometry to a corresponding Geometry. Notice that GML Boxes will be converted to Surfaces because in ISO 19107 Envelopes are no geometries.

Currently, the following conversions are supported:

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

wrapBox

public static Envelope wrapBox(Element element,
                               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

protected static Curve wrapCurveAsCurve(Element element,
                                        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

wrapMultiCurveAsMultiCurve

protected static MultiCurve wrapMultiCurveAsMultiCurve(Element element,
                                                       String srsName)
                                                throws XMLParsingException,
                                                       GeometryException,
                                                       UnknownCRSException,
                                                       InvalidGMLException
Returns an instance of MultiCurve created from the passed gml:MultiCurve element.

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

wrapSurfaceAsSurface

protected static Surface wrapSurfaceAsSurface(Element element,
                                              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

wrapMultiSurfaceAsMultiSurface

protected static MultiSurface wrapMultiSurfaceAsMultiSurface(Element element,
                                                             String srsName)
                                                      throws XMLParsingException,
                                                             GeometryException,
                                                             InvalidGMLException,
                                                             UnknownCRSException
Returns an instance of MultiSurface created from the passed gml:MultiSurface element.

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

export

public static PrintWriter export(Geometry geometry,
                                 OutputStream target)
                          throws GeometryException
Creates a GML representation from the passed Geometry

Parameters:
geometry -
target -
Throws:
GeometryException

export

public static 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

exportAsBox

public static 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:
Throws:
GeometryException

exportAsEnvelope

public static 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:
Throws:
GeometryException

wrap

@Deprecated
public static Geometry wrap(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(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:

  • GML Point -> Point
  • GML MultiPoint -> MultiPoint
  • GML LineString -> Curve
  • GML MultiLineString -> MultiCurve
  • GML Polygon -> Surface
  • GML MultiPolygon -> MultiSurface
  • GML Box -> Surface
  • GML Curve -> Curve
  • GML Surface -> Surface
  • GML MultiCurve -> MultiCurve
  • GML MultiSurface -> MultiSurface

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

wrapBox

@Deprecated
public static Envelope wrapBox(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

deegree 2.2 (2008/12/22 11:33 build-3038-official)

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