Isis 3 Developer Reference
GisGeometry.h
Go to the documentation of this file.
1 #ifndef GisGeometry_h
2 #define GisGeometry_h
3 
27 // GEOSGeometry, GEOSPreparedGeometry types
28 #include <geos_c.h>
29 
30 // Qt library
31 #include <QMetaType>
32 #include <QSharedPointer>
33 
34 class QString;
35 
36 namespace Isis {
37 
38  class Cube;
67  class GisGeometry {
68 
69  public:
73  enum Type {
74  None,
75  WKT,
76  WKB,
79  };
80 
81  GisGeometry();
82  GisGeometry(const double xlongitude, const double ylatitude);
83  GisGeometry(Cube &cube);
84  GisGeometry(const QString &gisSource, const Type t);
85  GisGeometry(const GisGeometry &geom);
86  GisGeometry(GEOSGeometry *geom);
87  GisGeometry &operator=(GisGeometry const &geom);
88  virtual ~GisGeometry();
89 
90  void setGeometry(GEOSGeometry *geom);
91 
92  bool isDefined() const;
93  bool isValid() const;
94  QString isValidReason() const;
95  bool isEmpty() const;
96  Type type() const;
97  static Type type(const QString &gtype);
98  static QString typeToString(const Type &type);
99 
100  const GEOSGeometry *geometry() const;
101  const GEOSPreparedGeometry *preparedGeometry() const;
102 
103  GisGeometry *clone() const;
104 
105  // Useful operations
106  double area() const;
107  double length() const;
108  double distance(const GisGeometry &target) const;
109  int points() const;
110 
111  bool intersects(const GisGeometry &target) const;
112  bool contains(const GisGeometry &target) const;
113  bool disjoint(const GisGeometry &target) const;
114  bool overlaps(const GisGeometry &target) const;
115  bool equals(const GisGeometry &target) const;
116 
117  double intersectRatio(const GisGeometry &geom) const;
118 
119  GisGeometry *envelope( ) const;
120  GisGeometry *convexHull( ) const;
121  GisGeometry *simplify(const double &tolerance) const;
122 
123  GisGeometry *intersection(const GisGeometry &geom) const;
124  GisGeometry *g_union(const GisGeometry &geom) const;
125 
126  GisGeometry *centroid() const;
127  bool centroid(double &xlongitude, double &ylatitude) const;
128 
129  private:
130  GEOSGeometry *makePoint(const double x, const double y) const;
131  GEOSGeometry *fromCube(Cube &cube) const;
132  GEOSPreparedGeometry const *makePrepared(const GEOSGeometry *geom) const;
133  void destroy();
134 
135  Type m_type;
136  GEOSGeometry *m_geom;
137  GEOSPreparedGeometry const *m_preparedGeom;
138 
139  };
140 
143 
144 } // Namespace Isis
145 
146 // Declaration so this type can be used in Qt's QVariant class
148 
149 #endif
150 
GisGeometry * convexHull() const
Computes the convex hull of the geometry.
Definition: GisGeometry.cpp:653
bool isDefined() const
Determines if the current geometry is valid.
Definition: GisGeometry.cpp:217
GisGeometry * clone() const
Clones the contents of this geometry to a new instance.
Definition: GisGeometry.cpp:335
GisGeometry * simplify(const double &tolerance) const
Simplify complex or overdetermined geoemtry.
Definition: GisGeometry.cpp:676
bool equals(const GisGeometry &target) const
Test if target and this geometry are equal.
Definition: GisGeometry.cpp:574
bool contains(const GisGeometry &target) const
Test if the target geometry is contained within this geometry.
Definition: GisGeometry.cpp:495
const GEOSPreparedGeometry * preparedGeometry() const
Returns special GEOS prepared geometry if it exists.
Definition: GisGeometry.cpp:322
No geometry. A geometry object cannot be created with this geometry type.
Definition: GisGeometry.h:74
GisGeometry * g_union(const GisGeometry &geom) const
Computes the union of two geometries.
Definition: GisGeometry.cpp:718
The GEOS library WKB reader is used to create the geometry.
Definition: GisGeometry.h:76
GEOS GIS. A geometry object cannot be created with this geometry type.
Definition: GisGeometry.h:78
double intersectRatio(const GisGeometry &geom) const
Computes intersect ratio between two geometries.
Definition: GisGeometry.cpp:599
bool intersects(const GisGeometry &target) const
Computes a new geometry from the intersection of the two geomtries.
Definition: GisGeometry.cpp:468
static QString typeToString(const Type &type)
Returns the type of the Geometry as a QString.
Definition: GisGeometry.cpp:294
bool disjoint(const GisGeometry &target) const
Tests for disjoint geometries.
Definition: GisGeometry.cpp:521
An ISIS Cube is used to create the geometry.
Definition: GisGeometry.h:77
double length() const
Computes the length of a geometry.
Definition: GisGeometry.cpp:399
virtual ~GisGeometry()
Destructor.
Definition: GisGeometry.cpp:168
double distance(const GisGeometry &target) const
Computes the distance between two geometries.
Definition: GisGeometry.cpp:423
bool isValid() const
Determines validity of the geometry contained in this object.
Definition: GisGeometry.cpp:230
GisGeometry & operator=(GisGeometry const &geom)
Assignment operator for GISGeomtries.
Definition: GisGeometry.cpp:181
Type
Source type of the geometry.
Definition: GisGeometry.h:73
QSharedPointer< GisGeometry > SharedGisGeometry
Definition for a SharedGisGeometry, a shared pointer to a GisGeometry.
Definition: GisGeometry.h:142
GisGeometry * envelope() const
Computes the envelope or bounding box of this geometry.
Definition: GisGeometry.cpp:636
bool overlaps(const GisGeometry &target) const
Test for overlapping geometries.
Definition: GisGeometry.cpp:548
Q_DECLARE_METATYPE(Isis::SharedGisGeometry)
GisGeometry * centroid() const
Computes the centroid of the geometry and returns it as a new geometry.
Definition: GisGeometry.cpp:763
double area() const
Computes the area of a geometry.
Definition: GisGeometry.cpp:376
int points() const
Get number of points in geometry.
Definition: GisGeometry.cpp:446
GisGeometry()
Fundamental constructor of an empty object.
Definition: GisGeometry.cpp:50
QString isValidReason() const
Returns a string describing reason for invalid geometry.
Definition: GisGeometry.cpp:244
GisGeometry * intersection(const GisGeometry &geom) const
Computes the intersection of two geometries.
Definition: GisGeometry.cpp:698
Type type() const
Returns the type (origin) of the geometry.
Definition: GisGeometry.cpp:261
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
const GEOSGeometry * geometry() const
Returns the GEOSGeometry object to extend functionality.
Definition: GisGeometry.cpp:308
bool isEmpty() const
Tests for a defined but empty geometry.
Definition: GisGeometry.cpp:355
void setGeometry(GEOSGeometry *geom)
Set the geometry directly taking ownership.
Definition: GisGeometry.cpp:204
The GEOS library WKT reader is used to create the geometry.
Definition: GisGeometry.h:75
Encapsulation class provides support for GEOS-C API.
Definition: GisGeometry.h:67
IO Handler for Isis Cubes.
Definition: Cube.h:170