Isis 3 Developer Reference
|
Encapsulation class provides support for GEOS-C API. More...
#include <GisGeometry.h>
Public Types | |
enum | Type { None, WKT, WKB, IsisCube, GeosGis } |
Source type of the geometry. More... | |
Public Member Functions | |
GisGeometry () | |
Fundamental constructor of an empty object. More... | |
GisGeometry (const double xlongitude, const double ylatitude) | |
Construct a point geometry. More... | |
GisGeometry (Cube &cube) | |
Create a geometry from a cube file. More... | |
GisGeometry (const QString &gisSource, const Type t) | |
Create a geometry from a character WKT/WKB source. More... | |
GisGeometry (const GisGeometry &geom) | |
Create a geometry from another geometry by cloning. More... | |
GisGeometry (GEOSGeometry *geom) | |
Create a GISGeometry directly from a GEOS-C GEOSGeometry. More... | |
GisGeometry & | operator= (GisGeometry const &geom) |
Assignment operator for GISGeomtries. More... | |
virtual | ~GisGeometry () |
Destructor. More... | |
void | setGeometry (GEOSGeometry *geom) |
Set the geometry directly taking ownership. More... | |
bool | isDefined () const |
Determines if the current geometry is valid. More... | |
bool | isValid () const |
Determines validity of the geometry contained in this object. More... | |
QString | isValidReason () const |
Returns a string describing reason for invalid geometry. More... | |
bool | isEmpty () const |
Tests for a defined but empty geometry. More... | |
Type | type () const |
Returns the type (origin) of the geometry. More... | |
const GEOSGeometry * | geometry () const |
Returns the GEOSGeometry object to extend functionality. More... | |
const GEOSPreparedGeometry * | preparedGeometry () const |
Returns special GEOS prepared geometry if it exists. More... | |
GisGeometry * | clone () const |
Clones the contents of this geometry to a new instance. More... | |
double | area () const |
Computes the area of a geometry. More... | |
double | length () const |
Computes the length of a geometry. More... | |
double | distance (const GisGeometry &target) const |
Computes the distance between two geometries. More... | |
int | points () const |
Get number of points in geometry. More... | |
bool | intersects (const GisGeometry &target) const |
Computes a new geometry from the intersection of the two geomtries. More... | |
bool | contains (const GisGeometry &target) const |
Test if the target geometry is contained within this geometry. More... | |
bool | disjoint (const GisGeometry &target) const |
Tests for disjoint geometries. More... | |
bool | overlaps (const GisGeometry &target) const |
Test for overlapping geometries. More... | |
bool | equals (const GisGeometry &target) const |
Test if target and this geometry are equal. More... | |
double | intersectRatio (const GisGeometry &geom) const |
Computes intersect ratio between two geometries. More... | |
GisGeometry * | envelope () const |
Computes the envelope or bounding box of this geometry. More... | |
GisGeometry * | convexHull () const |
Computes the convex hull of the geometry. More... | |
GisGeometry * | simplify (const double &tolerance) const |
Simplify complex or overdetermined geoemtry. More... | |
GisGeometry * | intersection (const GisGeometry &geom) const |
Computes the intersection of two geometries. More... | |
GisGeometry * | g_union (const GisGeometry &geom) const |
Computes the union of two geometries. More... | |
GisGeometry * | centroid () const |
Computes the centroid of the geometry and returns it as a new geometry. More... | |
bool | centroid (double &xlongitude, double &ylatitude) const |
Computes the centroid of a spatial geometry. More... | |
Static Public Member Functions | |
static Type | type (const QString >ype) |
Returns enum representation of the geometry origin from string type. More... | |
static QString | typeToString (const Type &type) |
Returns the type of the Geometry as a QString. More... | |
Encapsulation class provides support for GEOS-C API.
The Geometry Engine, Open Source (GEOS) software package, developed in C++ from a port of the Java Toplogy Suite (JTS) provides a simplied, generic C API using an opaque C pointer. This layer is to provide stable API from which to develop and maintain applications that are relatively immune from changes to the underlying C++ implementation.
This class provides much of the basic elements to support simplified development of C++ applications with similiar goals - to provide immmunity from developmental changes to code using the GEOS-C API in a C++ development environment.
The GEOS home page is http://trac.osgeo.org/geos/. The documentation for the GEOS-C package can be found at http://geos.osgeo.org/doxygen/c_iface.html.
Source type of the geometry.
Enumerator | |
---|---|
None | No geometry. A geometry object cannot be created with this geometry type. |
WKT | The GEOS library WKT reader is used to create the geometry. |
WKB | The GEOS library WKB reader is used to create the geometry. |
IsisCube | An ISIS Cube is used to create the geometry. |
GeosGis | GEOS GIS. A geometry object cannot be created with this geometry type. |
Isis::GisGeometry::GisGeometry | ( | ) |
Fundamental constructor of an empty object.
References Isis::GisTopology::instance().
Referenced by centroid(), clone(), convexHull(), envelope(), g_union(), intersection(), and simplify().
Isis::GisGeometry::GisGeometry | ( | const double | xlongitude, |
const double | ylatitude | ||
) |
Construct a point geometry.
This constructor will create a point geometry. Note this can either be used to create a geometric geometry with a longitude/latitude or a grid geometry in any system with an X/Y value. It is up to the caller to maintain the coordinate system.
xlongitude | X or longitude coordinate |
ylatitude | Y or latitude coordinate |
References Isis::GisTopology::instance().
Isis::GisGeometry::GisGeometry | ( | Cube & | cube | ) |
Create a geometry from a cube file.
This constructor will read the contents of the Polygon blob of an ISIS cube file and create a geometry from its contents.
cube | Cube object to create the geomtery from |
References Isis::GisTopology::instance().
Isis::GisGeometry::GisGeometry | ( | const QString & | gisSource, |
const Type | t | ||
) |
Create a geometry from a character WKT/WKB source.
gisSource | String containing the text representation of a GIS geometry. This can be either a WKT or WKB formatted string |
t | Type of GisGeometry - WKT or WKB |
References _FILEINFO_, Isis::GisTopology::geomFromWKB(), Isis::GisTopology::geomFromWKT(), Isis::GisTopology::instance(), IsisCube, Isis::Cube::open(), Isis::IException::Programmer, typeToString(), WKB, and WKT.
Isis::GisGeometry::GisGeometry | ( | const GisGeometry & | geom | ) |
Create a geometry from another geometry by cloning.
This contructor uses the GISTopology clone method to generate a new geometry.
geom | GISGeometry to create new geometry from |
References Isis::GisTopology::clone(), Isis::GisTopology::instance(), and isDefined().
Isis::GisGeometry::GisGeometry | ( | GEOSGeometry * | geom | ) |
Create a GISGeometry directly from a GEOS-C GEOSGeometry.
This constructor will create a new GISGeometry object that takes ownership from the caller and is managed for the life of this new object.
geom | GEOSGeometry instance to use |
References Isis::GisTopology::instance().
|
virtual |
Destructor.
double Isis::GisGeometry::area | ( | ) | const |
Computes the area of a geometry.
This method will compute the area of a geometry. Note the area is in the units of the coordinates. For example, if the coordinates of the geometry are in latitude/longitude, then the units are in degrees. Callers must maintain the units of the coordinates.
Point geometries will have 0 area.
References isValid().
Referenced by intersectRatio().
GisGeometry * Isis::GisGeometry::centroid | ( | ) | const |
Computes the centroid of the geometry and returns it as a new geometry.
References GisGeometry(), and isValid().
bool Isis::GisGeometry::centroid | ( | double & | xlongitude, |
double & | ylatitude | ||
) | const |
Computes the centroid of a spatial geometry.
This method will compute the coordinate centroid of a spatial geometry.
xlongitude | X/longitude coordinate of centroid |
ylatitude | Y/latitude coordinate of centroid |
References Isis::GisTopology::destroy(), Isis::GisTopology::instance(), isValid(), and Isis::Null.
GisGeometry * Isis::GisGeometry::clone | ( | ) | const |
Clones the contents of this geometry to a new instance.
This method will clone the contents of this geometry and return a new instance to the caller.
References Isis::GisTopology::clone(), GisGeometry(), Isis::GisTopology::instance(), and isDefined().
bool Isis::GisGeometry::contains | ( | const GisGeometry & | target | ) | const |
Test if the target geometry is contained within this geometry.
target | Other geometry to test |
References geometry(), and isValid().
GisGeometry * Isis::GisGeometry::convexHull | ( | ) | const |
Computes the convex hull of the geometry.
References GisGeometry(), and isValid().
bool Isis::GisGeometry::disjoint | ( | const GisGeometry & | target | ) | const |
Tests for disjoint geometries.
target | Other geometry to test |
References geometry(), and isValid().
double Isis::GisGeometry::distance | ( | const GisGeometry & | target | ) | const |
Computes the distance between two geometries.
This method computes the distance between two geometries. Refer to the GEOS documentation as to the details of this computation.
target | Target geometry to compute distance to |
References geometry(), isValid(), and Isis::Null.
GisGeometry * Isis::GisGeometry::envelope | ( | ) | const |
Computes the envelope or bounding box of this geometry.
This method computes the envelope or bounding box of the geometry in this object. A new geometry is computed and a pointer is returned to the caller. The caller assumes ownership of this geometry.
A null geometry will be returned if an error is occured or the current geometry is invalid.
References GisGeometry(), and isValid().
bool Isis::GisGeometry::equals | ( | const GisGeometry & | target | ) | const |
Test if target and this geometry are equal.
target | Geometry to test for equality |
References geometry(), and isValid().
GisGeometry * Isis::GisGeometry::g_union | ( | const GisGeometry & | target | ) | const |
Computes the union of two geometries.
target | Other geometry to union with this geometry |
References geometry(), GisGeometry(), and isValid().
const GEOSGeometry * Isis::GisGeometry::geometry | ( | ) | const |
Returns the GEOSGeometry object to extend functionality.
Referenced by Isis::Strategy::applyToIntersectedGeometry(), contains(), disjoint(), distance(), equals(), g_union(), intersection(), intersects(), and overlaps().
GisGeometry * Isis::GisGeometry::intersection | ( | const GisGeometry & | target | ) | const |
Computes the intersection of two geometries.
The area of common interesction of the target geometry and this geometry are computed and returned to the caller.
target | Other geometry to compute intersection |
References geometry(), GisGeometry(), and isValid().
Referenced by intersectRatio().
double Isis::GisGeometry::intersectRatio | ( | const GisGeometry & | target | ) | const |
Computes intersect ratio between two geometries.
This method computes the intersection of two geometries and the returns the ratio of the area of intersection with this geometry. Units must be the same for both geometries or result will not be valid.
target | Geometry to compute intersect ratio for |
References area(), intersection(), and isValid().
bool Isis::GisGeometry::intersects | ( | const GisGeometry & | target | ) | const |
Computes a new geometry from the intersection of the two geomtries.
This method will compute the union of two geometries and return a new geometry that represents the combination of them.
target | Other geometry to combine by union opertor |
References geometry(), and isValid().
Referenced by Isis::Strategy::applyToIntersectedGeometry().
bool Isis::GisGeometry::isDefined | ( | ) | const |
Determines if the current geometry is valid.
Referenced by clone(), GisGeometry(), isValid(), isValidReason(), and operator=().
bool Isis::GisGeometry::isEmpty | ( | ) | const |
Tests for a defined but empty geometry.
References isValid().
bool Isis::GisGeometry::isValid | ( | ) | const |
Determines validity of the geometry contained in this object.
First determines if it contains a geometry and then validates with the GEOS toolkit.
References isDefined().
Referenced by Isis::Strategy::applyToIntersectedGeometry(), area(), centroid(), contains(), convexHull(), disjoint(), distance(), envelope(), equals(), g_union(), intersection(), intersectRatio(), intersects(), isEmpty(), length(), overlaps(), points(), and simplify().
QString Isis::GisGeometry::isValidReason | ( | ) | const |
Returns a string describing reason for invalid geometry.
References Isis::GisTopology::destroy(), Isis::GisTopology::instance(), and isDefined().
double Isis::GisGeometry::length | ( | ) | const |
Computes the length of a geometry.
This method will compute the length of a geometry. This is suitable for Linestring and spatial geometries.
References isValid().
GisGeometry & Isis::GisGeometry::operator= | ( | GisGeometry const & | geom | ) |
Assignment operator for GISGeomtries.
This assignment operator essentially clones the right side geomemtry
geom | Geometry to assign to current object |
References Isis::GisTopology::clone(), Isis::GisTopology::instance(), and isDefined().
bool Isis::GisGeometry::overlaps | ( | const GisGeometry & | target | ) | const |
Test for overlapping geometries.
target | Geometry to test for overlap with this geometry |
References geometry(), and isValid().
int Isis::GisGeometry::points | ( | ) | const |
Get number of points in geometry.
References isValid().
Referenced by Isis::Strategy::importGeometry().
const GEOSPreparedGeometry * Isis::GisGeometry::preparedGeometry | ( | ) | const |
Returns special GEOS prepared geometry if it exists.
This method will return a pointer to the prepared version of the GEOSGeometry data. Caller should test for a NULL pointer as it may be disabled or non-existant.
void Isis::GisGeometry::setGeometry | ( | GEOSGeometry * | geom | ) |
Set the geometry directly taking ownership.
This method will replace the current geoemetry with the geom parameter contents. The existing contents of this object is destroyed before taking ownership of the geom paramter object.
geom | GEOSGeometry to incoporate into this object |
GisGeometry * Isis::GisGeometry::simplify | ( | const double & | tolerance | ) | const |
Simplify complex or overdetermined geoemtry.
This method will simplify a geometry with a Douglas -Peucker algorithm using a tolerance specifying the maximum distance from the original (multi)polygon. The use of this algorithm is designed to prevent oversimplification
tolerance | Maximum distance from the original geometry expressed in the coordinate system of the geometry. |
References GisGeometry(), and isValid().
Referenced by Isis::Strategy::importGeometry().
GisGeometry::Type Isis::GisGeometry::type | ( | ) | const |
Returns the type (origin) of the geometry.
Referenced by Isis::Strategy::importGeometry(), and typeToString().
|
static |
|
static |
Returns the type of the Geometry as a QString.
gstrType | Enum type of origin |
References GeosGis, IsisCube, type(), WKB, and WKT.
Referenced by GisGeometry().