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

org.deegree.model.spatialschema
Class GeometryImpl

java.lang.Object
  extended by org.deegree.model.spatialschema.GeometryImpl
All Implemented Interfaces:
java.io.Serializable, Geometry
Direct Known Subclasses:
AggregateImpl, BoundaryImpl, PrimitiveImpl

public abstract class GeometryImpl
extends java.lang.Object
implements Geometry, java.io.Serializable

Default implementation of the Geometry interface from package deegree.model. The implementation is abstract because only the management of the spatial reference system is unique for all geometries.

Version:
$Revision: 18195 $, $Date: 2009-06-18 17:55:39 +0200 (Do, 18 Jun 2009) $
Author:
Andreas Poth, last edited by: $Author: mschneider $
See Also:
Serialized Form

Field Summary
protected  Boundary boundary
           
protected  Point centroid
           
protected  Geometry convexHull
           
protected  CoordinateSystem crs
           
protected  boolean empty
           
protected  Envelope envelope
           
protected  double mute
           
protected  boolean valid
           
 
Fields inherited from interface org.deegree.model.spatialschema.Geometry
BUFFER_CAP_BUTT, BUFFER_CAP_ROUND, BUFFER_CAP_SQUARE
 
Constructor Summary
protected GeometryImpl(CoordinateSystem crs)
          constructor that sets the spatial reference system
 
Method Summary
protected abstract  void calculateParam()
          recalculates internal parameters
 java.lang.Object clone()
           
 boolean contains(Geometry that)
          The Boolean valued operation "contains" shall return TRUE if this Geometry contains another Geometry.
 boolean contains(Position position)
          The Boolean valued operation "contains" shall return TRUE if this Geometry contains a single point given by a coordinate.
 Geometry difference(Geometry that)
          The "difference" operation shall return the set theoretic difference of this Geometry and the passed Geometry.
 double distance(Geometry gmo)
           The operation "distance" shall return the distance between this Geometry and another Geometry.
 boolean equals(java.lang.Object that)
          Compares the Geometry to be equal to another Geometry.
 Boundary getBoundary()
          returns the boundary of the surface as general boundary
 Geometry getBuffer(double distance)
          The operation "buffer" shall return a Geometry containing all points whose distance from this Geometry is less than or equal to the "distance" passed as a parameter.
 Geometry getBuffer(double distance, int segments, int capStyle)
          The operation "buffer" shall return a Geometry containing all points whose distance from this Geometry is less than or equal to the "distance" passed as a parameter.
 Point getCentroid()
           The operation "centroid" shall return the mathematical centroid for this Geometry.
 Geometry getConvexHull()
          The operation "convexHull" shall return a Geometry that represents the convex hull of this Geometry.
 CoordinateSystem getCoordinateSystem()
           
 Envelope getEnvelope()
          returns the bounding box / envelope of a geometry
 double getTolerance()
          returns the tolerance value use for topological operations
 Geometry intersection(Geometry that)
          The "intersection" operation shall return the set theoretic intersection of this Geometry and the passed Geometry.
 boolean intersects(Geometry that)
          The Boolean valued operation "intersects" shall return TRUE if this Geometry intersects another Geometry.
 boolean isEmpty()
           
protected  boolean isValid()
           
 boolean isWithinDistance(Geometry that, double distance)
          provide optimized proximity queries within for a distance . calvin added on 10/21/2003
 void setCoordinateSystem(CoordinateSystem crs)
          sets the spatial reference system
 void setEmpty(boolean empty)
           
 void setTolerance(double tolerance)
          sets tolerance value use for topological operations
protected  void setValid(boolean valid)
           
 java.lang.String toString()
           
 void translate(double[] d)
          dummy implementation of this method
 Geometry union(Geometry that)
          The "union" operation shall return the set theoretic union of this Geometry and the passed Geometry.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.deegree.model.spatialschema.Geometry
getCoordinateDimension, getDimension
 

Field Detail

mute

protected double mute

crs

protected CoordinateSystem crs

boundary

protected Boundary boundary

envelope

protected Envelope envelope

convexHull

protected Geometry convexHull

centroid

protected Point centroid

empty

protected boolean empty

valid

protected boolean valid
Constructor Detail

GeometryImpl

protected GeometryImpl(CoordinateSystem crs)
constructor that sets the spatial reference system

Parameters:
crs - new spatial reference system
Method Detail

getCoordinateSystem

public CoordinateSystem getCoordinateSystem()
Specified by:
getCoordinateSystem in interface Geometry
Returns:
the spatial reference system of a geometry

setCoordinateSystem

public void setCoordinateSystem(CoordinateSystem crs)
sets the spatial reference system

Parameters:
crs - new spatial reference system

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Geometry
Returns:
true if no geometry values resp. points stored within the geometry.

setEmpty

public void setEmpty(boolean empty)
Parameters:
empty - indicates the geometry as empty

getBoundary

public Boundary getBoundary()
returns the boundary of the surface as general boundary

Specified by:
getBoundary in interface Geometry
Returns:
the boundary of a geometry

translate

public void translate(double[] d)
dummy implementation of this method

Specified by:
translate in interface Geometry
Parameters:
d - vector to translate the geometry with

distance

public double distance(Geometry gmo)

