Class Geometry

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static 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 is no srid
      int type
      The OGIS geometry type of this feature.
      static int UNKNOWN_SRID
      Official UNKNOWN srid value
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Geometry​(int type)
      Constructor for subclasses
    • 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 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:
        Constant Field Values
      • srid

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

      • Geometry

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

      • 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
      • 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