org.postgis

## Class ComposedGeom

- java.lang.Object
- - org.postgis.Geometry
  - - org.postgis.ComposedGeom

All Implemented Interfaces:
  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

Fields
`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

Constructors
`` `ComposedGeom(int type)` Constructs an instance with the specified type
`protected` `ComposedGeom(int type, Geometry[] geoms)`
`protected` `ComposedGeom(int type, String value, boolean haveM)`

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`boolean` `checkConsistency()` Do some internal consistency checks on the geometry.
`protected abstract Geometry[]` `createSubGeomArray(int size)` Return the appropriate instance of the sub-geometry array - this encapsulates subclass specific array instantiation
`protected abstract Geometry` `createSubGeomInstance(String token, boolean haveM)` Return the appropriate instance of the sub-geometry - 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(StringBuffer sb)` Render the "inner" part of the WKT (inside the brackets) into the StringBuffer.
`boolean` `isEmpty()`
`Iterator` `iterator()`
`protected void` `mediumWKT(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)

Constructs an instance with the specified type

Parameters:
  `type` - int value corresponding to the geometry type.

#### ComposedGeom

    protected ComposedGeom(int type,
                           Geometry[] geoms)

#### ComposedGeom

    protected ComposedGeom(int type,
                           String value,
                           boolean haveM)
                    throws SQLException

Throws:
  `SQLException`

### Method Detail

#### getSubGeometry

    public Geometry getSubGeometry(int index)

#### numGeoms

    public int numGeoms()

#### createSubGeomInstance

    protected abstract Geometry createSubGeomInstance(String token,
                                                      boolean haveM)
                                               throws SQLException

Return the appropriate instance of the sub-geometry - this encapsulates subclass specific constructor calls

Parameters:
  `token` - The token containing the value for the sub-geometry
  `haveM` - flag to indicate the existence of a measure
Returns:
  the new sub-geometry
Throws:
  `SQLException` - if a SQLException is thrown

#### createSubGeomArray

    protected abstract Geometry[] createSubGeomArray(int size)

Return the appropriate instance of the sub-geometry array - this encapsulates subclass specific array instantiation

Parameters:
  `size` - number of elements in the array
Returns:
  Geometry array corresponding to the sub-geometry

#### 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`
Parameters:
  `other` - geometry to compare
Returns:
  true if equal, false otherwise

#### numPoints

    public int numPoints()

Description copied from class: `Geometry`
Return the number of Points of the geometry

Specified by:
  `numPoints` in class `Geometry`
Returns:
  number of points in the 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;
Returns:
  nth point in the geometry

#### getLastPoint

    public Point getLastPoint()

Optimized version

Specified by:
  `getLastPoint` in class `Geometry`
Returns:
  the final Point in this geometry

#### getFirstPoint

    public Point getFirstPoint()

Optimized version

Specified by:
  `getFirstPoint` in class `Geometry`
Returns:
  the initial Point in this geometry

#### iterator

    public Iterator iterator()

#### isEmpty

    public boolean isEmpty()

#### mediumWKT

    protected void mediumWKT(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`
Parameters:
  `sb` - StringBuffer to render into

#### innerWKT

    protected void innerWKT(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`
Parameters:
  `sb` - StringBuffer to render into

#### 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`
Parameters:
  `srid` - the SRID for this geometry