Package org.geolatte.geom
Class Geometry<P extends Position>
- java.lang.Object
-
- org.geolatte.geom.Geometry<P>
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
AbstractGeometryCollection,LineString,Point,Polygon
public abstract class Geometry<P extends Position> extends Object implements Serializable
The base class forGeometrys.- Author:
- Karel Maesen, Geovise BVBA, 2011
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedGeometry(CoordinateReferenceSystem<P> crs)Creates an empty GeometryprotectedGeometry(PositionSequence<P> positions, CoordinateReferenceSystem<P> crs)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidaccept(GeometryVisitor<P> visitor)Accepts aGeometryVisitor.<Q extends Position>
Geometry<Q>as(Class<Q> castToType)protected <Q extends Position>
voidcheckCast(Class<Q> castToType)Checks whether a cast should succeedbooleanequals(Object o)static <Q extends Position>
Geometry<Q>forceToCrs(Geometry<?> geometry, CoordinateReferenceSystem<Q> crs)Creates a newGeometrywith the positions from the specified geometry and having the specifiedCoordinateReferenceSystemintgetCoordinateDimension()Returns the coordinate dimension of thisGeometryCoordinateReferenceSystem<P>getCoordinateReferenceSystem()Returns the coordinate reference system of thisGeometryprotected static <T extends Position>
CoordinateReferenceSystem<T>getCrs(Geometry<T>[] geometries)abstract intgetDimension()Returns the topological dimension of this instance.Envelope<P>getEnvelope()Returns theEnvelopeof this instance.abstract GeometryTypegetGeometryType()Returns the type of thisGeometry.intgetNumPositions()Returns the number of positions in thePositionSequenceof thisGeometry.Class<P>getPositionClass()PgetPositionN(int index)Returns the position at the specified index in thePositionSequenceof thisGeometry.PositionSequence<P>getPositions()Returns thePositionSequenceof this instanceintgetSRID()Returns the numeric identifier of the coordinate reference system of thisGeometry.inthashCode()booleanisEmpty()Tests whether thisGeometrycorresponds to the empty set.protected static <T extends Position>
PositionSequence<T>nestPositionSequences(Geometry<T>[] geometries)StringtoString()Returns the Well-Known Text (WKT) representation of thisGeometry.protected ObjectwriteReplace()
-
-
-
Constructor Detail
-
Geometry
protected Geometry(CoordinateReferenceSystem<P> crs)
Creates an empty Geometry- Parameters:
crs- the CoordinateReferenceSystem to use
-
Geometry
protected Geometry(PositionSequence<P> positions, CoordinateReferenceSystem<P> crs)
-
-
Method Detail
-
forceToCrs
public static <Q extends Position> Geometry<Q> forceToCrs(Geometry<?> geometry, CoordinateReferenceSystem<Q> crs)
Creates a newGeometrywith the positions from the specified geometry and having the specifiedCoordinateReferenceSystem- Type Parameters:
Q- thePositiontype for the returned Geometry- Parameters:
geometry- sourceGeometrythat supplies thePositions for the returnedGeometrycrs- theCoordinateReferenceSystemfor the returnedGeometry- Returns:
- a
Geometrywith the positions of the specified geometry and having the specifiedCoordinateReferenceSystem
-
nestPositionSequences
protected static <T extends Position> PositionSequence<T> nestPositionSequences(Geometry<T>[] geometries)
-
getCrs
protected static <T extends Position> CoordinateReferenceSystem<T> getCrs(Geometry<T>[] geometries)
-
getCoordinateDimension
public int getCoordinateDimension()
Returns the coordinate dimension of thisGeometryThe coordinate dimension is the number of components in the coordinates of the points in this
Geometry.- Returns:
- the coordinate dimension
-
getCoordinateReferenceSystem
public CoordinateReferenceSystem<P> getCoordinateReferenceSystem()
Returns the coordinate reference system of thisGeometry- Returns:
- the coordinate reference system of this
Geometry
-
getSRID
public int getSRID()
Returns the numeric identifier of the coordinate reference system of thisGeometry.A SRID is usually interpreted as meaning the EPSG-code for the coordinate reference system. In this implementation, this is not enforced.
- Returns:
- the numeric identifier of the coordinate reference system of this
Geometry.
-
isEmpty
public boolean isEmpty()
Tests whether thisGeometrycorresponds to the empty set.- Returns:
- true if this
Geometrycorresponds to the empty set, false otherwise.
-
getNumPositions
public int getNumPositions()
Returns the number of positions in thePositionSequenceof thisGeometry.- Returns:
- the number of positions in the
PositionSequenceof thisGeometry.
-
getPositionN
public P getPositionN(int index)
Returns the position at the specified index in thePositionSequenceof thisGeometry.- Parameters:
index- the position in thePositionSequence(first point is at index 0).- Returns:
- the position at the specified index in the
PositionSequenceof thisGeometry.
-
checkCast
protected <Q extends Position> void checkCast(Class<Q> castToType)
Checks whether a cast should succeed- Type Parameters:
Q-- Parameters:
castToType-
-
getPositions
public PositionSequence<P> getPositions()
Returns thePositionSequenceof this instance- Returns:
- the
PositionSequenceof this instance
-
getEnvelope
public Envelope<P> getEnvelope()
Returns theEnvelopeof this instance.- Returns:
- the
Envelopeof this instance.
-
getGeometryType
public abstract GeometryType getGeometryType()
Returns the type of thisGeometry.- Returns:
- the
GeometryTypeof this instance.
-
toString
public String toString()
Returns the Well-Known Text (WKT) representation of thisGeometry.
-
getDimension
public abstract int getDimension()
Returns the topological dimension of this instance. In non-homogenous collections, this will return the largest topological dimension of the containedGeometries.- Returns:
- the topological dimension of this instance
-
accept
public abstract void accept(GeometryVisitor<P> visitor)
Accepts aGeometryVisitor.If this
Geometryinstance is aGeometryCollectionthen it will pass the visitor to its containedGeometries.- Parameters:
visitor-
-
writeReplace
protected Object writeReplace() throws ObjectStreamException
- Throws:
ObjectStreamException
-
-