Isis Developer Reference
Isis::GisGeometry Class Reference

Encapsulation class provides support for GEOS-C API. More...

#include <GisGeometry.h>

Collaboration diagram for Isis::GisGeometry:
Collaboration graph

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.
 
 GisGeometry (const double xlongitude, const double ylatitude)
 Construct a point geometry.
 
 GisGeometry (Cube &cube)
 Create a geometry from a cube file.
 
 GisGeometry (const QString &gisSource, const Type t)
 Create a geometry from a character WKT/WKB source.
 
 GisGeometry (const GisGeometry &geom)
 Create a geometry from another geometry by cloning.
 
 GisGeometry (GEOSGeometry *geom)
 Create a GISGeometry directly from a GEOS-C GEOSGeometry.
 
GisGeometryoperator= (GisGeometry const &geom)
 Assignment operator for GISGeomtries.
 
virtual ~GisGeometry ()
 Destructor.
 
void setGeometry (GEOSGeometry *geom)
 Set the geometry directly taking ownership.
 
bool isDefined () const
 Determines if the current geometry is valid.
 
bool isValid () const
 Determines validity of the geometry contained in this object.
 
QString isValidReason () const
 Returns a string describing reason for invalid geometry.
 
bool isEmpty () const
 Tests for a defined but empty geometry.
 
Type type () const
 Returns the type (origin) of the geometry.
 
const GEOSGeometry * geometry () const
 Returns the GEOSGeometry object to extend functionality.
 
const GEOSPreparedGeometry * preparedGeometry () const
 Returns special GEOS prepared geometry if it exists.
 
GisGeometryclone () const
 Clones the contents of this geometry to a new instance.
 
double area () const
 Computes the area of a geometry.
 
double length () const
 Computes the length of a geometry.
 
double distance (const GisGeometry &target) const
 Computes the distance between two geometries.
 
int points () const
 Get number of points in geometry.
 
bool intersects (const GisGeometry &target) const
 Computes a new geometry from the intersection of the two geomtries.
 
bool contains (const GisGeometry &target) const
 Test if the target geometry is contained within this geometry.
 
bool disjoint (const GisGeometry &target) const
 Tests for disjoint geometries.
 
bool overlaps (const GisGeometry &target) const
 Test for overlapping geometries.
 
bool equals (const GisGeometry &target) const
 Test if target and this geometry are equal.
 
double intersectRatio (const GisGeometry &geom) const
 Computes intersect ratio between two geometries.
 
GisGeometryenvelope () const
 Computes the envelope or bounding box of this geometry.
 
GisGeometryconvexHull () const
 Computes the convex hull of the geometry.
 
GisGeometrysimplify (const double &tolerance) const
 Simplify complex or overdetermined geoemtry.
 
GisGeometryintersection (const GisGeometry &geom) const
 Computes the intersection of two geometries.
 
GisGeometryg_union (const GisGeometry &geom) const
 Computes the union of two geometries.
 
GisGeometrycentroid () const
 Computes the centroid of the geometry and returns it as a new geometry.
 
bool centroid (double &xlongitude, double &ylatitude) const
 Computes the centroid of a spatial geometry.
 

Static Public Member Functions

static Type type (const QString &gtype)
 Returns enum representation of the geometry origin from string type.
 
static QString typeToString (const Type &type)
 Returns the type of the Geometry as a QString.
 

Detailed Description

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.

Author
2012-07-15 Kris Becker

Member Enumeration Documentation

◆ Type

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.

Constructor & Destructor Documentation

◆ GisGeometry() [1/6]

Isis::GisGeometry::GisGeometry ( )

Fundamental constructor of an empty object.

References Isis::GisTopology::instance().

Referenced by centroid(), clone(), convexHull(), envelope(), g_union(), intersection(), and simplify().

◆ GisGeometry() [2/6]

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.

Parameters
xlongitudeX or longitude coordinate
ylatitudeY or latitude coordinate

References Isis::GisTopology::instance().

◆ GisGeometry() [3/6]

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.

