Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| deegree 2.4 (2010/11/11 10:47 build-27-official)
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.deegree.model.spatialschema
Class GMLGeometryAdapter

    java.lang.Object
      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 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 StringBuffer` | `export(Geometry geometry)` Creates a GML representation from the passed `Geometry`.
`static PrintWriter` | `export(Geometry geometry, OutputStream os)` Writes the GML representation of the given `Geometry` to the given `OutputStream`.
`static PrintWriter` | `export(Geometry geometry, OutputStream os, String id)`
`static PrintWriter` | `export(Geometry geometry, PrintWriter pw)` Writes the GML representation of the given `Geometry` to the given `PrintWriter`.
`static PrintWriter` | `export(Geometry geometry, PrintWriter pw, String id)`
`static StringBuffer` | `export(Geometry geometry, String id)`
`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 void` | `exportMultiGeometry(MultiGeometry multiGeometry, PrintWriter pw)` Exports the given `MultiGeometry` as a `gml:MultiGeometry` element.
`static void` | `exportMultiGeometry(MultiGeometry multiGeometry, PrintWriter pw, String id)` Exports the given `MultiGeometry` as a `gml:MultiGeometry` element.
`static boolean` | `isGeometrieSupported(String localName)` Returns true if the given localName !
`static boolean` | `swap(Envelope env)`
`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)` Parses the given DOM element of a GML geometry and returns a corresponding deegree `Geometry` object.
`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 deegree `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.
`static Surface` | `wrapBoxAsSurface(Element element, String srsName)` Returns a `Surface` created from the given `gml:Box` element.
`static CompositeSurface` | `wrapCompositeSurface(Element element, String srsName)` Returns an instance of `CompositeSurface` created from the passed `gml:CompositeSurface` element.
`static Curve` | `wrapCurveAsCurve(Element element, String srsName)` Returns an instance of `Curve` created from the passed `gml:Curve` element.
`static Curve` | `wrapLinearRing(Element element, String srsName)` Parses the given `gml:LinearRing` element as a `Curve`.
`static Curve` | `wrapLineString(Element element, String srsName)` Returns a `Curve` instance created from the passed `gml:LineString` element.
`static MultiCurve` | `wrapMultiCurveAsMultiCurve(Element element, String srsName)` Parses the given `gml:MultiCurve` element as a `MultiCurve`.
`static MultiGeometry` | `wrapMultiGeometry(Element element, String srsName)` Creates an instance of `MultiGeometry` from the passed `gml:MultiGeometry` element.
`static MultiCurve` | `wrapMultiLineString(Element element, String srsName)` Returns a `MultiCurve` instance created from the passed `gml:MultiLineString` element.
`static MultiPoint` | `wrapMultiPoint(Element element, String srsName)` Returns a `MultiPoint` instance created from the passed `gml:MultiPoint` element.
`static MultiSurface` | `wrapMultiPolygon(Element element, String srsName)` Returns a `MultiSurface` instance created from the passed `gml:MultiPolygon` element.
`static MultiSurface` | `wrapMultiSurfaceAsMultiSurface(Element element, String srsName)` Parses the given `gml:MultiSurface` element as a `MultiSurface`.
`static Point` | `wrapPoint(Element element, String srsName)` Returns a `Point` instance created from the passed `gml:Point` element.
`static Surface` | `wrapPolygon(Element element, String srsName)` Parses the given `gml:Polygon` element as a `Surface`.
`static Curve` | `wrapRing(Element element, String srsName)` Parses the given `gml:Ring` element as a `Curve`.
`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`

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(String localName)

  Returns true if the given localName != `null` or empty and matches one of the following:
  - Box (alternative name: Envelope)
  - CompositeSurface
  - Curve
  - LinearRing
  - LineString
  - MultiCurve
  - MultiGeometry
  - MultiLineString
  - MultiPoint
  - MultiPolygon
  - MultiSurface
  - Point (alternative name: Center)
  - Polygon
  - Ring
  - Surface

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

### wrap

    public static Geometry wrap(Element element,
                                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(String gml,
                                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(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

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

### wrapSurfaceAsSurface

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

### wrapPoint

    public static Point wrapPoint(Element element,
                                  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(Element element,
                                       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(Element element,
                                      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(Element element,
                                       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(Element element,
                                 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(Element element,
                                            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(Element element,
                                                 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(Element element,
                                                        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(Element element,
                                                              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(Element element,
                                                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(Element element,
                                                  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(Element element,
                                           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(Element element,
                                                        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 PrintWriter export(Geometry geometry,
                                     OutputStream os)
                              throws GeometryException

  Writes the GML representation of the given `Geometry` to the given `OutputStream`.

  Currently, the `Geometry` realizations are handled:

  - SurfacePatch
  - LineString
  - Point
  - Curve
  - Surface
  - MultiPoint
  - MultiCurve
  - MultiSurface
  - MultiGeometry

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

### export

    public static PrintWriter export(Geometry geometry,
                                     OutputStream os,
                                     String id)
                              throws GeometryException

  Parameters:
    `geometry` -
    `os` -
    `id` -
  Returns:
    a `PrintWriter` created from the `OutputStream`
  Throws:
    `GeometryException`

### export

    public static PrintWriter export(Geometry geometry,
                                     PrintWriter pw)
                              throws GeometryException

  Writes the GML representation of the given `Geometry` to the given `PrintWriter`.

  Currently, the `Geometry` realizations are handled:

  - SurfacePatch
  - LineString
  - Point
  - Curve
  - Surface
  - MultiPoint
  - MultiCurve
  - MultiSurface
  - MultiGeometry

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

### export

    public static PrintWriter export(Geometry geometry,
                                     PrintWriter pw,
                                     String id)
                              throws GeometryException

  Parameters:
    `geometry` -
    `pw` -
    `id` -
  Returns:
    same as input `PrintWriter`
  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`

### export

    public static StringBuffer export(Geometry geometry,
                                      String id)
                               throws GeometryException

  Parameters:
    `geometry` -
    `id` -
  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:
    the stringbuffer filled with the envelope.

### 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:
    the String representation of the given envelope

### exportMultiGeometry

    public static void exportMultiGeometry(MultiGeometry multiGeometry,
                                           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,
                                           PrintWriter pw,
                                           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(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`

### swap

    public static boolean swap(Envelope env)

  Parameters:
    `env` -
  Returns:
    true, if configuration and environment say yes to swapping

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| deegree 2.4 (2010/11/11 10:47 build-27-official)
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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