Package net.postgis.jdbc.geometry
Class Geometry
java.lang.Object
net.postgis.jdbc.geometry.Geometry
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ComposedGeom,Point
The base class of all geometries
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String[]intThe dimensionality of this feature (2,3)static final intThe OGIS geometry type number for feature collections.booleanDo we have a measure (4th dimension)static final intFake type for linear ringstatic final intThe OGIS geometry type number for lines.static final intThe OGIS geometry type number for aggregate lines.static final intThe OGIS geometry type number for aggregate points.static final intThe OGIS geometry type number for aggregate polygons.static final intThe OGIS geometry type number for points.static final intThe OGIS geometry type number for polygons.intThe spacial reference system id of this geometry, default is no sridfinal intThe OGIS geometry type of this feature.static final intOfficial UNKNOWN srid value -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanDo some internal consistency checks on the geometry.booleanjava.lang.Object equals implementationbooleangeometry 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.intQueries the number of geometric dimensions of this geometry.abstract PointSame as getPoint(0);abstract PointSame 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.Return the Type as Stringstatic StringgetTypeString(int type) The Text representations of the geometry typesgetValue()backwards compatibility methodinthashCode()java.lang.Object hashCode implementationprotected StringSplits 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.booleanReturns whether we have a measureprotected voidRender the WKT without the type name, but including the brackets into the StringBufferabstract intReturn the number of Points of the geometryfinal voidouterWKT(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 subgeometriestoString()
-
Field Details
-
LINEARRING
public static final int LINEARRINGFake type for linear ring- See Also:
-
POINT
public static final int POINTThe OGIS geometry type number for points.- See Also:
-
LINESTRING
public static final int LINESTRINGThe OGIS geometry type number for lines.- See Also:
-
POLYGON
public static final int POLYGONThe OGIS geometry type number for polygons.- See Also:
-
MULTIPOINT
public static final int MULTIPOINTThe OGIS geometry type number for aggregate points.- See Also:
-
MULTILINESTRING
public static final int MULTILINESTRINGThe OGIS geometry type number for aggregate lines.- See Also:
-
MULTIPOLYGON
public static final int MULTIPOLYGONThe OGIS geometry type number for aggregate polygons.- See Also:
-
GEOMETRYCOLLECTION
public static final int GEOMETRYCOLLECTIONThe OGIS geometry type number for feature collections.- See Also:
-
ALLTYPES
-
dimension
public int dimensionThe dimensionality of this feature (2,3) -
haveMeasure
public boolean haveMeasureDo we have a measure (4th dimension) -
type
public final int typeThe 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_SRIDOfficial UNKNOWN srid value- See Also:
-
srid
public int sridThe 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
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
java.lang.Object equals implementation -
equals
geometry specific equals implementation - only defined for non-null values- Parameters:
other- geometry to compare- Returns:
- true if equal, false otherwise
-
equalsintern
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
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
Same as getPoint(0);- Returns:
- the initial Point in this geometry
-
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
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
-
outerWKT
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
-
mediumWKT
Render the WKT without the type name, but including the brackets into the StringBuffer- Parameters:
sb- StringBuffer to render into
-
innerWKT
Render the "inner" part of the WKT (inside the brackets) into the StringBuffer.- Parameters:
SB- StringBuffer to render into
-
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
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
-