org.postgis
Class Geometry

java.lang.Object
  extended by org.postgis.Geometry
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
ComposedGeom, Point

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

The base class of all geometries

See Also:
Serialized Form

Field Summary
static java.lang.String[] ALLTYPES
           
 int dimension
          The dimensionality of this feature (2,3)
static int GEOMETRYCOLLECTION
          The OGIS geometry type number for feature collections.
 boolean haveMeasure
          Do we have a measure (4th dimension)
static int LINEARRING
          Fake type for linear ring
static int LINESTRING
          The OGIS geometry type number for lines.
static int MULTILINESTRING
          The OGIS geometry type number for aggregate lines.
static int MULTIPOINT
          The OGIS geometry type number for aggregate points.
static int MULTIPOLYGON
          The OGIS geometry type number for aggregate polygons.
static int POINT
          The OGIS geometry type number for points.
static int POLYGON
          The OGIS geometry type number for polygons.
 int srid
          The spacial reference system id of this geometry, default (no srid) is -1
 int type
          The OGIS geometry type of this feature. this is final as it never changes, it is bound to the subclass of the instance.
 
Constructor Summary
protected Geometry(int type)
          Constructor for subclasses
 
Method Summary
 boolean checkConsistency()
          Do some internal consistency checks on the geometry.
 boolean equals(Geometry other)
          geometry specific equals implementation - only defined for non-null values
 boolean equals(java.lang.Object other)
          java.lang.Object equals implementation
protected abstract  boolean equalsintern(Geometry other)
          Whether test coordinates for geometry - subclass specific code Implementors can assume that dimensin, type, srid and haveMeasure are equal, other !
 int getDimension()
          Queries the number of geometric dimensions of this geometry.
abstract  Point getFirstPoint()
          Same as getPoint(0);
abstract  Point getLastPoint()
          Same as getPoint(numPoints()-1);
abstract  Point getPoint(int n)
          Get the nth Point of the geometry
 int getSrid()
          The OGIS geometry type number of this geometry.
 int getType()
          The OGIS geometry type number of this geometry.
 java.lang.String getTypeString()
          Return the Type as String
static java.lang.String getTypeString(int type)
          The Text representations of the geometry types
 java.lang.String getValue()
          backwards compatibility method
 int hashCode()
          java.lang.Object hashCode implementation
protected  java.lang.String initSRID(java.lang.String value)
          Splits the SRID=4711; part of a EWKT rep if present and sets the srid.
protected abstract  void innerWKT(java.lang.StringBuffer SB)
          Render the "inner" part of the WKT (inside the brackets) into the StringBuffer.
 boolean isMeasured()
          Returns whether we have a measure
protected  void mediumWKT(java.lang.StringBuffer sb)
          Render the WKT without the type name, but including the brackets into the StringBuffer
abstract  int numPoints()
          Return the number of Points of the geometry
 void outerWKT(java.lang.StringBuffer sb)
           
 void outerWKT(java.lang.StringBuffer sb, boolean putM)
          Render the WKT version of this Geometry (without SRID) into the given StringBuffer.
 void setSrid(int srid)
          Recursively sets the srid on this geometry and all contained subgeometries
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

LINEARRING

public static final int LINEARRING
Fake type for linear ring

See Also:
Constant Field Values

POINT

public static final int POINT
The OGIS geometry type number for points.

See Also:
Constant Field Values

LINESTRING

public static final int LINESTRING
The OGIS geometry type number for lines.

See Also:
Constant Field Values

POLYGON

public static final int POLYGON
The OGIS geometry type number for polygons.

See Also:
Constant Field Values

MULTIPOINT

public static final int MULTIPOINT
The OGIS geometry type number for aggregate points.

See Also:
Constant Field Values

MULTILINESTRING

public static final int MULTILINESTRING
The OGIS geometry type number for aggregate lines.

See Also:
Constant Field Values

