Class Geometry
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
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
Assign spatial reference to this object.Boundary()
Compute boundary.Buffer
(double distance) Compute buffer of geometry.Buffer
(double distance, int quadsecs) Compute buffer of geometry.Centroid()
Compute the geometry centroid.clone()
Clone()
Make a copy of this object.void
Force rings to be closed.ConcaveHull
(double ratio, boolean allowHoles) boolean
Test for containment.Compute convex hull.int
static Geometry
CreateFromGML
(String gml) Create geometry from GML.static Geometry
CreateFromJson
(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
(String wkt) Create a geometry object of the appropriate type from it's well known text representation.boolean
Test for crossing.DelaunayTriangulation
(double dfTolerance) DelaunayTriangulation
(double dfTolerance, int bOnlyEdges) void
delete()
Delete a geometry.Difference
(Geometry other) Compute difference.boolean
Test for disjointness.double
Compute distance between two geometries.double
Distance3D
(Geometry other) void
Empty()
Clear geometry information.boolean
Returns two if two geometries are equivalent.boolean
boolean
Convert a geometry into GML format.ExportToGML
(Vector options) Convert a geometry into GML format.byte[]
byte[]
ExportToIsoWkb
(int byte_order) int
ExportToIsoWkt
(String[] argout) Convert a geometry into GeoJSON format.ExportToJson
(Vector options) Convert a geometry into GeoJSON format.Convert a geometry into KML format.ExportToKML
(String altitude_mode) Convert a geometry into KML format.byte[]
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.Convert a geometry into well known text format.int
ExportToWkt
(String[] argout) Convert a geometry into well known text format.void
Convert geometry to strictly 2D.double
GetArea()
Deprecated.Deprecated.int
Get the dimension of the coordinates in this object.GetCurveGeometry
(Vector options) int
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
Fetch the number of elements in a geometry or number of geometries in container.Fetch WKT name for geometry type.GetGeometryRef
(int iSubGeom) Fetch geometry from a geometry container.int
Fetch geometry type.GetLinearGeometry
(double dfMaxAngleStepSizeDegrees) GetLinearGeometry
(double dfMaxAngleStepSizeDegrees, 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
Fetch number of points from a geometry.double[][]
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) 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
int
HasCurveGeometry
(int bLookForCircular) int
hashCode()
boolean
Deprecated.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
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 geometryboolean
Test for overlap.int
RemoveGeometry
(int iSubGeom) 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) Simplify
(double dTolerance) Simplify the geometry.SimplifyPreserveTopology
(double dTolerance) Simplify the geometry while preserving topology.void
SwapXY()
SymDifference
(Geometry other) Compute symmetric difference.SymmetricDifference
(Geometry other) Deprecated.boolean
Test for touching.Transform
(GeomTransformer transformer) int
Apply arbitrary coordinate transformation to geometry.int
Transform geometry to new spatial reference system.Compute union.Compute union using cascading.Value
(double dfDistance) boolean
Test for containment.long
WkbSize()
-
Constructor Details
-
Geometry
Deprecated.Use referenced methods instead.Create a new geometry.The geometry can be instantiated by 4 different and exclusive way:
- By specifying the geometry type (ogr.wkbPoint, etc..)
- By specifying the well known text representation (wkt)
- By specifying the well known binary representation (wkb)
- By specifying the GML representation
You should rather use either the Geometry(int) constructor, or the static methods like Geometry.CreateFromWkt(), Geometry.CreateFromWbt() or Geometry.CreateFromGML().
- Parameters:
eGeometryType
- the type code of the geometry class to be instantiated.wkt
- the well known text representationwkb
- the well known binary representationgml
- the GML representation- See Also:
-
Geometry
public Geometry(int eGeometryType) Create an empty geometry of desired type.The type may be one of ogr.wkbPoint, etc..
- Parameters:
eGeometryType
- the type code of the geometry class to be instantiated.- Since:
- Java bindings 1.7.0
-
-
Method Details
-
delete
public void delete()Delete a geometry.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 !
-
equals
-
hashCode
public int hashCode() -
clone
-
GetPoint_2D
public double[] GetPoint_2D(int iPoint) Fetch a point in line string or a point geometry.- Parameters:
iPoint
- the vertex to fetch, from 0 to GetNumPoints()-1, zero for a point.- Returns:
- an allocated array of 2 doubles to contain the x, y coordinates.
- Since:
- Java bindings 1.7.0
-
GetPoint
public double[] GetPoint(int iPoint) Fetch a point in line string or a point geometry.- Parameters:
iPoint
- the vertex to fetch, from 0 to GetNumPoints()-1, zero for a point.- Returns:
- an allocated array of 3 doubles to contain the x, y, z coordinates.
- Since:
- Java bindings 1.7.0
-
CreateFromWkt
Create a geometry object of the appropriate type from it's well known text representation.- Parameters:
wkt
- string containing well known text representation of the geometry to be created.- Returns:
- a geometry on success, or null on error.
- Since:
- Java bindings 1.7.0
-
CreateFromWkb
Create a geometry object of the appropriate type from it's well known binary representation.- Parameters:
wkb
- input BLOB data.- Returns:
- a geometry on success, or null on error.
- Since:
- Java bindings 1.7.0
-
CreateFromGML
Create geometry from 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.
- Parameters:
gml
- The GML fragment for the geometry.- Returns:
- a geometry on success, or null on error.
- Since:
- Java bindings 1.7.0
-
CreateFromJson
Create geometry from GeoJSON.- Parameters:
json
- GeoJSON content- Returns:
- a geometry on success, or null on error.
- Since:
- Java bindings 1.7.0
-
ExportToWkb
public int ExportToWkb(byte[] wkbArray, int byte_order) Convert a geometry into well known binary format.This function relates to the SFCOM IWks::ExportToWKB() method.
- Parameters:
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.- Returns:
- 0 on success. Otherwise throws a RuntimeException (or an error code if DontUseExceptions() has been called).
-
ExportToWkt
Convert a geometry into well known text format.This method relates to the SFCOM IWks::ExportToWKT() method.
- Parameters:
argout
- an allocated array of 1 string where the WKT output will be inserted- Returns:
- Currently 0 is always returned.
-
ExportToIsoWkt
-
ExportToWkb
public byte[] ExportToWkb(int byte_order) Convert a geometry into well known binary format.This function relates to the SFCOM IWks::ExportToWKB() method.
- Parameters:
byte_order
- One of wkbXDR or wkbNDR indicating MSB or LSB byte order respectively.- Returns:
- the wkb content
- Since:
- Java bindings 1.7.0
-
ExportToWkb
public byte[] ExportToWkb()Convert a geometry into well known binary format.This function relates to the SFCOM IWks::ExportToWKB() method. MSB order (wkbXDR) will be used.
- Returns:
- the wkb content
- Since:
- Java bindings 1.7.0
-
ExportToIsoWkb
public byte[] ExportToIsoWkb(int byte_order) -
ExportToIsoWkb
public byte[] ExportToIsoWkb() -
ExportToGML
Convert a geometry into GML format.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 :
- FORMAT=GML3. Otherwise it will default to GML 2.1.2 output.
- GML3_LINESTRING_ELEMENT=curve. (Only valid for FORMAT=GML3) To use gml:Curve element for linestrings. Otherwise gml:LineString will be used .
- GML3_LONGSRS=YES/NO. (Only valid for FORMAT=GML3) Default to YES. If YES, SRS with EPSG authority will be written with the "urn:ogc:def:crs:EPSG::" prefix. In the case, if the SRS is a geographic SRS without explicit AXIS order, but that the same SRS authority code imported with ImportFromEPSGA() should be treated as lat/long, then the function will take care of coordinate order swapping. If set to NO, SRS with EPSG authority will be written with the "EPSG:" prefix, even if they are in lat/long order.
- Parameters:
options
- a list of strings.- Returns:
- A GML fragment or null in case of error.
- Since:
- OGR 1.8.0
-
ExportToGML
Convert a geometry into GML format.The GML geometry is expressed directly in terms of GML basic data types assuming the this is available in the gml namespace.
- Returns:
- A GML fragment or null in case of error.
-
ExportToKML
Convert a geometry into KML format.- Parameters:
altitude_mode
- string which will be inserted in-between the <altitude_mode> tag.- Returns:
- A KML fragment or null in case of error.
-
ExportToKML
Convert a geometry into KML format.- Returns:
- A KML fragment or null in case of error.
- Since:
- Java bindings 1.7.0
-
ExportToJson
Convert a geometry into GeoJSON format.- Parameters:
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.- Returns:
- A GeoJSON fragment or null in case of error.
- Since:
- OGR 1.9.0
-
ExportToJson
Convert a geometry into GeoJSON format.- Returns:
- A GeoJSON fragment or null in case of error.
-
AddPoint
public void AddPoint(double x, double y, double z) Add a point to a geometry (line string or point).The vertex count of the line string is increased by one, and assigned from the passed location value.
- Parameters:
x
- coordinate of point to add.y
- coordinate of point to add.z
- coordinate of point to add.
-
AddPoint
public void AddPoint(double x, double y) Add a point to a geometry (line string or point).The vertex count of the line string is increased by one, and assigned from the passed location value.
- Parameters:
x
- coordinate of point to add.y
- coordinate of point to add.- Since:
- Java bindings 1.7.0
-
AddPointM
public void AddPointM(double x, double y, double m) -
AddPointZM
public void AddPointZM(double x, double y, double z, double m) -
AddPoint_2D
public void AddPoint_2D(double x, double y) Add a point to a geometry (line string or point).The vertex count of the line string is increased by one, and assigned from the passed location value.
- Parameters:
x
- x coordinate of point to add.y
- y coordinate of point to add.
-
AddGeometryDirectly
Add a geometry directly to the container.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.
- Parameters:
other
- geometry to add to the container.- Returns:
- 0 if successful, or throws RuntimeException (or an error code if DontUseExceptions() has been called) if the geometry type is illegal for the type of geometry container.
-
AddGeometry
Add a geometry to the container.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.
- Parameters:
other
- geometry to add to the container.- Returns:
- 0 if successful, or throws RuntimeException (or an error code if DontUseExceptions() has been called) if the geometry type is illegal for the type of geometry container.
-
RemoveGeometry
public int RemoveGeometry(int iSubGeom) -
Clone
Make a copy of this object.This method relates to the SFCOM IGeometry::clone() method.
- Returns:
- a new object instance with the same geometry, and spatial reference system as the original.
-
GetGeometryType
public int GetGeometryType()Fetch geometry type.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.
- Returns:
- the geometry type code.
-
GetGeometryName
Fetch WKT name for geometry type.There is no SFCOM analog to this method.
- Returns:
- name used for this geometry type in well known text format.
-
Length
public double Length()Returns the length of the geometry- Returns:
- length of the geometry
- Since:
- Java bindings 1.8.0
-
Area
public double Area()Compute geometry area.Computes the area for an OGRLinearRing, OGRPolygon or OGRMultiPolygon. Undefined for all other geometry types (returns zero).
- Returns:
- the area or 0.0 for unsupported geometry types.
- Since:
- OGR 1.8.0
-
GetArea
public double GetArea()Deprecated.Compute geometry area (deprecated).- See Also:
-
GetPointCount
public int GetPointCount()Fetch number of points from a geometry.Only wkbPoint[25D] or wkbLineString[25D] may return a valid value. Other geometry types will silently return 0.
- Returns:
- the number of points.
-
GetPoints
public double[][] GetPoints(int nCoordinateDimension) Returns all points of a point or a line string.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.
- Parameters:
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.- Returns:
- the coordinates
- Since:
- OGR 1.9.0
-
GetPoints
public double[][] GetPoints()Returns all points of a point or a line string.Same as below with nCoordinateDimension == 0
- Returns:
- the coordinates
- Since:
- OGR 1.9.0
- See Also:
-
GetX
public double GetX(int ipoint) Fetch the x coordinate of a point from a geometry.- Parameters:
ipoint
- point to get the x coordinate. (must be 0 for a point geometry)- Returns:
- the X coordinate of this point.
-
GetX
public double GetX()Fetch the x coordinate of the first point from a geometry.- Returns:
- the X coordinate of this point.
- Since:
- Java bindings 1.7.0
-
GetY
public double GetY(int ipoint) Fetch the y coordinate of a point from a geometry.- Parameters:
ipoint
- point to get the y coordinate. (must be 0 for a point geometry)- Returns:
- the Y coordinate of this point.
-
GetY
public double GetY()Fetch the y coordinate of the first point from a geometry.- Returns:
- the Y coordinate of this point.
- Since:
- Java bindings 1.7.0
-
GetZ
public double GetZ(int ipoint) Fetch the z coordinate of a point from a geometry.- Parameters:
ipoint
- point to get the z coordinate. (must be 0 for a point geometry)- Returns:
- the Z coordinate of this point.
-
GetZ
public double GetZ()Fetch the z coordinate of the first point from a geometry.- Returns:
- the Z coordinate of this point.
- Since:
- Java bindings 1.7.0
-
GetM
public double GetM(int point) -
GetM
public double GetM() -
GetPoint
public void GetPoint(int iPoint, double[] argout) Fetch a point in line string or a point geometry.- Parameters:
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.
-
GetPointZM
public void GetPointZM(int iPoint, double[] argout) -
GetPoint_2D
public void GetPoint_2D(int iPoint, double[] argout) Fetch a point in line string or a point geometry.- Parameters:
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.
-
GetGeometryCount
public int GetGeometryCount()Fetch the number of elements in a geometry or number of geometries in container.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).
- Returns:
- the number of elements.
-
SetPoint
public void SetPoint(int ipoint, double x, double y, double z) Set the location of a vertex in a point or linestring geometry.If ipoint is larger than the number of existing points in the linestring, the point count will be increased to accommodate the request.
- Parameters:
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).
-
SetPoint
public void SetPoint(int ipoint, double x, double y) Set the location of a vertex in a point or linestring geometry.If ipoint is larger than the number of existing points in the linestring, the point count will be increased to accommodate the request.
- Parameters:
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.- Since:
- Java bindings 1.7.0
-
SetPointM
public void SetPointM(int point, double x, double y, double m) -
SetPointZM
public void SetPointZM(int point, double x, double y, double z, double m) -
SetPoint_2D
public void SetPoint_2D(int ipoint, double x, double y) Set the location of a vertex in a point or linestring geometry.If ipoint is larger than the number of existing points in the linestring, the point count will be increased to accommodate the request.
- Parameters:
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.
-
SwapXY
public void SwapXY() -
GetGeometryRef
Fetch geometry from a geometry container.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.
- Parameters:
iSubGeom
- the index of the geometry to fetch, between 0 and GetGeometryCount() - 1.- Returns:
- requested geometry.
-
Simplify
Simplify the geometry.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.
- Parameters:
dTolerance
- the distance tolerance for the simplification.- Returns:
- the simplified geometry or null if an error occurs.
- Since:
- OGR 1.8.0
-
SimplifyPreserveTopology
Simplify the geometry while preserving topology.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.
- Parameters:
dTolerance
- the distance tolerance for the simplification.- Returns:
- the simplified geometry or null if an error occurs.
- Since:
- OGR 1.9.0
-
DelaunayTriangulation
-
DelaunayTriangulation
-
DelaunayTriangulation
-
Polygonize
-
Boundary
Compute 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.
- Returns:
- a newly allocated geometry now owned by the caller, or null on failure.
- Since:
- OGR 1.8.0
-
GetBoundary
Deprecated.Compute boundary (deprecated).- See Also:
-
ConvexHull
Compute convex hull.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.
- Returns:
- a newly allocated geometry now owned by the caller, or null on failure.
-
ConcaveHull
-
MakeValid
-
MakeValid
-
Normalize
-
RemoveLowerDimensionSubGeoms
-
Buffer
Compute buffer of geometry.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.
- Parameters:
distance
- the buffer distance to be applied.quadsecs
- the number of segments used to approximate a 90 degree (quadrant) of curvature.- Returns:
- the newly created geometry, or null if an error occurs.
-
Buffer
Compute buffer of geometry.Same as below with quadsecs == 30.
- Since:
- Java bindings 1.7.0
- See Also:
-
Intersection
Compute intersection.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.
- Parameters:
other
- the other geometry intersected with "this" geometry.- Returns:
- a new geometry representing the intersection or null if there is no intersection or an error occurs.
- See Also:
-
Union
Compute union.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.
- Parameters:
other
- the other geometry unioned with "this" geometry.- Returns:
- a new geometry representing the union or null if an error occurs.
-
UnionCascaded
Compute union using cascading.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.
- Returns:
- a new geometry representing the union or null if an error occurs.
- Since:
- OGR 1.8.0
-
Difference
Compute difference.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.
- Parameters:
other
- the other geometry removed from "this" geometry.- Returns:
- a new geometry representing the difference or null if the difference is empty or an error occurs.
-
SymDifference
Compute symmetric difference.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.
- Parameters:
other
- the other geometry.- Returns:
- a new geometry representing the symmetric difference or null if the difference is empty or an error occurs.
- Since:
- OGR 1.8.0
-
SymmetricDifference
Deprecated.Compute symmetric difference (deprecated).- See Also:
-
Distance
Compute distance between two geometries.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.
- Parameters:
other
- the other geometry to compare against.- Returns:
- the distance between the geometries or -1 if an error occurs.
-
Distance3D
-
Empty
public void Empty()Clear geometry information.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.
-
IsEmpty
public boolean IsEmpty()Returns true (non-zero) if the object has no points.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.
- Returns:
- true if object is empty, otherwise false.
-
IsValid
public boolean IsValid()Test if the geometry is valid.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.
- Returns:
- true if the geometry has no points, otherwise false.
-
IsSimple
public boolean IsSimple()Test if the geometry is simple.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.
- Returns:
- true if the geometry has no points, otherwise false.
-
IsRing
public boolean IsRing()Test if the geometry is a ring.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.
- Returns:
- true if the geometry has no points, otherwise false.
-
Intersects
Do these features intersect?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.
- Parameters:
other
- the other geometry to test against.- Returns:
- true if the geometries intersect, otherwise false.
- Since:
- OGR 1.8.0
-
Intersect
Deprecated.Do these features intersect?- See Also:
-
Equals
-
Equal
Returns two if two geometries are equivalent.- Returns:
- true if equivalent or false otherwise.
-
Disjoint
Test for disjointness.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.
- Parameters:
other
- the geometry to compare to this geometry.- Returns:
- true if they are disjoint, otherwise false.
-
Touches
Test for touching.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.
- Parameters:
other
- the geometry to compare to this geometry.- Returns:
- true if they are touching, otherwise false.
-
Crosses
Test for crossing.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.
- Parameters:
other
- the geometry to compare to this geometry.- Returns:
- true if they are crossing, otherwise false.
-
Within
Test for containment.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.
- Parameters:
other
- the geometry to compare to this geometry.- Returns:
- true if poOtherGeom is within this geometry, otherwise false.
-
Contains
Test for containment.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.
- Parameters:
other
- the geometry to compare to this geometry.- Returns:
- true if poOtherGeom contains this geometry, otherwise false
-
Overlaps
Test for overlap.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.
- Parameters:
other
- the geometry to compare to this geometry.- Returns:
- true if they are overlapping, otherwise false.
-
TransformTo
Transform geometry to new spatial reference system.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.
- Parameters:
srs
- spatial reference system to transform to.- Returns:
- 0 on success. Otherwise throws a RuntimeException (or an error code if DontUseExceptions() has been called).
-
Transform
Apply arbitrary coordinate transformation to geometry.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.
- Parameters:
ct
- the transformation to apply.- Returns:
- 0 on success. Otherwise throws a RuntimeException (or an error code if DontUseExceptions() has been called).
-
GetSpatialReference
Returns spatial reference system for object.This method relates to the SFCOM IGeometry::get_SpatialReference() method.
- Returns:
- a reference to the spatial reference object. The object may be shared with many geometry objects, and should not be modified.
-
AssignSpatialReference
Assign spatial reference to this object.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.
- Parameters:
srs
- new spatial reference system to apply.
-
CloseRings
public void CloseRings()Force rings to be closed.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.
-
FlattenTo2D
public void FlattenTo2D()Convert geometry to strictly 2D.In a sense this converts all Z coordinates to 0.0.
-
Segmentize
public void Segmentize(double max_length) Modify the geometry such it has no segment longer then the given distance.Interpolated points will have Z and M values (if needed) set to 0. Distance computation is performed in 2d only
- Parameters:
max_length
- the maximum distance between 2 points after segmentization- Since:
- Java bindings 1.7.0
-
GetEnvelope
public void GetEnvelope(double[] argout) Computes and returns the bounding envelope for this geometry.- Parameters:
argout
- an allocated array of 4 doubles into which to place the result
-
GetEnvelope3D
public void GetEnvelope3D(double[] argout) Computes and returns the 3D bounding envelope for this geometry.- Parameters:
argout
- an allocated array of 6 doubles into which to place the result- Since:
- OGR 1.9.0
-
Centroid
Compute the geometry centroid. The centroid is not necessarily within the geometry.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.
- Returns:
- point with the centroid location, or null in case of failure
-
PointOnSurface
-
WkbSize
public long WkbSize() -
GetCoordinateDimension
public int GetCoordinateDimension()Get the dimension of the coordinates in this object.This method corresponds to the SFCOM IGeometry::GetDimension() method.
- Returns:
- in practice this always returns 2 indicating that coordinates are specified within a two dimensional space.
-
CoordinateDimension
public int CoordinateDimension() -
Is3D
public int Is3D() -
IsMeasured
public int IsMeasured() -
SetCoordinateDimension
public void SetCoordinateDimension(int dimension) Set the coordinate 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.
- Parameters:
dimension
- New coordinate dimension value, either 2 or 3.
-
Set3D
public void Set3D(int b3D) -
SetMeasured
public void SetMeasured(int bMeasured) -
GetDimension
public int GetDimension()Get the dimension of this object.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()).
- Returns:
- 0 for points, 1 for lines and 2 for surfaces.
-
HasCurveGeometry
public int HasCurveGeometry(int bLookForCircular) -
HasCurveGeometry
public int HasCurveGeometry() -
GetLinearGeometry
-
GetLinearGeometry
-
GetLinearGeometry
-
GetCurveGeometry
-
GetCurveGeometry
-
Value
-
Transform
-
CreatePreparedGeometry
-
ExportToWkt
Convert a geometry into well known text format.This method relates to the SFCOM IWks::ExportToWKT() method.
- Returns:
- the WKT string
- Since:
- Java bindings 1.7.0
-