Isis 3 Programmer 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... | |
Private Member Functions | |
GEOSGeometry * | makePoint (const double x, const double y) const |
Create a point geometry. More... | |
GEOSGeometry * | fromCube (Cube &cube) const |
Reads Polygon from ISIS Cube and returns geometry from contents. More... | |
GEOSPreparedGeometry const * | makePrepared (const GEOSGeometry *geom) const |
Creates a prepared geometry of current geometry. More... | |
void | destroy () |
Destroys the GEOS elements of this geometry object More... | |
Private Attributes | |
Type | m_type |
Geometry type of GIS source. More... | |
GEOSGeometry * | m_geom |
Pointer to GEOS-C opaque structure. More... | |
GEOSPreparedGeometry const * | m_preparedGeom |
A prepared geometry from the GEOS library. 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.
2012-07-15 Kris Becker - Original version.
2015-03-18 Jeannie Backer - Brought class files closer to ISIS coding standards.
2016-03-02 Ian Humphrey - Updated for coding standards compliance. Added to jwbacker's original unit test to prepare for adding this class to ISIS. Fixes #2398.
2016-03-04 Kris Becker - Completed the documentation and implmented the equals() method.
Definition at line 67 of file GisGeometry.h.
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. |
Definition at line 73 of file GisGeometry.h.
Isis::GisGeometry::GisGeometry | ( | ) |
Fundamental constructor of an empty object.
Definition at line 50 of file GisGeometry.cpp.
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 |
Definition at line 67 of file GisGeometry.cpp.
References Isis::GisTopology::instance(), m_geom, m_preparedGeom, makePoint(), and makePrepared().
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 |
Definition at line 85 of file GisGeometry.cpp.
References fromCube(), Isis::GisTopology::instance(), m_geom, m_preparedGeom, and makePrepared().
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 |
Definition at line 102 of file GisGeometry.cpp.
References _FILEINFO_, fromCube(), Isis::GisTopology::geomFromWKB(), Isis::GisTopology::geomFromWKT(), Isis::GisTopology::instance(), IsisCube, m_geom, m_preparedGeom, m_type, makePrepared(), 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 |
Definition at line 137 of file GisGeometry.cpp.
References Isis::GisTopology::clone(), Isis::GisTopology::instance(), isDefined(), m_geom, m_preparedGeom, and makePrepared().
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 |
Definition at line 157 of file GisGeometry.cpp.
References Isis::GisTopology::instance(), m_geom, m_preparedGeom, and makePrepared().
|
virtual |
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.
Definition at line 376 of file GisGeometry.cpp.
References isValid(), and m_geom.
Referenced by intersectRatio().
GisGeometry * Isis::GisGeometry::centroid | ( | ) | const |
Computes the centroid of the geometry and returns it as a new geometry.
Definition at line 763 of file GisGeometry.cpp.
References GisGeometry(), isValid(), and m_geom.
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 |
Definition at line 740 of file GisGeometry.cpp.
References Isis::GisTopology::destroy(), Isis::GisTopology::instance(), isValid(), m_geom, 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.
Definition at line 335 of file GisGeometry.cpp.
References Isis::GisTopology::clone(), GisGeometry(), Isis::GisTopology::instance(), isDefined(), m_geom, m_type, and makePrepared().
bool Isis::GisGeometry::contains | ( | const GisGeometry & | target | ) | const |
Test if the target geometry is contained within this geometry.
target | Other geometry to test |
Definition at line 495 of file GisGeometry.cpp.
References geometry(), isValid(), m_geom, and m_preparedGeom.
GisGeometry * Isis::GisGeometry::convexHull | ( | ) | const |
Computes the convex hull of the geometry.
Definition at line 653 of file GisGeometry.cpp.
References GisGeometry(), isValid(), and m_geom.
|
private |
Destroys the GEOS elements of this geometry object
Definition at line 822 of file GisGeometry.cpp.
References Isis::GisTopology::destroy(), Isis::GisTopology::instance(), m_geom, and m_preparedGeom.
Referenced by operator=(), setGeometry(), and ~GisGeometry().
bool Isis::GisGeometry::disjoint | ( | const GisGeometry & | target | ) | const |
Tests for disjoint geometries.
target | Other geometry to test |
Definition at line 521 of file GisGeometry.cpp.
References geometry(), isValid(), m_geom, and m_preparedGeom.
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 |
Definition at line 423 of file GisGeometry.cpp.
References geometry(), isValid(), m_geom, 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.
Definition at line 636 of file GisGeometry.cpp.
References GisGeometry(), isValid(), and m_geom.
bool Isis::GisGeometry::equals | ( | const GisGeometry & | target | ) | const |
Test if target and this geometry are equal.
target | Geometry to test for equality |
Definition at line 574 of file GisGeometry.cpp.
References geometry(), isValid(), and m_geom.
|
private |
Reads Polygon from ISIS Cube and returns geometry from contents.
cube | ISIS Cube contaning a Polygon geometry object |
Definition at line 812 of file GisGeometry.cpp.
References Isis::GisTopology::geomFromWKT(), Isis::GisTopology::instance(), and Isis::GisBlob::polygon().
Referenced by GisGeometry().
GisGeometry * Isis::GisGeometry::g_union | ( | const GisGeometry & | target | ) | const |
Computes the union of two geometries.
target | Other geometry to union with this geometry |
Definition at line 718 of file GisGeometry.cpp.
References geometry(), GisGeometry(), isValid(), and m_geom.
const GEOSGeometry * Isis::GisGeometry::geometry | ( | ) | const |
Returns the GEOSGeometry object to extend functionality.
Definition at line 308 of file GisGeometry.cpp.
References m_geom.
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 |
Definition at line 698 of file GisGeometry.cpp.
References geometry(), GisGeometry(), isValid(), and m_geom.
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 |
Definition at line 599 of file GisGeometry.cpp.
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 |
Definition at line 468 of file GisGeometry.cpp.
References geometry(), isValid(), m_geom, and m_preparedGeom.
Referenced by Isis::Strategy::applyToIntersectedGeometry().
bool Isis::GisGeometry::isDefined | ( | ) | const |
Determines if the current geometry is valid.
Definition at line 217 of file GisGeometry.cpp.
References m_geom.
Referenced by clone(), GisGeometry(), isValid(), isValidReason(), and operator=().
bool Isis::GisGeometry::isEmpty | ( | ) | const |
Tests for a defined but empty geometry.
Definition at line 355 of file GisGeometry.cpp.
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.
Definition at line 230 of file GisGeometry.cpp.
References isDefined(), and m_geom.
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.
Definition at line 244 of file GisGeometry.cpp.
References Isis::GisTopology::destroy(), Isis::GisTopology::instance(), isDefined(), and m_geom.
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.
Definition at line 399 of file GisGeometry.cpp.
|
private |
Create a point geometry.
y | Y or latitude coordinate |
Definition at line 796 of file GisGeometry.cpp.
Referenced by GisGeometry().
|
private |
Creates a prepared geometry of current geometry.
geom |
Definition at line 779 of file GisGeometry.cpp.
References Isis::GisTopology::instance(), and Isis::GisTopology::preparedGeometry().
Referenced by clone(), GisGeometry(), operator=(), and setGeometry().
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 |
Definition at line 181 of file GisGeometry.cpp.
References Isis::GisTopology::clone(), destroy(), Isis::GisTopology::instance(), isDefined(), m_geom, m_preparedGeom, m_type, and makePrepared().
bool Isis::GisGeometry::overlaps | ( | const GisGeometry & | target | ) | const |
Test for overlapping geometries.
target | Geometry to test for overlap with this geometry |
Definition at line 548 of file GisGeometry.cpp.
References geometry(), isValid(), m_geom, and m_preparedGeom.
int Isis::GisGeometry::points | ( | ) | const |
Get number of points in geometry.
Definition at line 446 of file GisGeometry.cpp.
References isValid(), and m_geom.
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.
Definition at line 322 of file GisGeometry.cpp.
References m_preparedGeom.
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 |
Definition at line 204 of file GisGeometry.cpp.
References destroy(), m_geom, m_preparedGeom, and makePrepared().
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. |
Definition at line 676 of file GisGeometry.cpp.
References GisGeometry(), isValid(), and m_geom.
Referenced by Isis::Strategy::importGeometry().
GisGeometry::Type Isis::GisGeometry::type | ( | ) | const |
Returns the type (origin) of the geometry.
Definition at line 261 of file GisGeometry.cpp.
References m_type.
Referenced by Isis::Strategy::importGeometry(), and typeToString().
|
static |
Returns enum representation of the geometry origin from string type.
gstrType | Character representation of geometry origin |
Definition at line 273 of file GisGeometry.cpp.
|
static |
Returns the type of the Geometry as a QString.
gstrType | Enum type of origin |
Definition at line 294 of file GisGeometry.cpp.
References GeosGis, IsisCube, type(), WKB, and WKT.
Referenced by GisGeometry().
|
private |
Pointer to GEOS-C opaque structure.
Definition at line 136 of file GisGeometry.h.
Referenced by area(), centroid(), clone(), contains(), convexHull(), destroy(), disjoint(), distance(), envelope(), equals(), g_union(), geometry(), GisGeometry(), intersection(), intersects(), isDefined(), isEmpty(), isValid(), isValidReason(), length(), operator=(), overlaps(), points(), setGeometry(), and simplify().
|
private |
A prepared geometry from the GEOS library.
Definition at line 137 of file GisGeometry.h.
Referenced by contains(), destroy(), disjoint(), GisGeometry(), intersects(), operator=(), overlaps(), preparedGeometry(), and setGeometry().
|
private |
Geometry type of GIS source.
Definition at line 135 of file GisGeometry.h.
Referenced by clone(), GisGeometry(), operator=(), and type().