org.geotools.geometry.jts.spatialschema.geometry
Class GeometryImpl

java.lang.Object
  extended by org.geotools.geometry.jts.spatialschema.geometry.GeometryImpl
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, JTSGeometry, org.opengis.geometry.Geometry, org.opengis.geometry.TransfiniteSet
Direct Known Subclasses:
AggregateImpl, ComplexImpl, CurveImpl, PointImpl, PolyhedralSurfaceImpl, SurfaceImpl

public abstract class GeometryImpl
extends java.lang.Object
implements org.opengis.geometry.Geometry, java.io.Serializable, org.opengis.util.Cloneable, JTSGeometry

Base class for our JTS-based implementation of the various ISO 19107 geometry classes.

See Also:
Serialized Form

Nested Class Summary
static class GeometryImpl.MathTransformFilter
          This class implements JTS's CoordinateFilter interface using a GeoAPI MathTransform object to actually perform the work.
 
Constructor Summary
GeometryImpl()
          Creates a new mutable GeometryImpl with a null CRS.
GeometryImpl(org.opengis.referencing.crs.CoordinateReferenceSystem coordinateReferenceSystem)
          Creates a new mutable GeometryImpl.
GeometryImpl(org.opengis.referencing.crs.CoordinateReferenceSystem coordinateReferenceSystem, boolean mutable)
          Creates a new GeometryImpl.
 
Method Summary
 GeometryImpl clone()
          Returns a deep copy of this geometric object.
protected abstract  com.vividsolutions.jts.geom.Geometry computeJTSPeer()
          Subclasses must override this method to compute the JTS equivalent of this geometry.
 boolean contains(org.opengis.geometry.DirectPosition point)
          Returns true if the given position lies in this geometry within the tolerance of the floating point representation.
 boolean contains(org.opengis.geometry.TransfiniteSet pointSet)
          Returns true if this geometry completely contains the given geometry.
 org.opengis.geometry.TransfiniteSet difference(org.opengis.geometry.TransfiniteSet pointSet)
           
 double distance(org.opengis.geometry.Geometry otherGeometry)
           
 boolean equals(org.opengis.geometry.TransfiniteSet pointSet)
           
 org.opengis.geometry.Boundary getBoundary()
          Returns the boundary of this geometry.
 org.opengis.geometry.Geometry getBuffer(double distance)
          Returns an approximate buffer around this object.
 org.opengis.geometry.DirectPosition getCentroid()
          Returns the centroid of this geometry.
 org.opengis.geometry.complex.Complex getClosure()
          This method is not implemented.
 org.opengis.geometry.Geometry getConvexHull()
          Returns the geometric convex hull of this geometry.
 int getCoordinateDimension()
          Returns the dimension of the coordinates in this geometry.
 org.opengis.referencing.crs.CoordinateReferenceSystem getCoordinateReferenceSystem()
          Returns the CRS that was given to the constructor.
 int getDimension(org.opengis.geometry.DirectPosition point)
          Returns the manifold dimension of the geometry at the given point.
 double getDistance(org.opengis.geometry.Geometry geometry)
          Returns the distance between the given geometry and this geometry.
 org.opengis.geometry.Envelope getEnvelope()
           
 com.vividsolutions.jts.geom.Geometry getJTSGeometry()
          Returns the JTS version of this geometry.
 java.util.Set getMaximalComplex()
          This impementation of geometry does not support traversing this association in this direction as it would require every geometry to know about all of the larger geometries of which it is a part.
 org.opengis.geometry.Geometry getMbRegion()
          Returns a Geometry that represents the minimum bounding region of this geometry.
 org.opengis.geometry.Precision getPrecision()
           
 org.opengis.geometry.DirectPosition getRepresentativePoint()
          Returns a point interior to the geometry.
 org.opengis.geometry.TransfiniteSet intersection(org.opengis.geometry.TransfiniteSet pointSet)
           
 boolean intersects(org.opengis.geometry.TransfiniteSet pointSet)
           
 void invalidateCachedJTSPeer()
          This method must be called by subclasses whenever the user makes a change to the geometry so that the cached JTS object can be recreated.
 boolean isCycle()
           
 boolean isMutable()
          Returns true if this geometry can be changed.
 boolean isSimple()
          Returns true if this object does not cross itself.
static java.util.Set listAsSet(java.util.List list)
           
