org.deegree.geometry.standard
Class AbstractDefaultGeometry

java.lang.Object
  extended by org.deegree.geometry.standard.AbstractDefaultGeometry
All Implemented Interfaces:
GMLObject, Object, TypedObjectNode, Geometry
Direct Known Subclasses:
DefaultCompositeCurve, DefaultCompositeGeometry, DefaultCompositeSolid, DefaultCompositeSurface, DefaultCurve, DefaultEnvelope, DefaultMultiGeometry, DefaultOrientableCurve, DefaultOrientableSurface, DefaultPoint, DefaultPolyhedralSurface, DefaultRing, DefaultSolid, DefaultSurface, DefaultTin, DefaultTriangulatedSurface

public abstract class AbstractDefaultGeometry
extends Object
implements Geometry

Abstract base class for the default Geometry implementation.

This implementation is built around JTS (Java Topology Suite) geometries which are used to evaluate topological predicates (e.g. intersects) and perform spatial analysis operations (e.g union). Simple geometries (e.g. LineStrings are mapped to a corresponding JTS object, for complex ones (e.g. Curves with non-linear segments), the JTS geometry only approximates the original geometry. See this page for a discussion.

Version:
$Revision: 31649 $, $Date: 2011-08-25 01:03:49 +0200 (Thu, 25 Aug 2011) $
Author:
Markus Schneider, last edited by: $Author: mschneider $

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.deegree.geometry.Geometry
Geometry.GeometryType
 
Field Summary
protected  ICRS crs
          Reference to a coordinate system.
protected  Envelope env
           
protected  String id
          Geometry identifier.
protected static com.vividsolutions.jts.geom.GeometryFactory jtsFactory
          Used to built JTS geometries.
protected  com.vividsolutions.jts.geom.Geometry jtsGeometry
           
protected  PrecisionModel pm
           
 
Constructor Summary
AbstractDefaultGeometry(String id, ICRS crs, PrecisionModel pm)
           
 
Method Summary
protected  com.vividsolutions.jts.geom.Geometry buildJTSGeometry()
           
 boolean contains(Geometry geometry)
          Tests whether this geometry contains the specified geometry.
 AbstractDefaultGeometry createFromJTS(com.vividsolutions.jts.geom.Geometry jtsGeom, ICRS crs)
          Helper methods for creating AbstractDefaultGeometry from JTS geometries that have been derived from this geometry by JTS spatial analysis methods.
 boolean crosses(Geometry geometry)
          Tests whether this geometry crosses the specified geometry.
 boolean equals(Geometry geometry)
          Tests whether this geometry is equal to the specified geometry.
protected static AbstractDefaultGeometry getAsDefaultGeometry(Geometry geometry)
           
 Geometry getBuffer(Measure distance)
          Return a new Geometry that contains all points with a distance from this Geometry that is less than or equal to the specified distance.
 Point getCentroid()
          Returns the centroid of the geometry.
 Geometry getConvexHull()
          Returns the convex hull of the geometry.
 ICRS getCoordinateSystem()
          Returns the associated spatial reference system.
 Geometry getDifference(Geometry geometry)
          Returns the set-theoretic difference of this and the passed Geometry.
 Measure getDistance(Geometry geometry, Unit requestedUnit)
          Returns the minimum distance between this and the specified geometry.
 Envelope getEnvelope()
          Returns the minimal bounding box of the geometry.
 GMLStdProps getGMLProperties()
          Returns the standard GML properties (e.g.
 String getId()
          Returns the id of the geometry.
 Geometry getIntersection(Geometry geometry)
          Returns the set-theoretic intersection of this and the passed Geometry.
 com.vividsolutions.jts.geom.Geometry getJTSGeometry()
          Returns an equivalent (or best-fit) JTS geometry object.
 PrecisionModel getPrecision()
          Returns the PrecisionModel of the geometry.
 Geometry getUnion(Geometry geometry)
          Returns the set-theoretic union of this and the passed Geometry.
 boolean intersects(Geometry geometry)
          Tests whether this geometry intersects the specified geometry.
 boolean isBeyond(Geometry geometry, Measure distance)
          Tests whether this geometry is beyond a specified distance of a second geometry.
 boolean isDisjoint(Geometry geometry)
          Tests whether this geometry is disjoint from the specified geometry.
 boolean isSFSCompliant()
          Returns whether this geometry complies with the Simple Feature Specification (SFS).
 boolean isWithin(Geometry geometry)
          tests whether the value of a geometric is topological located within this geometry.
 boolean isWithinDistance(Geometry geometry, Measure distance)
          Tests whether this geometry is within a specified distance of a second geometry.
 boolean overlaps(Geometry geometry)
          Tests whether this geometry overlaps the specified geometry.
 void setCoordinateSystem(ICRS crs)
          Sets the associated spatial reference system.
 void setGMLProperties(GMLStdProps standardProps)
          Sets the attached properties (e.g.
 void setId(String id)
          Sets the id of the geometry.
 void setPrecision(PrecisionModel pm)
          Sets the PrecisionModel of the geometry.
 String toString()
           
 boolean touches(Geometry geometry)
          Tests whether this geometry touches the specified geometry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.deegree.geometry.Geometry
getCoordinateDimension, getGeometryType
 

Field Detail

jtsFactory

protected static final com.vividsolutions.jts.geom.GeometryFactory jtsFactory
Used to built JTS geometries.


id

protected String id
Geometry identifier.


crs

protected ICRS crs
Reference to a coordinate system.


pm

protected PrecisionModel pm

jtsGeometry

protected com.vividsolutions.jts.geom.Geometry jtsGeometry

env

protected Envelope env
Constructor Detail

AbstractDefaultGeometry

public AbstractDefaultGeometry(String id,
                               ICRS crs,
                               PrecisionModel pm)
Parameters:
id -
crs -
pm -
Method Detail

getId

public String getId()
Description copied from interface: Geometry
Returns the id of the geometry.

In a GML representation of the geometry, this corresponds to the gml:id (GML 3 and later) or gid (GML 2) attribute of the geometry element.

Specified by:
getId in interface Object
Specified by:
getId in interface Geometry
Returns:
the id of the geometry, or null if it is an anonymous (unidentified) geometry

setId

public void setId(String id)
Description copied from interface: Geometry
Sets the id of the geometry.

Specified by:
setId in interface Geometry
Parameters:
id - id of the geometry

getCoordinateSystem

public ICRS getCoordinateSystem()
Description copied from interface: Geometry
Returns the associated spatial reference system.

Specified by:
getCoordinateSystem in interface Geometry
Returns:
spatial reference system, may be null

setCoordinateSystem

public void setCoordinateSystem(ICRS crs)
Description copied from interface: Geometry
Sets the associated spatial reference system.

Specified by:
setCoordinateSystem in interface Geometry
Parameters:
crs - spatial reference system, may be null

getPrecision

public PrecisionModel getPrecision()
Description copied from interface: Geometry
Returns the PrecisionModel of the geometry.

Specified by:
getPrecision in interface Geometry
Returns:
the precision model

setPrecision

public void setPrecision(PrecisionModel pm)
Description copied from interface: Geometry
Sets the PrecisionModel of the geometry.

Specified by:
setPrecision in interface Geometry
Parameters:
pm - the precision model to set

intersects

public boolean intersects(Geometry geometry)
Description copied from interface: Geometry
Tests whether this geometry intersects the specified geometry. TODO formal explanation (DE9IM)

Specified by:
intersects in interface Geometry
Parameters:
geometry - the Geometry to test this Geometry against
Returns:
true if this Geometry intersects geometry

isDisjoint

public boolean isDisjoint(Geometry geometry)
Description copied from interface: Geometry
Tests whether this geometry is disjoint from the specified geometry. TODO formal explanation (DE9IM)

Specified by:
isDisjoint in interface Geometry
Parameters:
geometry - the Geometry to test this Geometry against
Returns:
true if this Geometry is disjoint from geometry

overlaps

public boolean overlaps(Geometry geometry)
Description copied from interface: Geometry
Tests whether this geometry overlaps the specified geometry. TODO formal explanation (DE9IM)

Specified by:
overlaps in interface Geometry
Parameters:
geometry - the Geometry to test this Geometry against
Returns:
true if this Geometry overlaps geometry

touches

public boolean touches(Geometry geometry)
Description copied from interface: Geometry
Tests whether this geometry touches the specified geometry. TODO formal explanation (DE9IM)

Specified by:
touches in interface Geometry
Parameters:
geometry - the Geometry to test this Geometry against
Returns:
true if this Geometry touches geometry

isWithin

public boolean isWithin(Geometry geometry)
Description copied from interface: Geometry
tests whether the value of a geometric is topological located within this geometry. This method is the opposite of Geometry.contains(Geometry) method

Specified by:
isWithin in interface Geometry
Returns:
true if passed geometry is located completly within this geometry

isWithinDistance

public boolean isWithinDistance(Geometry geometry,
                                Measure distance)
Description copied from interface: Geometry
Tests whether this geometry is within a specified distance of a second geometry.

Specified by:
isWithinDistance in interface Geometry
Parameters:
geometry - second geometry
Returns:
true, iff the distance between this and the second geometry is less than or equal distance

isBeyond

public boolean isBeyond(Geometry geometry,
                        Measure distance)
Description copied from interface: Geometry
Tests whether this geometry is beyond a specified distance of a second geometry.

Specified by:
isBeyond in interface Geometry
Parameters:
geometry - second geometry
Returns:
true, iff the minimum distance between this and the second geometry is greater than distance

contains

public boolean contains(Geometry geometry)
Description copied from interface: Geometry
Tests whether this geometry contains the specified geometry. TODO formal explanation (DE9IM)

Specified by:
contains in interface Geometry
Parameters:
geometry - the Geometry to test this Geometry against
Returns:
true if this Geometry contains geometry

crosses

public boolean crosses(Geometry geometry)
Description copied from interface: Geometry
Tests whether this geometry crosses the specified geometry. TODO formal explanation (DE9IM)

Specified by:
crosses in interface Geometry
Parameters:
geometry - the Geometry to test this Geometry against
Returns:
true if this Geometry crosses geometry

equals

public boolean equals(Geometry geometry)
Description copied from interface: Geometry
Tests whether this geometry is equal to the specified geometry. TODO formal explanation (DE9IM)

Specified by:
equals in interface Geometry
Parameters:
geometry - the Geometry to test this Geometry against
Returns:
true if this Geometry is equal to geometry

getCentroid

public Point getCentroid()
Description copied from interface: Geometry
Returns the centroid of the geometry.

Specified by:
getCentroid in interface Geometry
Returns:
a Point that is the centroid of this geometry

getDistance

public Measure getDistance(Geometry geometry,
                           Unit requestedUnit)
Description copied from interface: Geometry
Returns the minimum distance between this and the specified geometry.

Specified by:
getDistance in interface Geometry
Parameters:
geometry - second geometry
requestedUnit - unit of the
Returns:
shortest distance between the two geometries

getIntersection

public Geometry getIntersection(Geometry geometry)
Description copied from interface: Geometry
Returns the set-theoretic intersection of this and the passed Geometry.

Specified by:
getIntersection in interface Geometry
Parameters:
geometry - other geometry, must not be null
Returns:
intersection Geometry or null (empty set)

getUnion

public Geometry getUnion(Geometry geometry)
Description copied from interface: Geometry
Returns the set-theoretic union of this and the passed Geometry.

Specified by:
getUnion in interface Geometry
Parameters:
geometry - other geometry, must not be null
Returns:
united Geometry (never null)

getDifference

public Geometry getDifference(Geometry geometry)
Description copied from interface: Geometry
Returns the set-theoretic difference of this and the passed Geometry.

Specified by:
getDifference in interface Geometry
Parameters:
geometry - other geometry, must not be null
Returns:
difference Geometry or null (empty set)

getBuffer

public Geometry getBuffer(Measure distance)
Description copied from interface: Geometry
Return a new Geometry that contains all points with a distance from this Geometry that is less than or equal to the specified distance.

Specified by:
getBuffer in interface Geometry
Returns:
buffer geometry

getConvexHull

public Geometry getConvexHull()
Description copied from interface: Geometry
Returns the convex hull of the geometry.

Specified by:
getConvexHull in interface Geometry
Returns:
convex hull of a Geometry

getEnvelope

public Envelope getEnvelope()
Description copied from interface: Geometry
Returns the minimal bounding box of the geometry.

Specified by:
getEnvelope in interface Geometry
Returns:
the minimal bounding box of the geometry

getJTSGeometry

public com.vividsolutions.jts.geom.Geometry getJTSGeometry()
Returns an equivalent (or best-fit) JTS geometry object.

Returns:
an equivalent (or best-fit) JTS geometry

buildJTSGeometry

protected com.vividsolutions.jts.geom.Geometry buildJTSGeometry()

getGMLProperties

public GMLStdProps getGMLProperties()
Description copied from interface: GMLObject
Returns the standard GML properties (e.g. gml:name).

Specified by:
getGMLProperties in interface GMLObject
Returns:
the standard GML properties, may be

setGMLProperties

public void setGMLProperties(GMLStdProps standardProps)
Description copied from interface: Geometry
Sets the attached properties (e.g. GML standard properties, such as gml:name).

Specified by:
setGMLProperties in interface Geometry
Parameters:
standardProps - properties to be attached

createFromJTS

public AbstractDefaultGeometry createFromJTS(com.vividsolutions.jts.geom.Geometry jtsGeom,
                                             ICRS crs)
Helper methods for creating AbstractDefaultGeometry from JTS geometries that have been derived from this geometry by JTS spatial analysis methods.

Parameters:
jtsGeom -
crs -
Returns:
geometry with precision model and CoordinateSystem information that are identical to the ones of this geometry, or null if the given geometry is an empty collection

getAsDefaultGeometry

protected static AbstractDefaultGeometry getAsDefaultGeometry(Geometry geometry)

isSFSCompliant

public boolean isSFSCompliant()
Description copied from interface: Geometry
Returns whether this geometry complies with the Simple Feature Specification (SFS).

Specified by:
isSFSCompliant in interface Geometry
Returns:
true, if this geometry complies with the SFS, false otherwise

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011. All Rights Reserved.