java.lang.Cloneable
public class Geometry
extends java.lang.Object
implements java.lang.Cloneable
The Geometry class is a binding for the C++ OGRGeometry class.
Some spatial analysis methods require that OGR is built on the GEOS library to work properly. The precise meaning of methods that describe spatial relationships between geometries is described in the SFCOM, or other simple features interface specifications, like "OpenGIS(R) Implementation Specification for Geographic information - Simple feature access - Part 1: Common architecture" (OGC 06-103r3)
Constructor | Description |
---|---|
Geometry(int eGeometryType) |
Create an empty geometry of desired type.
|
Geometry(int eGeometryType,
java.lang.String wkt,
byte[] wkb,
java.lang.String gml) |
Deprecated.
Use referenced methods instead.
|
Modifier and Type | Method | Description |
---|---|---|
int |
AddGeometry(Geometry other) |
Add a geometry to the container.
|
int |
AddGeometryDirectly(Geometry other) |
Add a geometry directly to the container.
|
void |
AddPoint(double x,
double y) |
Add a point to a geometry (line string or point).
|
void |
AddPoint(double x,
double y,
double z) |
Add a point to a geometry (line string or point).
|
void |
AddPoint_2D(double x,
double y) |
Add a point to a geometry (line string or point).
|
void |
AddPointM(double x,
double y,
double m) |
|
void |
AddPointZM(double x,
double y,
double z,
double m) |
|
double |
Area() |
Compute geometry area.
|
void |
AssignSpatialReference(SpatialReference srs) |
Assign spatial reference to this object.
|
Geometry |
Boundary() |
Compute boundary.
|
Geometry |
Buffer(double distance) |
Compute buffer of geometry.
|
Geometry |
Buffer(double distance,
int quadsecs) |
Compute buffer of geometry.
|
Geometry |
Centroid() |
Compute the geometry centroid.
|
java.lang.Object |
clone() |
|
Geometry |
Clone() |
Make a copy of this object.
|
void |
CloseRings() |
Force rings to be closed.
|
boolean |
Contains(Geometry other) |
Test for containment.
|
Geometry |
ConvexHull() |
Compute convex hull.
|
int |
CoordinateDimension() |
|
static Geometry |
CreateFromGML(java.lang.String gml) |
Create geometry from GML.
|
static Geometry |
CreateFromJson(java.lang.String json) |
Create geometry from GeoJSON.
|
static Geometry |
CreateFromWkb(byte[] wkb) |
Create a geometry object of the appropriate type from it's well known
binary representation.
|
static Geometry |
CreateFromWkt(java.lang.String wkt) |
Create a geometry object of the appropriate type from it's well known
text representation.
|
PreparedGeometry |
CreatePreparedGeometry() |
|
boolean |
Crosses(Geometry other) |
Test for crossing.
|
Geometry |
DelaunayTriangulation() |
|
Geometry |
DelaunayTriangulation(double dfTolerance) |
|
Geometry |
DelaunayTriangulation(double dfTolerance,
int bOnlyEdges) |
|
void |
delete() |
Delete a geometry.
|
Geometry |
Difference(Geometry other) |
Compute difference.
|
boolean |
Disjoint(Geometry other) |
Test for disjointness.
|
double |
Distance(Geometry other) |
Compute distance between two geometries.
|
double |
Distance3D(Geometry other) |
|
void |
Empty() |
Clear geometry information.
|
boolean |
Equal(Geometry other) |
Returns two if two geometries are equivalent.
|
boolean |
equals(java.lang.Object obj) |
|
boolean |
Equals(Geometry other) |
|
java.lang.String |
ExportToGML() |
Convert a geometry into GML format.
|
java.lang.String |
ExportToGML(java.util.Vector options) |
Convert a geometry into GML format.
|
byte[] |
ExportToIsoWkb() |
|
byte[] |
ExportToIsoWkb(int byte_order) |
|
int |
ExportToIsoWkt(java.lang.String[] argout) |
|
java.lang.String |
ExportToJson() |
Convert a geometry into GeoJSON format.
|
java.lang.String |
ExportToJson(java.util.Vector options) |
Convert a geometry into GeoJSON format.
|
java.lang.String |
ExportToKML() |
Convert a geometry into KML format.
|
java.lang.String |
ExportToKML(java.lang.String altitude_mode) |
Convert a geometry into KML format.
|
byte[] |
ExportToWkb() |
Convert a geometry into well known binary format.
|
int |
ExportToWkb(byte[] wkbArray,
int byte_order) |
Convert a geometry into well known binary format.
|
byte[] |
ExportToWkb(int byte_order) |
Convert a geometry into well known binary format.
|
java.lang.String |
ExportToWkt() |
Convert a geometry into well known text format.
|
int |
ExportToWkt(java.lang.String[] argout) |
Convert a geometry into well known text format.
|
void |
FlattenTo2D() |
Convert geometry to strictly 2D.
|
double |
GetArea() |
Deprecated.
|
Geometry |
GetBoundary() |
Deprecated.
|
int |
GetCoordinateDimension() |
Get the dimension of the coordinates in this object.
|
Geometry |
GetCurveGeometry() |
|
Geometry |
GetCurveGeometry(java.util.Vector options) |
|
int |
GetDimension() |
Get the dimension of this object.
|
void |
GetEnvelope(double[] argout) |
Computes and returns the bounding envelope for this geometry.
|
void |
GetEnvelope3D(double[] argout) |
Computes and returns the 3D bounding envelope for this geometry.
|
int |
GetGeometryCount() |
Fetch the number of elements in a geometry or number of geometries in
container.
|
java.lang.String |
GetGeometryName() |
Fetch WKT name for geometry type.
|
Geometry |
GetGeometryRef(int iSubGeom) |
Fetch geometry from a geometry container.
|
int |
GetGeometryType() |
Fetch geometry type.
|
Geometry |
GetLinearGeometry() |
|
Geometry |
GetLinearGeometry(double dfMaxAngleStepSizeDegrees) |
|
Geometry |
GetLinearGeometry(double dfMaxAngleStepSizeDegrees,
java.util.Vector options) |
|
double |
GetM() |
|
double |
GetM(int point) |
|
double[] |
GetPoint(int iPoint) |
Fetch a point in line string or a point geometry.
|
void |
GetPoint(int iPoint,
double[] argout) |
Fetch a point in line string or a point geometry.
|
double[] |
GetPoint_2D(int iPoint) |
Fetch a point in line string or a point geometry.
|
void |
GetPoint_2D(int iPoint,
double[] argout) |
Fetch a point in line string or a point geometry.
|
int |
GetPointCount() |
Fetch number of points from a geometry.
|
double[][] |
GetPoints() |
Returns all points of a point or a line string.
|
double[][] |
GetPoints(int nCoordinateDimension) |
Returns all points of a point or a line string.
|
void |
GetPointZM(int iPoint,
double[] argout) |
|
SpatialReference |
GetSpatialReference() |
Returns spatial reference system for object.
|
double |
GetX() |
Fetch the x coordinate of the first point from a geometry.
|
double |
GetX(int ipoint) |
Fetch the x coordinate of a point from a geometry.
|
double |
GetY() |
Fetch the y coordinate of the first point from a geometry.
|
double |
GetY(int ipoint) |
Fetch the y coordinate of a point from a geometry.
|
double |
GetZ() |
Fetch the z coordinate of the first point from a geometry.
|
double |
GetZ(int ipoint) |
Fetch the z coordinate of a point from a geometry.
|
int |
HasCurveGeometry() |
|
int |
HasCurveGeometry(int bLookForCircular) |
|
int |
hashCode() |
|
boolean |
Intersect(Geometry other) |
Deprecated.
|
Geometry |
Intersection(Geometry other) |
Compute intersection.
|
boolean |
Intersects(Geometry other) |
Do these features intersect?
|
int |
Is3D() |
|
boolean |
IsEmpty() |
Returns true (non-zero) if the object has no points.
|
int |
IsMeasured() |
|
boolean |
IsRing() |
Test if the geometry is a ring.
|
boolean |
IsSimple() |
Test if the geometry is simple.
|
boolean |
IsValid() |
Test if the geometry is valid.
|
double |
Length() |
Returns the length of the geometry
|
Geometry |
MakeValid() |
|
boolean |
Overlaps(Geometry other) |
Test for overlap.
|
Geometry |
PointOnSurface() |
|
Geometry |
Polygonize() |
|
int |
RemoveGeometry(int iSubGeom) |
|
Geometry |
RemoveLowerDimensionSubGeoms() |
|
void |
Segmentize(double max_length) |
Modify the geometry such it has no segment longer then the given distance.
|
void |
Set3D(int b3D) |
|
void |
SetCoordinateDimension(int dimension) |
Set the coordinate dimension.
|
void |
SetMeasured(int bMeasured) |
|
void |
SetPoint(int ipoint,
double x,
double y) |
Set the location of a vertex in a point or linestring geometry.
|
void |
SetPoint(int ipoint,
double x,
double y,
double z) |
Set the location of a vertex in a point or linestring geometry.
|
void |
SetPoint_2D(int ipoint,
double x,
double y) |
Set the location of a vertex in a point or linestring geometry.
|
void |
SetPointM(int point,
double x,
double y,
double m) |
|
void |
SetPointZM(int point,
double x,
double y,
double z,
double m) |
|
Geometry |
Simplify(double dTolerance) |
Simplify the geometry.
|
Geometry |
SimplifyPreserveTopology(double dTolerance) |
Simplify the geometry while preserving topology.
|
void |
SwapXY() |
|
Geometry |
SymDifference(Geometry other) |
Compute symmetric difference.
|
Geometry |
SymmetricDifference(Geometry other) |
Deprecated.
|
boolean |
Touches(Geometry other) |
Test for touching.
|
Geometry |
Transform(GeomTransformer transformer) |
|
int |
Transform(CoordinateTransformation ct) |
Apply arbitrary coordinate transformation to geometry.
|
int |
TransformTo(SpatialReference srs) |
Transform geometry to new spatial reference system.
|
Geometry |
Union(Geometry other) |
Compute union.
|
Geometry |
UnionCascaded() |
Compute union using cascading.
|
Geometry |
Value(double dfDistance) |
|
boolean |
Within(Geometry other) |
Test for containment.
|
int |
WkbSize() |
Returns size of related binary representation.
|
public Geometry(int eGeometryType, java.lang.String wkt, byte[] wkb, java.lang.String gml)
The geometry can be instantiated by 4 different and exclusive way:
You should rather use either the Geometry(int) constructor, or the static methods like Geometry.CreateFromWkt(), Geometry.CreateFromWbt() or Geometry.CreateFromGML().
eGeometryType
- the type code of the geometry class to be instantiated.wkt
- the well known text representationwkb
- the well known binary representationgml
- the GML representationGeometry(int eGeometryType)
,
CreateFromWkt(String wkt)
,
CreateFromWkb(byte[] wkb)
,
CreateFromGML(String gml)
public Geometry(int eGeometryType)
The type may be one of ogr.wkbPoint, etc..
eGeometryType
- the type code of the geometry class to be instantiated.public void delete()
Calling this method is not required as normal garbage collection will reclaim associated resources when the object goes out of scope. Otherwise calling delete() explicitly will help release resources sooner. Don't call any method on a deleted object !
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.Object clone()
clone
in class java.lang.Object
public double[] GetPoint_2D(int iPoint)
iPoint
- the vertex to fetch, from 0 to GetNumPoints()-1, zero for a point.public double[] GetPoint(int iPoint)
iPoint
- the vertex to fetch, from 0 to GetNumPoints()-1, zero for a point.public static Geometry CreateFromWkt(java.lang.String wkt)
wkt
- string containing well known text
representation of the geometry to be created.public static Geometry CreateFromWkb(byte[] wkb)
wkb
- input BLOB data.public static Geometry CreateFromGML(java.lang.String gml)
This method translates a fragment of GML containing only the geometry portion into a corresponding Geometry. There are many limitations on the forms of GML geometries supported by this parser, but they are too numerous to list here.
gml
- The GML fragment for the geometry.public static Geometry CreateFromJson(java.lang.String json)
json
- GeoJSON contentpublic int ExportToWkb(byte[] wkbArray, int byte_order)
This function relates to the SFCOM IWks::ExportToWKB() method.
wkbArray
- a sufficiently large array (at least WkbSize() large) to receive the wkb content.byte_order
- One of wkbXDR or wkbNDR indicating MSB or LSB byte order
respectively.public int ExportToWkt(java.lang.String[] argout)
This method relates to the SFCOM IWks::ExportToWKT() method.
argout
- an allocated array of 1 string where the WKT output will be insertedpublic int ExportToIsoWkt(java.lang.String[] argout)
public byte[] ExportToWkb(int byte_order)
This function relates to the SFCOM IWks::ExportToWKB() method.
byte_order
- One of wkbXDR or wkbNDR indicating MSB or LSB byte order
respectively.public byte[] ExportToWkb()
This function relates to the SFCOM IWks::ExportToWKB() method. MSB order (wkbXDR) will be used.
public byte[] ExportToIsoWkb(int byte_order)
public byte[] ExportToIsoWkb()
public java.lang.String ExportToGML(java.util.Vector options)
The GML geometry is expressed directly in terms of GML basic data types assuming the this is available in the gml namespace. The supported options in OGR 1.8.0 are :
options
- a list of strings.public java.lang.String ExportToGML()
The GML geometry is expressed directly in terms of GML basic data types assuming the this is available in the gml namespace.
public java.lang.String ExportToKML(java.lang.String altitude_mode)
altitude_mode
- string which will be inserted in-between the <altitude_mode> tag.public java.lang.String ExportToKML()
public java.lang.String ExportToJson(java.util.Vector options)
options
- a list of strings. For now, only COORDINATE_PRECISION=int_number
where int_number is the maximum number of figures after decimal separator to write in coordinates.public java.lang.String ExportToJson()
public void AddPoint(double x, double y, double z)
The vertex count of the line string is increased by one, and assigned from the passed location value.
x
- coordinate of point to add.y
- coordinate of point to add.z
- coordinate of point to add.public void AddPoint(double x, double y)
The vertex count of the line string is increased by one, and assigned from the passed location value.
x
- coordinate of point to add.y
- coordinate of point to add.public void AddPointM(double x, double y, double m)
public void AddPointZM(double x, double y, double z, double m)
public void AddPoint_2D(double x, double y)
The vertex count of the line string is increased by one, and assigned from the passed location value.
x
- x coordinate of point to add.y
- y coordinate of point to add.public int AddGeometryDirectly(Geometry other)
Some subclasses of OGRGeometryCollection restrict the types of geometry that can be added, and may return an error. Ownership of the passed geometry is taken by the container rather than cloning as addGeometry() does.
There is no SFCOM analog to this method.
For a polygon, other must be a linearring. If the polygon is empty, the first added subgeometry will be the exterior ring. The next ones will be the interior rings.
other
- geometry to add to the container.public int AddGeometry(Geometry other)
Some subclasses of OGRGeometryCollection restrict the types of geometry that can be added, and may return an error. The passed geometry is cloned to make an internal copy.
There is no SFCOM analog to this method.
For a polygon, other must be a linearring. If the polygon is empty, the first added subgeometry will be the exterior ring. The next ones will be the interior rings.
other
- geometry to add to the container.public int RemoveGeometry(int iSubGeom)
public Geometry Clone()
This method relates to the SFCOM IGeometry::clone() method.
public int GetGeometryType()
Note that the geometry type may include the 2.5D flag. To get a 2D flattened version of the geometry type apply the wkbFlatten() macro to the return result.
public java.lang.String GetGeometryName()
There is no SFCOM analog to this method.
public double Length()
public double Area()
Computes the area for an OGRLinearRing, OGRPolygon or OGRMultiPolygon. Undefined for all other geometry types (returns zero).
public double GetArea()
Area()
public int GetPointCount()
Only wkbPoint[25D] or wkbLineString[25D] may return a valid value. Other geometry types will silently return 0.
public double[][] GetPoints(int nCoordinateDimension)
This method returns an array of tuples with the [x,y] or [x,y,z] coordinates pair or triplets.
Only wkbPoint[25D] or wkbLineString[25D] may return a valid value. Other geometry types will return null.
nCoordinateDimension
- if nCoordinateDimension == 0 then the number of coordinates per tuple
will reflect the coordinate dimension of the geometry. If nCoordinateDimension == 2,
the number of coordinates per tuple will be 2. If nCoordinateDimension == 3, the number of
coordinates per tuple will be 3.public double[][] GetPoints()
Same as below with nCoordinateDimension == 0
GetPoints(int)
public double GetX(int ipoint)
ipoint
- point to get the x coordinate. (must be 0 for a point geometry)public double GetX()
public double GetY(int ipoint)
ipoint
- point to get the y coordinate. (must be 0 for a point geometry)public double GetY()
public double GetZ(int ipoint)
ipoint
- point to get the z coordinate. (must be 0 for a point geometry)public double GetZ()
public double GetM(int point)
public double GetM()
public void GetPoint(int iPoint, double[] argout)
iPoint
- the vertex to fetch, from 0 to GetNumPoints()-1, zero for a point.argout
- an allocated array of 3 doubles to contain the x, y, z coordinates.public void GetPointZM(int iPoint, double[] argout)
public void GetPoint_2D(int iPoint, double[] argout)
iPoint
- the vertex to fetch, from 0 to GetNumPoints()-1, zero for a point.argout
- an allocated array of 2 doubles to contain the x, y coordinates.public int GetGeometryCount()
Only geometries of type wkbPolygon[25D], wkbMultiPoint[25D], wkbMultiLineString[25D], wkbMultiPolygon[25D] or wkbGeometryCollection[25D] may return a valid value. Other geometry types will silently return 0. For a polygon, the returned number is the number of rings (exterior ring + interior rings).
public void SetPoint(int ipoint, double x, double y, double z)
If ipoint is larger than the number of existing points in the linestring, the point count will be increased to accommodate the request.
ipoint
- the index of the vertex to assign (zero based) or
zero for a point.x
- input X coordinate to assign.y
- input Y coordinate to assign.z
- input Z coordinate to assign (defaults to zero).public void SetPoint(int ipoint, double x, double y)
If ipoint is larger than the number of existing points in the linestring, the point count will be increased to accommodate the request.
ipoint
- the index of the vertex to assign (zero based) or
zero for a point.x
- input X coordinate to assign.y
- input Y coordinate to assign.public void SetPointM(int point, double x, double y, double m)
public void SetPointZM(int point, double x, double y, double z, double m)
public void SetPoint_2D(int ipoint, double x, double y)
If ipoint is larger than the number of existing points in the linestring, the point count will be increased to accommodate the request.
ipoint
- the index of the vertex to assign (zero based) or
zero for a point.x
- input X coordinate to assign.y
- input Y coordinate to assign.public void SwapXY()
public Geometry GetGeometryRef(int iSubGeom)
This function returns a handle to a geometry within the container. The returned geometry remains owned by the container, and should not be modified. The handle is only valid until the next change to the geometry container. Use Clone() to make a copy.
This function relates to the SFCOM IGeometryCollection::get_Geometry() method.
For a polygon, OGR_G_GetGeometryRef(iSubGeom) returns the exterior ring if iSubGeom == 0, and the interior rings for iSubGeom > 0.
iSubGeom
- the index of the geometry to fetch, between 0 and
GetGeometryCount() - 1.public Geometry Simplify(double dTolerance)
This function is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this function will always fail, issuing a CPLE_NotSupported error.
dTolerance
- the distance tolerance for the simplification.public Geometry SimplifyPreserveTopology(double dTolerance)
This function is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this function will always fail, issuing a CPLE_NotSupported error.
dTolerance
- the distance tolerance for the simplification.public Geometry DelaunayTriangulation(double dfTolerance, int bOnlyEdges)
public Geometry DelaunayTriangulation(double dfTolerance)
public Geometry DelaunayTriangulation()
public Geometry Polygonize()
public Geometry Boundary()
A new geometry object is created and returned containing the boundary of the geometry on which the method is invoked.
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail.
public Geometry GetBoundary()
Boundary()
public Geometry ConvexHull()
A new geometry object is created and returned containing the convex hull of the geometry on which the method is invoked.
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail.
public Geometry MakeValid()
public Geometry RemoveLowerDimensionSubGeoms()
public Geometry Buffer(double distance, int quadsecs)
Builds a new geometry containing the buffer region around the geometry on which it is invoked. The buffer is a polygon containing the region within the buffer distance of the original geometry.
Some buffer sections are properly described as curves, but are converted to approximate polygons. The nQuadSegs parameter can be used to control how many segments should be used to define a 90 degree curve - a quadrant of a circle. A value of 30 is a reasonable default. Large values result in large numbers of vertices in the resulting buffer geometry while small numbers reduce the accuracy of the result.
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail.
distance
- the buffer distance to be applied.quadsecs
- the number of segments used to approximate a 90 degree (quadrant) of
curvature.public Geometry Buffer(double distance)
Same as below with quadsecs == 30.
Buffer(double distance, int quadsecs)
public Geometry Intersection(Geometry other)
Generates a new geometry which is the region of intersection of the two geometries operated on. The Intersects() method can be used to test if two geometries intersect.
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail.
other
- the other geometry intersected with "this" geometry.Intersects(Geometry)
public Geometry Union(Geometry other)
Generates a new geometry which is the region of union of the two geometries operated on.
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail.
other
- the other geometry unioned with "this" geometry.public Geometry UnionCascaded()
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.
public Geometry Difference(Geometry other)
Generates a new geometry which is the region of this geometry with the region of the second geometry removed.
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail.
other
- the other geometry removed from "this" geometry.public Geometry SymDifference(Geometry other)
Generates a new geometry which is the symmetric difference of this geometry and the second geometry passed into the method.
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail.
other
- the other geometry.public Geometry SymmetricDifference(Geometry other)
SymDifference(Geometry)
public double Distance(Geometry other)
Returns the shortest distance between the two geometries.
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail.
other
- the other geometry to compare against.public double Distance3D(Geometry other)
public void Empty()
This restores the geometry to it's initial state after construction, and before assignment of actual geometry.
This method relates to the SFCOM IGeometry::Empty() method.
public boolean IsEmpty()
Normally this returns false except between when an object is instantiated and points have been assigned. This method relates to the SFCOM IGeometry::IsEmpty() method.
public boolean IsValid()
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always return false.
public boolean IsSimple()
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always return false.
public boolean IsRing()
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always return false.
public boolean Intersects(Geometry other)
Determines whether two geometries intersect. If GEOS is enabled, then this is done in rigorous fashion otherwise true is returned if the envelopes (bounding boxes) of the two features overlap.
The geom argument may be safely null, but in this case the method will always return true. That is, a null geometry is treated as being everywhere.
other
- the other geometry to test against.public boolean Intersect(Geometry other)
Intersects(Geometry)
public boolean Equals(Geometry other)
public boolean Equal(Geometry other)
public boolean Disjoint(Geometry other)
Tests if this geometry and the other passed into the method are disjoint.
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail.
other
- the geometry to compare to this geometry.public boolean Touches(Geometry other)
Tests if this geometry and the other passed into the method are touching. This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail.
other
- the geometry to compare to this geometry.public boolean Crosses(Geometry other)
Tests if this geometry and the other passed into the method are crossing.
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail.
other
- the geometry to compare to this geometry.public boolean Within(Geometry other)
Tests if actual geometry object is within the passed geometry. This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail.
other
- the geometry to compare to this geometry.public boolean Contains(Geometry other)
Tests if actual geometry object contains the passed geometry.
This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail.
other
- the geometry to compare to this geometry.public boolean Overlaps(Geometry other)
Tests if this geometry and the other passed into the method overlap, that is their intersection has a non-zero area. This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail.
other
- the geometry to compare to this geometry.public int TransformTo(SpatialReference srs)
This method will transform the coordinates of a geometry from their current spatial reference system to a new target spatial reference system. Normally this means reprojecting the vectors, but it could include datum shifts, and changes of units.
This method will only work if the geometry already has an assigned spatial reference system, and if it is transformable to the target coordinate system.
Because this method requires internal creation and initialization of an CoordinateTransformation object it is significantly more expensive to use this method to transform many geometries than it is to create the CoordinateTransformation in advance, and call transform() with that transformation. This method exists primarily for convenience when only transforming a single geometry.
srs
- spatial reference system to transform to.public int Transform(CoordinateTransformation ct)
This method will transform the coordinates of a geometry from their current spatial reference system to a new target spatial reference system. Normally this means reprojecting the vectors, but it could include datum shifts, and changes of units.
Note that this method does not require that the geometry already have a spatial reference system. It will be assumed that they can be treated as having the source spatial reference system of the CoordinateTransformation object, and the actual SRS of the geometry will be ignored. On successful completion the output OGRSpatialReference of the CoordinateTransformation will be assigned to the geometry.
ct
- the transformation to apply.public SpatialReference GetSpatialReference()
This method relates to the SFCOM IGeometry::get_SpatialReference() method.
public void AssignSpatialReference(SpatialReference srs)
Any existing spatial reference is replaced, but under no circumstances does this result in the object being reprojected. It is just changing the interpretation of the existing geometry. Note that assigning a spatial reference increments the reference count on the SpatialReference, but does not copy it. This is similar to the SFCOM IGeometry::put_SpatialReference() method.
srs
- new spatial reference system to apply.public void CloseRings()
If this geometry, or any contained geometries has polygon rings that are not closed, they will be closed by adding the starting point at the end.
public void FlattenTo2D()
In a sense this converts all Z coordinates to 0.0.
public void Segmentize(double max_length)
Interpolated points will have Z and M values (if needed) set to 0. Distance computation is performed in 2d only
max_length
- the maximum distance between 2 points after segmentizationpublic void GetEnvelope(double[] argout)
argout
- an allocated array of 4 doubles into which to place the resultpublic void GetEnvelope3D(double[] argout)
argout
- an allocated array of 6 doubles into which to place the resultpublic Geometry Centroid()
This method relates to the SFCOM ISurface::get_Centroid() method however the current implementation based on GEOS can operate on other geometry types such as multipoint, linestring, geometrycollection such as multipolygons. OGC SF SQL 1.1 defines the operation for surfaces (polygons). SQL/MM-Part 3 defines the operation for surfaces and multisurfaces (multipolygons).
This function is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this function will always fail, issuing a CPLE_NotSupported error.
public Geometry PointOnSurface()
public int WkbSize()
This method returns the exact number of bytes required to hold the well known binary representation of this geometry object. Its computation may be slightly expensive for complex geometries. This method relates to the SFCOM IWks::WkbSize() method.
public int GetCoordinateDimension()
This method corresponds to the SFCOM IGeometry::GetDimension() method.
public int CoordinateDimension()
public int Is3D()
public int IsMeasured()
public void SetCoordinateDimension(int dimension)
This method sets the explicit coordinate dimension. Setting the coordinate dimension of a geometry to 2 should zero out any existing Z values. Setting the dimension of a geometry collection will not necessarily affect the children geometries.
dimension
- New coordinate dimension value, either 2 or 3.public void Set3D(int b3D)
public void SetMeasured(int bMeasured)
public int GetDimension()
This method corresponds to the SFCOM IGeometry::GetDimension() method. It indicates the dimension of the object, but does not indicate the dimension of the underlying space (as indicated by GetCoordinateDimension()).
public int HasCurveGeometry(int bLookForCircular)
public int HasCurveGeometry()
public Geometry GetLinearGeometry(double dfMaxAngleStepSizeDegrees, java.util.Vector options)
public Geometry GetLinearGeometry(double dfMaxAngleStepSizeDegrees)
public Geometry GetLinearGeometry()
public Geometry GetCurveGeometry(java.util.Vector options)
public Geometry GetCurveGeometry()
public Geometry Value(double dfDistance)
public Geometry Transform(GeomTransformer transformer)
public PreparedGeometry CreatePreparedGeometry()
public java.lang.String ExportToWkt()
This method relates to the SFCOM IWks::ExportToWKT() method.