Isis 3 Programmer Reference
GisGeometry.h
1#ifndef GisGeometry_h
2#define GisGeometry_h
7
8/* SPDX-License-Identifier: CC0-1.0 */
9
10// GEOSGeometry, GEOSPreparedGeometry types
11#include <geos_c.h>
12
13// Qt library
14#include <QMetaType>
15#include <QSharedPointer>
16
17class QString;
18
19namespace Isis {
20
21 class Cube;
56
57 public:
68
70 GisGeometry(const double xlongitude, const double ylatitude);
71 GisGeometry(Cube &cube);
72 GisGeometry(const QString &gisSource, const Type t);
73 GisGeometry(const GisGeometry &geom);
74 GisGeometry(GEOSGeometry *geom);
75 GisGeometry &operator=(GisGeometry const &geom);
76 virtual ~GisGeometry();
77
78 void setGeometry(GEOSGeometry *geom);
79
80 bool isDefined() const;
81 bool isValid() const;
82 QString isValidReason() const;
83 bool isEmpty() const;
84 Type type() const;
85 static Type type(const QString &gtype);
86 static QString typeToString(const Type &type);
87
88 const GEOSGeometry *geometry() const;
89 const GEOSPreparedGeometry *preparedGeometry() const;
90
91 GisGeometry *clone() const;
92
93 // Useful operations
94 double area() const;
95 double length() const;
96 double distance(const GisGeometry &target) const;
97 int points() const;
98
99 bool intersects(const GisGeometry &target) const;
100 bool contains(const GisGeometry &target) const;
101 bool disjoint(const GisGeometry &target) const;
102 bool overlaps(const GisGeometry &target) const;
103 bool equals(const GisGeometry &target) const;
104
105 double intersectRatio(const GisGeometry &geom) const;
106
107 GisGeometry *buffer(const double width=0.0, const int quadsegs=16) const;
108 GisGeometry *envelope( ) const;
109 GisGeometry *convexHull( ) const;
110 GisGeometry *simplify(const double &tolerance) const;
111
112 GisGeometry *intersection(const GisGeometry &geom) const;
113 GisGeometry *g_union(const GisGeometry &geom) const;
114
115 GisGeometry *centroid() const;
116 bool centroid(double &xlongitude, double &ylatitude) const;
117
118 private:
119 GEOSGeometry *makePoint(const double x, const double y) const;
120 GEOSGeometry *fromCube(Cube &cube) const;
121 GEOSPreparedGeometry const *makePrepared(const GEOSGeometry *geom) const;
122 void destroy();
123
125 GEOSGeometry *m_geom;
126 GEOSPreparedGeometry const *m_preparedGeom;
127
128 };
129
132
133} // Namespace Isis
134
135// Declaration so this type can be used in Qt's QVariant class
136Q_DECLARE_METATYPE(Isis::SharedGisGeometry);
137
138#endif
139
IO Handler for Isis Cubes.
Definition Cube.h:168
Encapsulation class provides support for GEOS-C API.
Definition GisGeometry.h:55
GEOSPreparedGeometry const * makePrepared(const GEOSGeometry *geom) const
Creates a prepared geometry of current geometry.
static QString typeToString(const Type &type)
Returns the type of the Geometry as a QString.
virtual ~GisGeometry()
Destructor.
double intersectRatio(const GisGeometry &geom) const
Computes intersect ratio between two geometries.
bool overlaps(const GisGeometry &target) const
Test for overlapping geometries.
GisGeometry * centroid() const
Computes the centroid of the geometry and returns it as a new geometry.
GEOSGeometry * fromCube(Cube &cube) const
Reads Polygon from ISIS Cube and returns geometry from contents.
bool contains(const GisGeometry &target) const
Test if the target geometry is contained within this geometry.
double area() const
Computes the area of a geometry.
Type type() const
Returns the type (origin) of the geometry.
bool equals(const GisGeometry &target) const
Test if target and this geometry are equal.
bool disjoint(const GisGeometry &target) const
Tests for disjoint geometries.
bool intersects(const GisGeometry &target) const
Computes a new geometry from the intersection of the two geomtries.
GisGeometry * convexHull() const
Computes the convex hull of the geometry.
void destroy()
Destroys the GEOS elements of this geometry object.
GisGeometry * g_union(const GisGeometry &geom) const
Computes the union of two geometries.
Type
Source type of the geometry.
Definition GisGeometry.h:61
@ IsisCube
An ISIS Cube is used to create the geometry.
Definition GisGeometry.h:65
@ GeosGis
GEOS GIS. A geometry object cannot be created with this geometry type.
Definition GisGeometry.h:66
@ None
No geometry. A geometry object cannot be created with this geometry type.
Definition GisGeometry.h:62
@ WKB
The GEOS library WKB reader is used to create the geometry.
Definition GisGeometry.h:64
@ WKT
The GEOS library WKT reader is used to create the geometry.
Definition GisGeometry.h:63
GisGeometry * clone() const
Clones the contents of this geometry to a new instance.
const GEOSGeometry * geometry() const
Returns the GEOSGeometry object to extend functionality.
GisGeometry & operator=(GisGeometry const &geom)
Assignment operator for GISGeomtries.
double distance(const GisGeometry &target) const
Computes the distance between two geometries.
double length() const
Computes the length of a geometry.
GEOSGeometry * m_geom
Pointer to GEOS-C opaque structure.
bool isValid() const
Determines validity of the geometry contained in this object.
const GEOSPreparedGeometry * preparedGeometry() const
Returns special GEOS prepared geometry if it exists.
void setGeometry(GEOSGeometry *geom)
Set the geometry directly taking ownership.
GisGeometry * envelope() const
Computes the envelope or bounding box of this geometry.
GEOSPreparedGeometry const * m_preparedGeom
A prepared geometry from the GEOS library.
GisGeometry * buffer(const double width=0.0, const int quadsegs=16) const
Compute a buffer around an existing geometry.
int points() const
Get number of points in geometry.
GisGeometry * simplify(const double &tolerance) const
Simplify complex or overdetermined geoemtry.
bool isDefined() const
Determines if the current geometry is valid.
bool isEmpty() const
Tests for a defined but empty geometry.
Type m_type
Geometry type of GIS source.
GisGeometry * intersection(const GisGeometry &geom) const
Computes the intersection of two geometries.
QString isValidReason() const
Returns a string describing reason for invalid geometry.
GEOSGeometry * makePoint(const double x, const double y) const
Create a point geometry.
GisGeometry()
Fundamental constructor of an empty object.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
QSharedPointer< GisGeometry > SharedGisGeometry
Definition for a SharedGisGeometry, a shared pointer to a GisGeometry.