USGS

Isis 3.0 Object Programmers' Reference

Home

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 
136  GEOSGeometry *m_geom;
137  GEOSPreparedGeometry const *m_preparedGeom;
138 
139  };
140 
142  typedef QSharedPointer<GisGeometry> SharedGisGeometry;
143 
144 } // Namespace Isis
145 
146 // Declaration so this type can be used in Qt's QVariant class
148 
149 #endif
150