The operation "distance" shall return the distance between this Geometry and another Geometry. This distance is defined to be the greatest lower bound of the set of distances between all pairs of points that include one each from each of the two Geometries. A "distance" value shall be a positive number associated to distance units such as meters or standard foot. If necessary, the second geometric object shall be transformed into the same coordinate reference system as the first before the distance is calculated.

If the geometric objects overlap, or touch, then their distance apart shall be zero. Some current implementations use a "negative" distance for such cases, but the approach is neither consistent between implementations, nor theoretically viable.

Specified by:
distance in interface Geometry
Returns:
the distance between this Geometry and another Geometry

getCentroid

public Point getCentroid()

The operation "centroid" shall return the mathematical centroid for this Geometry. The result is not guaranteed to be on the object. For heterogeneous collections of primitives, the centroid only takes into account those of the largest dimension. For example, when calculating the centroid of surfaces, an average is taken weighted by area. Since curves have no area they do not contribute to the average.

Specified by:
getCentroid in interface Geometry
Returns:
the centroid

getEnvelope

public Envelope getEnvelope()
returns the bounding box / envelope of a geometry

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

getConvexHull

public Geometry getConvexHull()
The operation "convexHull" shall return a Geometry that represents the convex hull of this Geometry.

Specified by:
getConvexHull in interface Geometry
Returns:
the convexHull
See Also:
an may has an useful implementation in extending classes

getBuffer

public Geometry getBuffer(double distance)
The operation "buffer" shall return a Geometry containing all points whose distance from this Geometry is less than or equal to the "distance" passed as a parameter. The Geometry returned is in the same reference system as this original Geometry. The dimension of the returned Geometry is normally the same as the coordinate dimension - a collection of Surfaces in 2D space and a collection of Solids in 3D space, but this may be application defined.

Specified by:
getBuffer in interface Geometry
Returns:
a Geometry containing all points whose distance from this Geometry is less than or equal to the "distance" passed as a parameter

getBuffer

public Geometry getBuffer(double distance,
                          int segments,
                          int capStyle)
Description copied from interface: Geometry
The operation "buffer" shall return a Geometry containing all points whose distance from this Geometry is less than or equal to the "distance" passed as a parameter. The Geometry returned is in the same reference system as this original Geometry. The dimension of the returned Geometry is normally the same as the coordinate dimension - a collection of Surfaces in 2D space and a collection of Solids in 3D space, but this may be application defined.

Specified by:
getBuffer in interface Geometry
Returns:
a Geometry containing all points whose distance from this Geometry is less than or equal to the "distance" passed as a parameter

contains

public boolean contains(Geometry that)
The Boolean valued operation "contains" shall return TRUE if this Geometry contains another Geometry.

Specified by:
contains in interface Geometry
Parameters:
that - the Geometry to test (whether is is contained)
Returns:
true if the given object is contained, else false

contains

public boolean contains(Position position)
The Boolean valued operation "contains" shall return TRUE if this Geometry contains a single point given by a coordinate.

Specified by:
contains in interface Geometry
Parameters:
position - Position to test (whether is is contained)
Returns:
true if the given object is contained, else false

intersects

public boolean intersects(Geometry that)
The Boolean valued operation "intersects" shall return TRUE if this Geometry intersects another Geometry. Within a Complex, the Primitives do not intersect one another. In general, topologically structured data uses shared geometric objects to capture intersection information.

Specified by:
intersects in interface Geometry
Parameters:
that - the Geometry to intersect with
Returns:
true if the objects intersects, else false

union

public Geometry union(Geometry that)
The "union" operation shall return the set theoretic union of this Geometry and the passed Geometry.

Specified by:
union in interface Geometry
Parameters:
that - the Geometry to unify
Returns:
intersection or null, if computation failed

intersection

public Geometry intersection(Geometry that)
                      throws GeometryException
The "intersection" operation shall return the set theoretic intersection of this Geometry and the passed Geometry.

Specified by:
intersection in interface Geometry
Parameters:
that - the Geometry to intersect with
Returns:
intersection or null, if it is empty (or computation failed)
Throws:
GeometryException

difference

public Geometry difference(Geometry that)
The "difference" operation shall return the set theoretic difference of this Geometry and the passed Geometry.

Specified by:
difference in interface Geometry
Parameters:
that - the Geometry to calculate the difference with
Returns:
difference or null, if it is empty (or computation failed)

equals

public boolean equals(java.lang.Object that)
Compares the Geometry to be equal to another Geometry.

Overrides:
equals in class java.lang.Object
Parameters:
that - the Geometry to test for equality
Returns:
true if the objects are equal, else false

isWithinDistance

public boolean isWithinDistance(Geometry that,
                                double distance)
provide optimized proximity queries within for a distance . calvin added on 10/21/2003

Specified by:
isWithinDistance in interface Geometry
Returns:
true if the geometry is in distance of this geometry

setTolerance

public void setTolerance(double tolerance)
sets tolerance value use for topological operations

Specified by:
setTolerance in interface Geometry
Parameters:
tolerance -

getTolerance

public double getTolerance()
returns the tolerance value use for topological operations

Specified by:
getTolerance in interface Geometry
Returns:
tolerance value use for topological operations

setValid

protected void setValid(boolean valid)
Parameters:
valid - invalidates the calculated parameters of the Geometry

isValid

protected boolean isValid()
Returns:
true if the calculated parameters of the Geometry are valid and false if they must be recalculated

calculateParam

protected abstract void calculateParam()
recalculates internal parameters


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

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