protected  void setJTSPeer(com.vividsolutions.jts.geom.Geometry g)
          This method is meant to be invoked by the JTSUtils utility class when it creates a Geometry from a JTS geometry.
 void setParent(JTSGeometry parent)
           
 org.opengis.geometry.TransfiniteSet symmetricDifference(org.opengis.geometry.TransfiniteSet pointSet)
           
 org.opengis.geometry.Geometry toImmutable()
          Creates an immutable copy of this object or just returns this object if it's already immutable.
 org.opengis.geometry.Geometry transform(org.opengis.referencing.crs.CoordinateReferenceSystem newCRS)
          Attempts to find a transform from the current CRS to the new CRS and creates a new geometry by invoking that transform on each control point of this geometry.
 org.opengis.geometry.Geometry transform(org.opengis.referencing.crs.CoordinateReferenceSystem newCRS, org.opengis.referencing.operation.MathTransform transform)
          Creates a new Geometry out of this one by invoking the given transform on each control point of this geometry.
 org.opengis.geometry.TransfiniteSet union(org.opengis.geometry.TransfiniteSet pointSet)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeometryImpl

public GeometryImpl()
Creates a new mutable GeometryImpl with a null CRS.


GeometryImpl

public GeometryImpl(org.opengis.referencing.crs.CoordinateReferenceSystem coordinateReferenceSystem)
Creates a new mutable GeometryImpl.

Parameters:
coordinateReferenceSystem - CRS for this geometry's vertices.

GeometryImpl

public GeometryImpl(org.opengis.referencing.crs.CoordinateReferenceSystem coordinateReferenceSystem,
                    boolean mutable)
Creates a new GeometryImpl.

Parameters:
coordinateReferenceSystem - CRS for this geometry's vertices.
mutable - Whether or not changes will be allowed.
Method Detail

setParent

public void setParent(JTSGeometry parent)

getPrecision

public org.opengis.geometry.Precision getPrecision()
Specified by:
getPrecision in interface org.opengis.geometry.Geometry

computeJTSPeer

protected abstract com.vividsolutions.jts.geom.Geometry computeJTSPeer()
Subclasses must override this method to compute the JTS equivalent of this geometry.


invalidateCachedJTSPeer

public final void invalidateCachedJTSPeer()
This method must be called by subclasses whenever the user makes a change to the geometry so that the cached JTS object can be recreated.

Specified by:
invalidateCachedJTSPeer in interface JTSGeometry

setJTSPeer

protected final void setJTSPeer(com.vividsolutions.jts.geom.Geometry g)
This method is meant to be invoked by the JTSUtils utility class when it creates a Geometry from a JTS geometry. This prevents the Geometry from having to recompute the JTS peer the first time.


getJTSGeometry

public final com.vividsolutions.jts.geom.Geometry getJTSGeometry()
Returns the JTS version of this geometry. If the geometry has not changed since the last time this method was called, it will return the exact same object.

Specified by:
getJTSGeometry in interface JTSGeometry

getCoordinateReferenceSystem

public final org.opengis.referencing.crs.CoordinateReferenceSystem getCoordinateReferenceSystem()
Returns the CRS that was given to the constructor.

Specified by:
getCoordinateReferenceSystem in interface org.opengis.geometry.Geometry

getMbRegion

public final org.opengis.geometry.Geometry getMbRegion()
Returns a Geometry that represents the minimum bounding region of this geometry.

Specified by:
getMbRegion in interface org.opengis.geometry.Geometry

getRepresentativePoint

public final org.opengis.geometry.DirectPosition getRepresentativePoint()
Returns a point interior to the geometry.

Specified by:
getRepresentativePoint in interface org.opengis.geometry.Geometry

getBoundary

public org.opengis.geometry.Boundary getBoundary()
Returns the boundary of this geometry. Returns null if the boundary is empty.

Specified by:
getBoundary in interface org.opengis.geometry.Geometry

getClosure

public final org.opengis.geometry.complex.Complex getClosure()
This method is not implemented. Always throws an UnsupportedOperationException.

Specified by:
getClosure in interface org.opengis.geometry.Geometry

isSimple

public final boolean isSimple()
Returns true if this object does not cross itself.

Specified by:
isSimple in interface org.opengis.geometry.Geometry

isCycle

public final boolean isCycle()
Specified by:
isCycle in interface org.opengis.geometry.Geometry

getDistance

public final double getDistance(org.opengis.geometry.Geometry geometry)
Returns the distance between the given geometry and this geometry. Note that this distance is in units the same as the units of the coordinate reference system, and thus may not have any physical meaning (such as when the coordinate system is a latitude/longitude system).


getDimension

public final int getDimension(org.opengis.geometry.DirectPosition point)
Returns the manifold dimension of the geometry at the given point. The point must lie on the geometry. For geometries that consist of multiple parts, this returns the dimension of the part intersecting the given point. When multiple parts coincide at the given point, this returns the least dimension of those geometries. Returns Integer.MAX_VALUE if the given point is not on this geometry.

Specified by:
getDimension in interface org.opengis.geometry.Geometry

getCoordinateDimension

public final int getCoordinateDimension()
Returns the dimension of the coordinates in this geometry. This delegates to the coordinate reference system, so it may throw a null pointer exception if this geometry has no coordinate reference system.

