Class Geometry

java.lang.Object
net.postgis.jdbc.geometry.Geometry
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ComposedGeom, Point

public abstract class Geometry extends Object implements Serializable
The base class of all geometries
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String[]
     
    int
    The dimensionality of this feature (2,3)
    static final int
    The OGIS geometry type number for feature collections.
    boolean
    Do we have a measure (4th dimension)
    static final int
    Fake type for linear ring
    static final int
    The OGIS geometry type number for lines.
    static final int
    The OGIS geometry type number for aggregate lines.
    static final int
    The OGIS geometry type number for aggregate points.
    static final int
    The OGIS geometry type number for aggregate polygons.
    static final int
    The OGIS geometry type number for points.
    static final int
    The OGIS geometry type number for polygons.
    int
    The spacial reference system id of this geometry, default is no srid
    final int
    The OGIS geometry type of this feature.
    static final int
    Official UNKNOWN srid value
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Geometry(int type)
    Constructor for subclasses
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Do some internal consistency checks on the geometry.
    boolean
    equals(Object other)
    java.lang.Object equals implementation
    boolean
    geometry specific equals implementation - only defined for non-null values
    protected abstract boolean
    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.
    int
    Queries the number of geometric dimensions of this geometry.
    abstract Point
    Same as getPoint(0);
    abstract Point
    Same as getPoint(numPoints()-1);
    abstract Point
    getPoint(int n)
    Get the nth Point of the geometry
    int
    The OGIS geometry type number of this geometry.
    int
    The OGIS geometry type number of this geometry.
    Return the Type as String
    static String
    getTypeString(int type)
    The Text representations of the geometry types
    backwards compatibility method
    int
    java.lang.Object hashCode implementation
    protected String
    Splits the SRID=4711; part of a EWKT rep if present and sets the srid.
    protected abstract void
    Render the "inner" part of the WKT (inside the brackets) into the StringBuffer.
    boolean
    Returns whether we have a measure
    protected void
    Render the WKT without the type name, but including the brackets into the StringBuffer
    abstract int
    Return the number of Points of the geometry
    final void
     
    void
    outerWKT(StringBuffer sb, boolean putM)
    Render the WKT version of this Geometry (without SRID) into the given StringBuffer.
    static int
    parseSRID(int srid)
    Parse a SRID value, anything <= 0 is unknown
    void
    setSrid(int srid)
    Recursively sets the srid on this geometry and all contained subgeometries
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • LINEARRING

      public static final int LINEARRING
      Fake type for linear ring
      See Also:
    • POINT

      public static final int POINT
      The OGIS geometry type number for points.
      See Also:
    • LINESTRING

      public static final int LINESTRING
      The OGIS geometry type number for lines.
      See Also:
    • POLYGON

      public static final int POLYGON
      The OGIS geometry type number for polygons.
      See Also:
    • MULTIPOINT

      public static final int MULTIPOINT
      The OGIS geometry type number for aggregate points.
      See Also:
    • MULTILINESTRING

      public static final int MULTILINESTRING
      The OGIS geometry type number for aggregate lines.
      See Also:
    • MULTIPOLYGON

      public static final int MULTIPOLYGON
      The OGIS geometry type number for aggregate polygons.
      See Also:
    • GEOMETRYCOLLECTION

      public static final int GEOMETRYCOLLECTION
      The OGIS geometry type number for feature collections.
      See Also:
    • ALLTYPES

      public static final 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.
    • UNKNOWN_SRID

      public static final int UNKNOWN_SRID
      Official UNKNOWN srid value
      See Also:
    • srid

      public int srid
      The spacial reference system id of this geometry, default is no srid
  • Constructor Details

    • Geometry

      protected Geometry(int type)
      Constructor for subclasses
      Parameters:
      type - has to be given by all subclasses.
  • Method Details

    • getTypeString

      public static String getTypeString(int type)
      The Text representations of the geometry types
      Parameters:
      type - int value of the type to lookup
      Returns:
      String reprentation of the type.
    • parseSRID

      public static int parseSRID(int srid)
      Parse a SRID value, anything <= 0 is unknown
      Parameters:
      srid - the SRID to parse
      Returns:
      parsed SRID value
    • hashCode

      public int hashCode()
      java.lang.Object hashCode implementation
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object other)
      java.lang.Object equals implementation
      Overrides:
      equals in class Object
      Parameters:
      other - geometry to compare
      Returns:
      true if equal, false otherwise
    • equals

      public boolean equals(Geometry other)
      geometry specific equals implementation - only defined for non-null values
      Parameters:
      other - geometry to compare
      Returns:
      true if equal, false otherwise
    • 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.
      Parameters:
      other - geometry to compare
      Returns:
      true if equal, false otherwise
    • numPoints

      public abstract int numPoints()
      Return the number of Points of the geometry
      Returns:
      number of points in 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;
      Returns:
      nth point in the geometry
      Throws:
      ArrayIndexOutOfBoundsException - in case of an emtpy geometry or bad index.
    • getFirstPoint

      public abstract Point getFirstPoint()
      Same as getPoint(0);
      Returns:
      the initial Point in this geometry
    • getLastPoint

      public abstract Point getLastPoint()
      Same as getPoint(numPoints()-1);
      Returns:
      the final Point in this geometry
    • getType

      public int getType()
      The OGIS geometry type number of this geometry.
      Returns:
      int value representation for the type of this geometry
    • getTypeString

      public String getTypeString()
      Return the Type as String
      Returns:
      String representation for the type of this geometry
    • isMeasured

      public boolean isMeasured()
      Returns whether we have a measure
      Returns:
      true if the geometry has a measure, false otherwise
    • 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.
      Returns:
      the SRID of this geometry
    • setSrid

      public void setSrid(int srid)
      Recursively sets the srid on this geometry and all contained subgeometries
      Parameters:
      srid - the SRID for this geometry
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • outerWKT

      public void outerWKT(StringBuffer sb, boolean putM)
      Render the WKT version of this Geometry (without SRID) into the given StringBuffer.
      Parameters:
      sb - StringBuffer to render into
      putM - flag to indicate if the M character should be used.
    • outerWKT

      public final void outerWKT(StringBuffer sb)
    • mediumWKT

      protected void mediumWKT(StringBuffer sb)
      Render the WKT without the type name, but including the brackets into the StringBuffer
      Parameters:
      sb - StringBuffer to render into
    • innerWKT

      protected abstract void innerWKT(StringBuffer SB)
      Render the "inner" part of the WKT (inside the brackets) into the StringBuffer.
      Parameters:
      SB - StringBuffer to render into
    • getValue

      public String getValue()
      backwards compatibility method
      Returns:
      String representation of the value for the geometry.
    • 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 String initSRID(String value)
      Splits the SRID=4711; part of a EWKT rep if present and sets the srid.
      Parameters:
      value - String value to extract the SRID from
      Returns:
      value without the SRID=4711; part