-
Notifications
You must be signed in to change notification settings - Fork 172
/
Copy pathGisGeometry.h
139 lines (113 loc) · 5.32 KB
/
GisGeometry.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#ifndef GisGeometry_h
#define GisGeometry_h
/** This is free and unencumbered software released into the public domain.
The authors of ISIS do not claim copyright on the contents of this file.
For more details about the LICENSE terms and the AUTHORS, you will
find files of those names at the top level of this repository. **/
/* SPDX-License-Identifier: CC0-1.0 */
// GEOSGeometry, GEOSPreparedGeometry types
#include <geos_c.h>
// Qt library
#include <QMetaType>
#include <QSharedPointer>
class QString;
namespace Isis {
class Cube;
/**
* @brief 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 Topology Suite (JTS) provides a simplified, generic C
* API using an opaque C pointer. This layer is to provide a 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
* @internal
* @history 2012-07-15 Kris Becker - Original version.
* @history 2015-03-18 Jeannie Backer - Brought class files closer to ISIS coding standards.
* @history 2016-03-02 Ian Humphrey - Updated for coding standards compliance. Added to
* jwbacker's original unit test to prepare for adding this class to
* ISIS. Fixes #2398.
* @history 2016-03-04 Kris Becker - Completed the documentation and implemented the equals()
* method.
* @history 2018-07-29 Kris Becker - Added buffer() method; isValid() was
* throwing an exception if the geometry was invalid
* (e.g., self-intersecting geometry), which is now
* trapped and a false condition is properly returned.
*
*/
class GisGeometry {
public:
/**
* Source type of the geometry.
*/
enum Type {
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.
};
GisGeometry();
GisGeometry(const double xlongitude, const double ylatitude);
GisGeometry(Cube &cube);
GisGeometry(const QString &gisSource, const Type t);
GisGeometry(const GisGeometry &geom);
GisGeometry(GEOSGeometry *geom);
GisGeometry &operator=(GisGeometry const &geom);
virtual ~GisGeometry();
void setGeometry(GEOSGeometry *geom);
bool isDefined() const;
bool isValid() const;
QString isValidReason() const;
bool isEmpty() const;
Type type() const;
static Type type(const QString >ype);
static QString typeToString(const Type &type);
const GEOSGeometry *geometry() const;
const GEOSPreparedGeometry *preparedGeometry() const;
GisGeometry *clone() const;
// Useful operations
double area() const;
double length() const;
double distance(const GisGeometry &target) const;
int points() const;
bool intersects(const GisGeometry &target) const;
bool contains(const GisGeometry &target) const;
bool disjoint(const GisGeometry &target) const;
bool overlaps(const GisGeometry &target) const;
bool equals(const GisGeometry &target) const;
double intersectRatio(const GisGeometry &geom) const;
GisGeometry *buffer(const double width=0.0, const int quadsegs=16) const;
GisGeometry *envelope( ) const;
GisGeometry *convexHull( ) const;
GisGeometry *simplify(const double &tolerance) const;
GisGeometry *intersection(const GisGeometry &geom) const;
GisGeometry *g_union(const GisGeometry &geom) const;
GisGeometry *centroid() const;
bool centroid(double &xlongitude, double &ylatitude) const;
private:
GEOSGeometry *makePoint(const double x, const double y) const;
GEOSGeometry *fromCube(Cube &cube) const;
GEOSPreparedGeometry const *makePrepared(const GEOSGeometry *geom) const;
void destroy();
Type m_type; //!< Geometry type of GIS source
GEOSGeometry *m_geom; //!< Pointer to GEOS-C opaque structure
GEOSPreparedGeometry const *m_preparedGeom; //!< A prepared geometry from the GEOS library.
};
//! Definition for a SharedGisGeometry, a shared pointer to a GisGeometry
typedef QSharedPointer<GisGeometry> SharedGisGeometry;
} // Namespace Isis
// Declaration so this type can be used in Qt's QVariant class
Q_DECLARE_METATYPE(Isis::SharedGisGeometry);
#endif