Specified by:
getCoordinateDimension in interface org.opengis.geometry.Geometry

getMaximalComplex

public final java.util.Set getMaximalComplex()
This impementation of geometry does not support traversing this association in this direction as it would require every geometry to know about all of the larger geometries of which it is a part. This would add some memory usage and bookkeeping headaches for functionality that will rarely, if ever, be used. This this method always returns null.

Specified by:
getMaximalComplex in interface org.opengis.geometry.Geometry

transform

public final org.opengis.geometry.Geometry transform(org.opengis.referencing.crs.CoordinateReferenceSystem newCRS)
                                              throws org.opengis.referencing.operation.TransformException
Attempts to find a transform from the current CRS to the new CRS and creates a new geometry by invoking that transform on each control point of this geometry.

Specified by:
transform in interface org.opengis.geometry.Geometry
Throws:
org.opengis.referencing.operation.TransformException

transform

public final org.opengis.geometry.Geometry transform(org.opengis.referencing.crs.CoordinateReferenceSystem newCRS,
                                                     org.opengis.referencing.operation.MathTransform transform)
                                              throws org.opengis.referencing.operation.TransformException
Creates a new Geometry out of this one by invoking the given transform on each control point of this geometry.

Specified by:
transform in interface org.opengis.geometry.Geometry
Throws:
org.opengis.referencing.operation.TransformException

getEnvelope

public final org.opengis.geometry.Envelope getEnvelope()
Specified by:
getEnvelope in interface org.opengis.geometry.Geometry
See Also:
org.opengis.geometry.coordinate.#getEnvelope()

getCentroid

public final org.opengis.geometry.DirectPosition getCentroid()
Returns the centroid of this geometry.

Specified by:
getCentroid in interface org.opengis.geometry.Geometry

getConvexHull

public final org.opengis.geometry.Geometry getConvexHull()
Returns the geometric convex hull of this geometry.

Specified by:
getConvexHull in interface org.opengis.geometry.Geometry

getBuffer

public final org.opengis.geometry.Geometry getBuffer(double distance)
Returns an approximate buffer around this object.

Specified by:
getBuffer in interface org.opengis.geometry.Geometry

isMutable

public final boolean isMutable()
Returns true if this geometry can be changed.

Specified by:
isMutable in interface org.opengis.geometry.Geometry

toImmutable

public final org.opengis.geometry.Geometry toImmutable()
Creates an immutable copy of this object or just returns this object if it's already immutable.

Specified by:
toImmutable in interface org.opengis.geometry.Geometry

clone

public GeometryImpl clone()
Returns a deep copy of this geometric object. Subclasses must override to make deep copies of members that are themselves mutable objects. Note that all of the (private) members of GeometryImpl are already immutable so this method simply delegates to the superclass (Object) clone.

Specified by:
clone in interface org.opengis.geometry.Geometry
Overrides:
clone in class java.lang.Object

contains

public boolean contains(org.opengis.geometry.DirectPosition point)
Returns true if the given position lies in this geometry within the tolerance of the floating point representation.

Specified by:
contains in interface org.opengis.geometry.TransfiniteSet

contains

public boolean contains(org.opengis.geometry.TransfiniteSet pointSet)
Returns true if this geometry completely contains the given geometry.

Specified by:
contains in interface org.opengis.geometry.TransfiniteSet

distance

public double distance(org.opengis.geometry.Geometry otherGeometry)
Specified by:
distance in interface org.opengis.geometry.Geometry

difference

public org.opengis.geometry.TransfiniteSet difference(org.opengis.geometry.TransfiniteSet pointSet)
Specified by:
difference in interface org.opengis.geometry.TransfiniteSet

equals

public boolean equals(org.opengis.geometry.TransfiniteSet pointSet)
Specified by:
equals in interface org.opengis.geometry.TransfiniteSet

intersection

public org.opengis.geometry.TransfiniteSet intersection(org.opengis.geometry.TransfiniteSet pointSet)
Specified by:
intersection in interface org.opengis.geometry.TransfiniteSet

intersects

public boolean intersects(org.opengis.geometry.TransfiniteSet pointSet)
Specified by:
intersects in interface org.opengis.geometry.TransfiniteSet

symmetricDifference

public org.opengis.geometry.TransfiniteSet symmetricDifference(org.opengis.geometry.TransfiniteSet pointSet)
Specified by:
symmetricDifference in interface org.opengis.geometry.TransfiniteSet

union

public org.opengis.geometry.TransfiniteSet union(org.opengis.geometry.TransfiniteSet pointSet)
Specified by:
union in interface org.opengis.geometry.TransfiniteSet

listAsSet

public static java.util.Set listAsSet(java.util.List list)


Copyright © 1996-2010 Geotools. All Rights Reserved.