|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.gdal.ogr.Geometry
public class Geometry
Abstract base class for all geometry classes.
The Geometry class is a binding for the C++ OGRGeometry class.
Note that the family of spatial analysis methods (Equal(), Disjoint(), ..., ConvexHull(), Buffer(), ...) are not implemented at ths time. Some other required and optional geometry methods have also been omitted at this time.
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 | |
---|---|
Geometry(int eGeometryType)
Create an empty geometry of desired type. |
|
Geometry(int eGeometryType,
String wkt,
byte[] wkb,
String gml)
Deprecated. Use referenced methods instead. |
Method Summary | |
---|---|
int |
AddGeometry(Geometry other)
Add a geometry to the container. |
int |
AddGeometryDirectly(Geometry other)
Add a geometry directly to the container. |
void |
AddPoint_2D(double x,
double y)
Add a point to a geometry (line string or point). |
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 |
AssignSpatialReference(SpatialReference srs)
Assign spatial reference to this object. |
Geometry |
Buffer(double distance)
Compute buffer of geometry. |
Geometry |
Buffer(double distance,
int quadsecs)
Compute buffer of geometry. |
Geometry |
Centroid()
Compute and return centroid of surface. |
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. |
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 |
Crosses(Geometry other)
Test for crossing. |
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. |
void |
Empty()
Clear geometry information. |
boolean |
Equal(Geometry other)
Returns two if two geometries are equivalent. |
boolean |
equals(Object obj)
|
String |
ExportToGML()
Convert a geometry into GML format. |
String |
ExportToJson()
Convert a geometry into GeoJSON format. |
String |
ExportToKML()
Convert a geometry into KML format. |
String |
ExportToKML(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. |
String |
ExportToWkt()
Convert a geometry into well known text format. |
int |
ExportToWkt(String[] argout)
Convert a geometry into well known text format. |
void |
FlattenTo2D()
Convert geometry to strictly 2D. |
double |
GetArea()
Compute geometry area. |
Geometry |
GetBoundary()
Compute boundary. |
int |
GetCoordinateDimension()
Get the dimension of the coordinates in this object. |
int |
GetDimension()
Get the dimension of this object. |
void |
GetEnvelope(double[] argout)
Computes and returns the bounding envelope for this geometry. |
int |
GetGeometryCount()
Fetch the number of elements in a geometry or number of geometries in container. |
String |
GetGeometryName()
Fetch WKT name for geometry type. |
Geometry |
GetGeometryRef(int iSubGeom)
Fetch geometry from a geometry container. |
int |
GetGeometryType()
Fetch geometry type. |
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. |
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. |
int |
GetPointCount()
Fetch number of points from a geometry. |
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 |
hashCode()
|
boolean |
Intersect(Geometry other)
Do these features intersect? |
Geometry |
Intersection(Geometry other)
Compute intersection. |
boolean |
IsEmpty()
Returns true (non-zero) if the object has no points. |
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 |
boolean |
Overlaps(Geometry other)
Test for overlap. |
void |
Segmentize(double max_length)
Modify the geometry such it has no segment longer then the given distance. |
void |
SetCoordinateDimension(int dimension)
Set the coordinate dimension. |
void |
SetPoint_2D(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)
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. |
Geometry |
SymmetricDifference(Geometry other)
Compute symmetric difference. |
boolean |
Touches(Geometry other)
Test for touching. |
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. |
boolean |
Within(Geometry other)
Test for containment. |
int |
WkbSize()
Returns size of related binary representation. |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Geometry(int eGeometryType, String wkt, byte[] wkb, String gml)
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)
eGeometryType
- the type code of the geometry class to be instantiated.Method Detail |
---|
public void delete()
public boolean equals(Object obj)
equals
in class Object
public int hashCode()
hashCode
in class Object
public Object clone()
clone
in class 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(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(String gml)
gml
- The GML fragment for the geometry.
public static Geometry CreateFromJson(String json)
json
- GeoJSON content
public int ExportToWkb(byte[] wkbArray, int byte_order)
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(String[] argout)
argout
- an allocated array of 1 string where the WKT output will be inserted
public byte[] ExportToWkb(int byte_order)
byte_order
- One of wkbXDR or wkbNDR indicating MSB or LSB byte order
respectively.
public byte[] ExportToWkb()
public String ExportToGML()
public String ExportToKML(String altitude_mode)
altitude_mode
- string which will be inserted in-between the <altitude_mode> tag.
public String ExportToKML()
public String ExportToJson()
public void AddPoint(double x, double y, double z)
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)
x
- coordinate of point to add.y
- coordinate of point to add.public void AddPoint_2D(double x, double y)
x
- x coordinate of point to add.y
- y coordinate of point to add.public int AddGeometryDirectly(Geometry other)
There is no SFCOM analog to this method.
other
- geometry to add to the container.
public int AddGeometry(Geometry other)
There is no SFCOM analog to this method.
other
- geometry to add to the container.
public Geometry Clone()
public int GetGeometryType()
public String GetGeometryName()
public double GetArea()
public int GetPointCount()
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 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 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()
public void SetPoint(int ipoint, double x, double y, double z)
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)
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 SetPoint_2D(int ipoint, double x, double y)
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 Geometry GetGeometryRef(int iSubGeom)
This function relates to the SFCOM IGeometryCollection::get_Geometry() method.
iSubGeom
- the index of the geometry to fetch, between 0 and
GetGeometryCount() - 1.
public Geometry GetBoundary()
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 ConvexHull()
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 Buffer(double distance, int quadsecs)
Some buffer sections are properly described as curves, but are converted to approximate polygons. The nQuadSegs parameter can be used to control how many segements 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)
Buffer(double distance, int quadsecs)
public Geometry Intersection(Geometry other)
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.
public Geometry Union(Geometry other)
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 Difference(Geometry other)
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 SymmetricDifference(Geometry other)
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 double Distance(Geometry other)
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 void Empty()
This method relates to the SFCOM IGeometry::Empty() method.
public boolean IsEmpty()
public double Length()
public boolean IsValid()
public boolean IsSimple()
public boolean IsRing()
public boolean Intersect(Geometry other)
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 Equal(Geometry other)
public boolean Disjoint(Geometry other)
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)
other
- the geometry to compare to this geometry.
public boolean Crosses(Geometry other)
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)
other
- the geometry to compare to this geometry.
public boolean Contains(Geometry other)
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)
other
- the geometry to compare to this geometry.
public int TransformTo(SpatialReference srs)
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)
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()
public void AssignSpatialReference(SpatialReference srs)
srs
- new spatial reference system to apply.public void CloseRings()
public void FlattenTo2D()
public void Segmentize(double max_length)
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 int WkbSize()
public int GetCoordinateDimension()
public void SetCoordinateDimension(int dimension)
dimension
- New coordinate dimension value, either 2 or 3.public int GetDimension()
public String ExportToWkt()
public Geometry Centroid()
This method relates to the SFCOM ISurface::get_Centroid() method.
NOTE: Only implemented when GEOS included in build.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |