Package org.postgis
Class Geometry
- java.lang.Object
-
- org.postgis.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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String[]ALLTYPESintdimensionThe dimensionality of this feature (2,3)static intGEOMETRYCOLLECTIONThe OGIS geometry type number for feature collections.booleanhaveMeasureDo we have a measure (4th dimension)static intLINEARRINGFake type for linear ringstatic intLINESTRINGThe OGIS geometry type number for lines.static intMULTILINESTRINGThe OGIS geometry type number for aggregate lines.static intMULTIPOINTThe OGIS geometry type number for aggregate points.static intMULTIPOLYGONThe OGIS geometry type number for aggregate polygons.static intPOINTThe OGIS geometry type number for points.static intPOLYGONThe OGIS geometry type number for polygons.intsridThe spacial reference system id of this geometry, default is no sridinttypeThe OGIS geometry type of this feature.static intUNKNOWN_SRIDOfficial UNKNOWN srid value
-
Constructor Summary
Constructors Modifier Constructor Description protectedGeometry(int type)Constructor for subclasses
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleancheckConsistency()Do some internal consistency checks on the geometry.booleanequals(Object other)java.lang.Object equals implementationbooleanequals(Geometry other)geometry specific equals implementation - only defined for non-null valuesprotected abstract booleanequalsintern(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.intgetDimension()Queries the number of geometric dimensions of this geometry.abstract PointgetFirstPoint()Same as getPoint(0);abstract PointgetLastPoint()Same as getPoint(numPoints()-1);abstract PointgetPoint(int n)Get the nth Point of the geometryintgetSrid()The OGIS geometry type number of this geometry.intgetType()The OGIS geometry type number of this geometry.StringgetTypeString()Return the Type as Stringstatic StringgetTypeString(int type)The Text representations of the geometry typesStringgetValue()backwards compatibility methodinthashCode()java.lang.Object hashCode implementationprotected StringinitSRID(String value)Splits the SRID=4711; part of a EWKT rep if present and sets the srid.protected abstract voidinnerWKT(StringBuffer SB)Render the "inner" part of the WKT (inside the brackets) into the StringBuffer.booleanisMeasured()Returns whether we have a measureprotected voidmediumWKT(StringBuffer sb)Render the WKT without the type name, but including the brackets into the StringBufferabstract intnumPoints()Return the number of Points of the geometryvoidouterWKT(StringBuffer sb)voidouterWKT(StringBuffer sb, boolean putM)Render the WKT version of this Geometry (without SRID) into the given StringBuffer.static intparseSRID(int srid)Parse a SRID value, anything<= 0is unknownvoidsetSrid(int srid)Recursively sets the srid on this geometry and all contained subgeometriesStringtoString()
-
-
-
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
-
-
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<= 0is unknown- Parameters:
srid- the SRID to parse- Returns:
- parsed SRID value
-
hashCode
public int hashCode()
java.lang.Object hashCode implementation
-
equals
public boolean equals(Object other)
java.lang.Object equals implementation
-
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 intoputM- 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.
-
-