MULTIPOLYGON

public static final int MULTIPOLYGON
The OGIS geometry type number for aggregate polygons.

See Also:
Constant Field Values

GEOMETRYCOLLECTION

public static final int GEOMETRYCOLLECTION
The OGIS geometry type number for feature collections.

See Also:
Constant Field Values

ALLTYPES

public static final java.lang.String[] ALLTYPES

dimension

public int dimension
The dimensionality of this feature (2,3)


haveMeasure

public boolean haveMeasure
Do we have a measure (4th dimension)


type

public final int type
The OGIS geometry type of this feature. this is final as it never changes, it is bound to the subclass of the instance.


srid

public int srid
The spacial reference system id of this geometry, default (no srid) is -1

Constructor Detail

Geometry

protected Geometry(int type)
Constructor for subclasses

Parameters:
type - has to be given by all subclasses.
Method Detail

getTypeString

public static java.lang.String getTypeString(int type)
The Text representations of the geometry types


hashCode

public int hashCode()
java.lang.Object hashCode implementation

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object other)
java.lang.Object equals implementation

Overrides:
equals in class java.lang.Object

equals

public boolean equals(Geometry other)
geometry specific equals implementation - only defined for non-null values


equalsintern

protected abstract boolean equalsintern(Geometry other)
Whether test coordinates for geometry - subclass specific code Implementors can assume that dimensin, type, srid and haveMeasure are equal, other != null and other is the same subclass.


numPoints

public abstract int numPoints()
Return the number of Points of the geometry


getPoint

public abstract Point getPoint(int n)
Get the nth Point of the geometry

Parameters:
n - the index of the point, from 0 to numPoints()-1;
Throws:
java.lang.ArrayIndexOutOfBoundsException - in case of an emtpy geometry or bad index.

getFirstPoint

public abstract Point getFirstPoint()
Same as getPoint(0);


getLastPoint

public abstract Point getLastPoint()
Same as getPoint(numPoints()-1);


getType

public int getType()
The OGIS geometry type number of this geometry.


getTypeString

public java.lang.String getTypeString()
Return the Type as String


isMeasured

public boolean isMeasured()
Returns whether we have a measure


getDimension

public int getDimension()
Queries the number of geometric dimensions of this geometry. This does not include measures, as opposed to the server.

Returns:
The dimensionality (eg, 2D or 3D) of this geometry.

getSrid

public int getSrid()
The OGIS geometry type number of this geometry.


setSrid

public void setSrid(int srid)
Recursively sets the srid on this geometry and all contained subgeometries


toString

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

outerWKT

public void outerWKT(java.lang.StringBuffer sb,
                     boolean putM)
Render the WKT version of this Geometry (without SRID) into the given StringBuffer.


outerWKT

public final void outerWKT(java.lang.StringBuffer sb)

mediumWKT

protected void mediumWKT(java.lang.StringBuffer sb)
Render the WKT without the type name, but including the brackets into the StringBuffer


innerWKT

protected abstract void innerWKT(java.lang.StringBuffer SB)
Render the "inner" part of the WKT (inside the brackets) into the StringBuffer.


getValue

public java.lang.String getValue()
backwards compatibility method


checkConsistency

public boolean checkConsistency()
Do some internal consistency checks on the geometry. Currently, all Geometries must have a valid dimension (2 or 3) and a valid type. 2-dimensional Points must have Z=0.0, as well as non-measured Points must have m=0.0. Composed geometries must have all equal SRID, dimensionality and measures, as well as that they do not contain NULL or inconsistent subgeometries. BinaryParser and WKTParser should only generate consistent geometries. BinaryWriter may produce invalid results on inconsistent geometries.

Returns:
true if all checks are passed.

initSRID

protected java.lang.String initSRID(java.lang.String value)
Splits the SRID=4711; part of a EWKT rep if present and sets the srid.



Copyright © 2009. All Rights Reserved.