Parameters
cubeCube object to create the geomtery from

References Isis::GisTopology::instance().

◆ GisGeometry() [4/6]

Isis::GisGeometry::GisGeometry ( const QString & gisSource,
const Type t )

Create a geometry from a character WKT/WKB source.

Parameters
gisSourceString containing the text representation of a GIS geometry. This can be either a WKT or WKB formatted string
tType of GisGeometry - WKT or WKB

References _FILEINFO_, Isis::GisTopology::instance(), IsisCube, Isis::Cube::open(), Isis::IException::Programmer, typeToString(), WKB, and WKT.

◆ GisGeometry() [5/6]

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.

Parameters
geomGISGeometry to create new geometry from

References Isis::GisTopology::instance(), and isDefined().

◆ GisGeometry() [6/6]

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.

Parameters
geomGEOSGeometry instance to use

References Isis::GisTopology::instance().

◆ ~GisGeometry()

Isis::GisGeometry::~GisGeometry ( )
virtual

Destructor.

Member Function Documentation

◆ area()

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.

Returns
double Area of the geometry in units of data coordinates of the geometry

References isValid().

Referenced by intersectRatio().

◆ centroid() [1/2]

GisGeometry * Isis::GisGeometry::centroid ( ) const

Computes the centroid of the geometry and returns it as a new geometry.

Returns
GisGeometry Pointer to point geometry of centroid of this geometry

References GisGeometry(), and isValid().

◆ centroid() [2/2]

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.

Parameters
xlongitudeX/longitude coordinate of centroid
ylatitudeY/latitude coordinate of centroid
Returns
bool True if successful, false if failed

References Isis::GisTopology::instance(), isValid(), and Isis::Null.

◆ clone()

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.

Returns
GisGeometry Geometry to clone

References GisGeometry(), Isis::GisTopology::instance(), and isDefined().

◆ contains()

bool Isis::GisGeometry::contains ( const GisGeometry & target) const

Test if the target geometry is contained within this geometry.

Parameters
targetOther geometry to test
Returns
bool True if target is contained with this geometry, false otherwise

References geometry(), and isValid().

◆ convexHull()

GisGeometry * Isis::GisGeometry::convexHull ( ) const

Computes the convex hull of the geometry.

Returns
GisGeometry Pointer to new geometry that represents the convex hull of this geometry. A null geometry, not NULL pointer is returned if problems occur.

References GisGeometry(), and isValid().

◆ disjoint()

bool Isis::GisGeometry::disjoint ( const GisGeometry & target) const

Tests for disjoint geometries.

Parameters
targetOther geometry to test
Returns
bool True if geometries are disjoint, false otherwise

References geometry(), and isValid().

◆ distance()

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.

Parameters
targetTarget geometry to compute distance to
Returns
double Distance in units of geometry coordinates

References geometry(), isValid(), and Isis::Null.

◆ envelope()

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.

Returns
GisGeometry Pointer to envelope/bounding box. A null geometry, not NULL pointer, is returned in problems occur.

References GisGeometry(), and isValid().

◆ equals()

bool Isis::GisGeometry::equals ( const GisGeometry & target) const

Test if target and this geometry are equal.

Parameters
targetGeometry to test for equality
Returns
bool True if geometries are equal, false if not

References geometry(), and isValid().

◆ g_union()

GisGeometry * Isis::GisGeometry::g_union ( const GisGeometry & target) const

Computes the union of two geometries.

Parameters
targetOther geometry to union with this geometry
Returns
GisGeometry Result of unioning the two geometries

References geometry(), GisGeometry(), and isValid().

◆ geometry()

const GEOSGeometry * Isis::GisGeometry::geometry ( ) const

Returns the GEOSGeometry object to extend functionality.

Returns
GEOSGeometry Pointer to GEOSGeometry structure

Referenced by Isis::Strategy::applyToIntersectedGeometry(), contains(), disjoint(), distance(), equals(), g_union(), intersection(), intersects(), and overlaps().

◆ intersection()

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.

