Isis Developer Reference
GisGeometry.h
Go to the documentation of this file.
1 #ifndef GisGeometry_h
2 #define GisGeometry_h
3 
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 
17 class QString;
18 
19 namespace Isis {
20 
21  class Cube;
50  class GisGeometry {
51 
52  public:
56  enum Type {
57  None,
58  WKT,
59  WKB,
61  GeosGis
62  };
63 
64  GisGeometry();
65  GisGeometry(const double xlongitude, const double ylatitude);
66  GisGeometry(Cube &cube);
67  GisGeometry(const QString &gisSource, const Type t);
68  GisGeometry(const GisGeometry &geom);
69  GisGeometry(GEOSGeometry *geom);
70  GisGeometry &operator=(GisGeometry const &geom);
71  virtual ~GisGeometry();
72 
73  void setGeometry(GEOSGeometry *geom);
74 
75  bool isDefined() const;
76  bool isValid() const;
77  QString isValidReason() const;
78  bool isEmpty() const;
79  Type type() const;
80  static Type type(const QString &gtype);
81  static QString typeToString(const Type &type);
82 
83  const GEOSGeometry *geometry() const;
84  const GEOSPreparedGeometry *preparedGeometry() const;
85 
86  GisGeometry *clone() const;
87 
88  // Useful operations
89  double area() const;
90  double length() const;
91  double distance(const GisGeometry &target) const;
92  int points() const;
93 
94  bool intersects(const GisGeometry &target) const;
95  bool contains(const GisGeometry &target) const;
96  bool disjoint(const GisGeometry &target) const;
97  bool overlaps(const GisGeometry &target) const;
98  bool equals(const GisGeometry &target) const;
99 
100  double intersectRatio(const GisGeometry &geom) const;
101 
102  GisGeometry *envelope( ) const;
103  GisGeometry *convexHull( ) const;
104  GisGeometry *simplify(const double &tolerance) const;
105 
106  GisGeometry *intersection(const GisGeometry &geom) const;
107  GisGeometry *g_union(const GisGeometry &geom) const;
108 
109  GisGeometry *centroid() const;
110  bool centroid(double &xlongitude, double &ylatitude) const;
111 
112  private:
113  GEOSGeometry *makePoint(const double x, const double y) const;
114  GEOSGeometry *fromCube(Cube &cube) const;
115  GEOSPreparedGeometry const *makePrepared(const GEOSGeometry *geom) const;
116  void destroy();
117 
118  Type m_type;
119  GEOSGeometry *m_geom;
120  GEOSPreparedGeometry const *m_preparedGeom;
121 
122  };
123 
126 
127 } // Namespace Isis
128 
129 // Declaration so this type can be used in Qt's QVariant class
131 
132 #endif
133 
Isis::GisGeometry::points
int points() const
Get number of points in geometry.
Definition: GisGeometry.cpp:429
Isis::GisGeometry::IsisCube
@ IsisCube
An ISIS Cube is used to create the geometry.
Definition: GisGeometry.h:60
Cube.h
Isis::GisGeometry::overlaps
bool overlaps(const GisGeometry &target) const
Test for overlapping geometries.
Definition: GisGeometry.cpp:531
Isis::GisGeometry::envelope
GisGeometry * envelope() const
Computes the envelope or bounding box of this geometry.
Definition: GisGeometry.cpp:619
Isis::GisTopology
This class models GIS topology.
Definition: GisTopology.h:34
Isis::GisGeometry::area
double area() const
Computes the area of a geometry.
Definition: GisGeometry.cpp:359
Isis::GisGeometry::centroid
GisGeometry * centroid() const
Computes the centroid of the geometry and returns it as a new geometry.
Definition: GisGeometry.cpp:746
Isis::GisGeometry::GisGeometry
GisGeometry()
Fundamental constructor of an empty object.
Definition: GisGeometry.cpp:33
SpecialPixel.h
Isis::GisGeometry::WKT
@ WKT
The GEOS library WKT reader is used to create the geometry.
Definition: GisGeometry.h:58
Isis::GisGeometry::isValidReason
QString isValidReason() const
Returns a string describing reason for invalid geometry.
Definition: GisGeometry.cpp:227
Isis::GisGeometry::intersection
GisGeometry * intersection(const GisGeometry &geom) const
Computes the intersection of two geometries.
Definition: GisGeometry.cpp:681
Isis::GisGeometry::type
Type type() const
Returns the type (origin) of the geometry.
Definition: GisGeometry.cpp:244
GisTopology.h
Isis::GisGeometry::geometry
const GEOSGeometry * geometry() const
Returns the GEOSGeometry object to extend functionality.
Definition: GisGeometry.cpp:291
Isis::GisGeometry::isEmpty
bool isEmpty() const
Tests for a defined but empty geometry.
Definition: GisGeometry.cpp:338
QSharedPointer< GisGeometry >
Isis::GisGeometry::setGeometry
void setGeometry(GEOSGeometry *geom)
Set the geometry directly taking ownership.
Definition: GisGeometry.cpp:187
Isis::GisTopology::clone
GEOSGeometry * clone(const GEOSGeometry *geom) const
Clones the given GEOSGeometry pointer.
Definition: GisTopology.cpp:148
Isis::GisGeometry
Encapsulation class provides support for GEOS-C API.
Definition: GisGeometry.h:50
Isis::GisGeometry::GeosGis
@ GeosGis
GEOS GIS. A geometry object cannot be created with this geometry type.
Definition: GisGeometry.h:61
Isis::GisGeometry::isDefined
bool isDefined() const
Determines if the current geometry is valid.
Definition: GisGeometry.cpp:200
GisGeometry.h
Isis::GisGeometry::clone
GisGeometry * clone() const
Clones the contents of this geometry to a new instance.
Definition: GisGeometry.cpp:318
Isis::GisGeometry::equals
bool equals(const GisGeometry &target) const
Test if target and this geometry are equal.
Definition: GisGeometry.cpp:557
_FILEINFO_
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:24
Isis::GisTopology::geomFromWKT
GEOSGeometry * geomFromWKT(const QString &wkt)
Reads in the geometry from the given well-known text formatted string.
Definition: GisTopology.cpp:128
Isis::GisTopology::instance
static GisTopology * instance()
Gets the singleton instance of this class.
Definition: GisTopology.cpp:83
Isis::GisTopology::geomFromWKB
GEOSGeometry * geomFromWKB(const QString &wkb)
Reads in the geometry from the given well-known binary formatted string.
Definition: GisTopology.cpp:100
Isis::GisGeometry::contains
bool contains(const GisGeometry &target) const
Test if the target geometry is contained within this geometry.
Definition: GisGeometry.cpp:478
Isis::GisGeometry::preparedGeometry
const GEOSPreparedGeometry * preparedGeometry() const
Returns special GEOS prepared geometry if it exists.
Definition: GisGeometry.cpp:305
Isis::GisTopology::destroy
void destroy(GEOSGeometry *geom) const
Destroys the given GEOS geometry.
Definition: GisTopology.cpp:232
Isis::GisGeometry::convexHull
GisGeometry * convexHull() const
Computes the convex hull of the geometry.
Definition: GisGeometry.cpp:636
Isis::GisGeometry::g_union
GisGeometry * g_union(const GisGeometry &geom) const
Computes the union of two geometries.
Definition: GisGeometry.cpp:701
Isis::GisGeometry::simplify
GisGeometry * simplify(const double &tolerance) const
Simplify complex or overdetermined geoemtry.
Definition: GisGeometry.cpp:659
Isis::GisGeometry::None
@ None
No geometry. A geometry object cannot be created with this geometry type.
Definition: GisGeometry.h:57
Isis::Cube
IO Handler for Isis Cubes.
Definition: Cube.h:167
Isis::GisGeometry::WKB
@ WKB
The GEOS library WKB reader is used to create the geometry.
Definition: GisGeometry.h:59
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::SharedGisGeometry
QSharedPointer< GisGeometry > SharedGisGeometry
Definition for a SharedGisGeometry, a shared pointer to a GisGeometry.
Definition: GisGeometry.h:125
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(Isis::SharedGisGeometry)
Isis::Null
const double Null
Value for an Isis Null pixel.
Definition: SpecialPixel.h:95
Isis::GisGeometry::intersects
bool intersects(const GisGeometry &target) const
Computes a new geometry from the intersection of the two geomtries.
Definition: GisGeometry.cpp:451
Isis::GisGeometry::typeToString
static QString typeToString(const Type &type)
Returns the type of the Geometry as a QString.
Definition: GisGeometry.cpp:277
IException.h
Isis::IException::Programmer
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:146
std
Namespace for the standard library.
Isis::GisGeometry::intersectRatio
double intersectRatio(const GisGeometry &geom) const
Computes intersect ratio between two geometries.
Definition: GisGeometry.cpp:582
Isis::GisGeometry::length
double length() const
Computes the length of a geometry.
Definition: GisGeometry.cpp:382
Isis::GisGeometry::distance
double distance(const GisGeometry &target) const
Computes the distance between two geometries.
Definition: GisGeometry.cpp:406
Isis::GisGeometry::disjoint
bool disjoint(const GisGeometry &target) const
Tests for disjoint geometries.
Definition: GisGeometry.cpp:504
Isis::GisGeometry::isValid
bool isValid() const
Determines validity of the geometry contained in this object.
Definition: GisGeometry.cpp:213
Isis::Cube::open
void open(const QString &cfile, QString access="r")
This method will open an isis cube for reading or reading/writing.
Definition: Cube.cpp:627
Isis::GisGeometry::Type
Type
Source type of the geometry.
Definition: GisGeometry.h:56
Isis::GisGeometry::operator=
GisGeometry & operator=(GisGeometry const &geom)
Assignment operator for GISGeomtries.
Definition: GisGeometry.cpp:164
Isis::GisGeometry::~GisGeometry
virtual ~GisGeometry()
Destructor.
Definition: GisGeometry.cpp:151
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
ImagePolygon.h
Isis::None
@ None
Definition: PixelType.h:28