org.postgis
Class ComposedGeom

java.lang.Object
  extended by org.postgis.Geometry
      extended by org.postgis.ComposedGeom
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
GeometryCollection, MultiLineString, MultiPolygon, PointComposedGeom, Polygon

public abstract class ComposedGeom
extends Geometry

ComposedGeom - Abstract base class for all Geometries that are composed out of other Geometries. In fact, this currently are all Geometry subclasses except Point.

Author:
markus.schaber@logix-tt.com
See Also:
Serialized Form

Field Summary
static Geometry[] EMPTY
           
protected  Geometry[] subgeoms
          The Array containing the geometries This is only to be exposed by concrete subclasses, to retain type safety.
 
Fields inherited from class org.postgis.Geometry
ALLTYPES, dimension, GEOMETRYCOLLECTION, haveMeasure, LINEARRING, LINESTRING, MULTILINESTRING, MULTIPOINT, MULTIPOLYGON, POINT, POLYGON, srid, type, UNKNOWN_SRID
 
Constructor Summary
  ComposedGeom(int type)
           
protected ComposedGeom(int type, Geometry[] geoms)
           
protected ComposedGeom(int type, java.lang.String value, boolean haveM)
           
 
Method Summary
 boolean checkConsistency()
          Do some internal consistency checks on the geometry.
protected abstract  Geometry[] createSubGeomArray(int size)
          Return the appropriate instance of the subgeometry array - this encapsulates subclass specific array instantiation
protected abstract  Geometry createSubGeomInstance(java.lang.String token, boolean haveM)
          Return the appropriate instance of the subgeometry - this encapsulates subclass specific constructor calls
protected  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.
 Point getFirstPoint()
          Optimized version
 Point getLastPoint()
          Optimized version
 Point getPoint(int n)
          Get the nth Point of the geometry
 Geometry getSubGeometry(int index)
           
 int hashCode()
          java.lang.Object hashCode implementation
protected  void innerWKT(java.lang.StringBuffer sb)
          Render the "inner" part of the WKT (inside the brackets) into the StringBuffer.
 boolean isEmpty()
           
 java.util.Iterator iterator()
           
protected  void mediumWKT(java.lang.StringBuffer sb)
          Render the WKT without the type name, but including the brackets into the StringBuffer
 int numGeoms()
           
 int numPoints()
          Return the number of Points of the geometry
 void setSrid(int srid)
          Recursively sets the srid on this geometry and all contained subgeometries
 
Methods inherited from class org.postgis.Geometry
equals, equals, getDimension, getSrid, getType, getTypeString, getTypeString, getValue, initSRID, isMeasured, outerWKT, outerWKT, parseSRID, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY

public static final Geometry[] EMPTY

subgeoms

protected Geometry[] subgeoms
The Array containing the geometries This is only to be exposed by concrete subclasses, to retain type safety.

Constructor Detail

ComposedGeom

public ComposedGeom(int type)
Parameters:
type -

ComposedGeom

protected ComposedGeom(int type,
                       Geometry[] geoms)

ComposedGeom

protected ComposedGeom(int type,
                       java.lang.String value,
                       boolean haveM)
                throws java.sql.SQLException
Throws:
java.sql.SQLException
Method Detail

getSubGeometry

public Geometry getSubGeometry(int index)

numGeoms

public int numGeoms()

createSubGeomInstance

protected abstract Geometry createSubGeomInstance(java.lang.String token,
                                                  boolean haveM)
                                           throws java.sql.SQLException
Return the appropriate instance of the subgeometry - this encapsulates subclass specific constructor calls

Throws:
java.sql.SQLException

createSubGeomArray

protected abstract Geometry[] createSubGeomArray(int size)
Return the appropriate instance of the subgeometry array - this encapsulates subclass specific array instantiation


equalsintern

protected boolean equalsintern(Geometry other)
Description copied from class: Geometry
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.

Specified by:
equalsintern in class Geometry

numPoints

public int numPoints()
Description copied from class: Geometry
Return the number of Points of the geometry

Specified by:
numPoints in class Geometry

getPoint

public Point getPoint(int n)
Description copied from class: Geometry
Get the nth Point of the geometry

Specified by:
getPoint in class Geometry
Parameters:
n - the index of the point, from 0 to numPoints()-1;

getLastPoint

public Point getLastPoint()
Optimized version

Specified by:
getLastPoint in class Geometry

getFirstPoint

public Point getFirstPoint()
Optimized version

Specified by:
getFirstPoint in class Geometry

iterator

public java.util.Iterator iterator()

isEmpty

public boolean isEmpty()

mediumWKT

protected void mediumWKT(java.lang.StringBuffer sb)
Description copied from class: Geometry
Render the WKT without the type name, but including the brackets into the StringBuffer

Overrides:
mediumWKT in class Geometry

innerWKT

protected void innerWKT(java.lang.StringBuffer sb)
Description copied from class: Geometry
Render the "inner" part of the WKT (inside the brackets) into the StringBuffer.

Specified by:
innerWKT in class Geometry

hashCode

public int hashCode()
Description copied from class: Geometry
java.lang.Object hashCode implementation

Overrides:
hashCode in class Geometry

checkConsistency

public boolean checkConsistency()
Description copied from class: Geometry
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.

Overrides:
checkConsistency in class Geometry
Returns:
true if all checks are passed.

setSrid

public void setSrid(int srid)
Description copied from class: Geometry
Recursively sets the srid on this geometry and all contained subgeometries

Overrides:
setSrid in class Geometry