Parameters
targetOther geometry to compute intersection
Returns
GisGeometry Intersection geometry

References geometry(), GisGeometry(), and isValid().

Referenced by intersectRatio().

◆ 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.

Parameters
targetGeometry to compute intersect ratio for
Returns
double Area of common intersection of two geometries in units of the two geometries.

References area(), intersection(), and isValid().

◆ intersects()

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.

Parameters
targetOther geometry to combine by union opertor
Returns
bool True if operation is successful, false otherwise

References geometry(), and isValid().

Referenced by Isis::Strategy::applyToIntersectedGeometry().

◆ isDefined()

bool Isis::GisGeometry::isDefined ( ) const

Determines if the current geometry is valid.

Returns
bool True if contents are valid, otherwise false

Referenced by clone(), GisGeometry(), isValid(), isValidReason(), and operator=().

◆ isEmpty()

bool Isis::GisGeometry::isEmpty ( ) const

Tests for a defined but empty geometry.

Returns
bool True if empty, false if has content

References isValid().

◆ 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.

Returns
bool True if valid, false if invalid or non-existant

References isDefined().

Referenced by Isis::Strategy::applyToIntersectedGeometry(), area(), centroid(), centroid(), contains(), convexHull(), disjoint(), distance(), envelope(), equals(), g_union(), intersection(), intersectRatio(), intersects(), isEmpty(), length(), overlaps(), points(), and simplify().

◆ isValidReason()

QString Isis::GisGeometry::isValidReason ( ) const

Returns a string describing reason for invalid geometry.

Returns
QString Description of the reason the geometry is invalid

References Isis::GisTopology::instance(), and isDefined().

◆ length()

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.

Returns
double Length of the geometry in units of the coordinates

References isValid().

◆ operator=()

GisGeometry & Isis::GisGeometry::operator= ( GisGeometry const & geom)

Assignment operator for GISGeomtries.

This assignment operator essentially clones the right side geomemtry

Parameters
geomGeometry to assign to current object
Returns
GisGeometry New geometry

References Isis::GisTopology::instance(), and isDefined().

◆ overlaps()

bool Isis::GisGeometry::overlaps ( const GisGeometry & target) const

Test for overlapping geometries.

Parameters
targetGeometry to test for overlap with this geometry
Returns
bool True if target geometry overlaps with this geometry, false otherwise

References geometry(), and isValid().

◆ points()

int Isis::GisGeometry::points ( ) const

Get number of points in geometry.

Returns
int Number of points contained in the geometry

References isValid().

Referenced by Isis::Strategy::importGeometry().

◆ preparedGeometry()

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.

Returns
GEOSPreparedGeometry Pointer to prepared geometry

◆ setGeometry()

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.

Parameters
geomGEOSGeometry to incoporate into this object

◆ simplify()

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

Parameters
toleranceMaximum distance from the original geometry expressed in the coordinate system of the geometry.
Returns
GisGeometry* Simplified geometry

References GisGeometry(), and isValid().

Referenced by Isis::Strategy::importGeometry().

◆ type() [1/2]

GisGeometry::Type Isis::GisGeometry::type ( ) const

Returns the type (origin) of the geometry.

Returns
GisGeometry::Type Enum type of geometry origin

Referenced by Isis::Strategy::importGeometry(), and typeToString().

◆ type() [2/2]

GisGeometry::Type Isis::GisGeometry::type ( const QString & gstrType)
static

Returns enum representation of the geometry origin from string type.

See also
type(QString)
Parameters
gstrTypeCharacter representation of geometry origin
Returns
GisGeometry::Type Enum type of origin

References GeosGis, IsisCube, None, WKB, and WKT.

◆ typeToString()

QString Isis::GisGeometry::typeToString ( const Type & type)
static

Returns the type of the Geometry as a QString.

See also
type(QString)
Parameters
gstrTypeEnum type of origin
Returns
GisGeometry::Type Character representation of geometry or origin

References GeosGis, IsisCube, type(), WKB, and WKT.

Referenced by GisGeometry().


The documentation for this class was generated from the following files: