-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
qgsgeometryengine.h
279 lines (242 loc) · 10.4 KB
/
qgsgeometryengine.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
/***************************************************************************
qgsgeometryengine.h
-------------------------------------------------------------------
Date : 22 Sept 2014
Copyright : (C) 2014 by Marco Hugentobler
email : marco.hugentobler at sourcepole dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSGEOMETRYENGINE_H
#define QGSGEOMETRYENGINE_H
#include "qgis_core.h"
#include "qgslinestring.h"
#include "qgsgeometry.h"
#include <QVector>
class QgsAbstractGeometry;
/**
* \ingroup core
* \class QgsGeometryEngine
* \brief Contains geometry relation and modification algorithms.
* \since QGIS 2.10
*/
class CORE_EXPORT QgsGeometryEngine
{
public:
/**
* Success or failure of a geometry operation.
* This gives details about cause of failure.
*/
enum EngineOperationResult
{
Success = 0, //!< Operation succeeded
NothingHappened = 1000, //!< Nothing happened, without any error
MethodNotImplemented, //!< Method not implemented in geometry engine
EngineError, //!< Error occurred in the geometry engine
NodedGeometryError, //!< Error occurred while creating a noded geometry
InvalidBaseGeometry, //!< The geometry on which the operation occurs is not valid
InvalidInput, //!< The input is not valid
/* split */
SplitCannotSplitPoint, //!< Points cannot be split
};
virtual ~QgsGeometryEngine() = default;
/**
* Should be called whenever the geometry associated with the engine
* has been modified and the engine must be updated to suit.
*/
virtual void geometryChanged() = 0;
/**
* Prepares the geometry, so that subsequent calls to spatial relation methods
* are much faster.
*
* This should be called for any geometry which is used for multiple relation
* tests against other geometries.
*
* \see geometryChanged()
*/
virtual void prepareGeometry() = 0;
/**
* Calculate the intersection of this and \a geom.
*
* \since QGIS 3.0 \a geom is a pointer
*/
virtual QgsAbstractGeometry *intersection( const QgsAbstractGeometry *geom, QString *errorMsg = nullptr ) const = 0 SIP_FACTORY;
/**
* Calculate the difference of this and \a geom.
*
* \since QGIS 3.0 \a geom is a pointer
*/
virtual QgsAbstractGeometry *difference( const QgsAbstractGeometry *geom, QString *errorMsg = nullptr ) const = 0 SIP_FACTORY;
/**
* Calculate the combination of this and \a geom.
*
* \since QGIS 3.0 \a geom is a pointer
*/
virtual QgsAbstractGeometry *combine( const QgsAbstractGeometry *geom, QString *errorMsg = nullptr ) const = 0 SIP_FACTORY;
/**
* Calculate the combination of this and \a geometries.
*
* \since QGIS 3.0 \a geom is a pointer
*/
virtual QgsAbstractGeometry *combine( const QVector<QgsAbstractGeometry *> &geomList, QString *errorMsg ) const = 0 SIP_FACTORY;
/**
* Calculate the combination of this and \a geometries.
*
* \since QGIS 3.0 \a geom is a pointer
*/
virtual QgsAbstractGeometry *combine( const QVector< QgsGeometry > &geometries, QString *errorMsg = nullptr ) const = 0 SIP_FACTORY;
/**
* Calculate the symmetric difference of this and \a geom.
*
* \since QGIS 3.0 \a geom is a pointer
*/
virtual QgsAbstractGeometry *symDifference( const QgsAbstractGeometry *geom, QString *errorMsg = nullptr ) const = 0 SIP_FACTORY;
virtual QgsAbstractGeometry *buffer( double distance, int segments, QString *errorMsg = nullptr ) const = 0 SIP_FACTORY;
virtual QgsAbstractGeometry *buffer( double distance, int segments, int endCapStyle, int joinStyle, double miterLimit, QString *errorMsg = nullptr ) const = 0 SIP_FACTORY;
virtual QgsAbstractGeometry *simplify( double tolerance, QString *errorMsg = nullptr ) const = 0 SIP_FACTORY;
virtual QgsAbstractGeometry *interpolate( double distance, QString *errorMsg = nullptr ) const = 0 SIP_FACTORY;
virtual QgsAbstractGeometry *envelope( QString *errorMsg = nullptr ) const = 0 SIP_FACTORY;
/**
* Calculates the centroid of this.
* May return a `nullptr`.
*
* \since QGIS 3.0 the centroid is returned
*/
virtual QgsPoint *centroid( QString *errorMsg = nullptr ) const = 0 SIP_FACTORY;
/**
* Calculate a point that is guaranteed to be on the surface of this.
* May return a `nullptr`.
*
* \since QGIS 3.0 the centroid is returned
*/
virtual QgsPoint *pointOnSurface( QString *errorMsg = nullptr ) const = 0 SIP_FACTORY;
/**
* Calculate the convex hull of this.
*/
virtual QgsAbstractGeometry *convexHull( QString *errorMsg = nullptr ) const = 0 SIP_FACTORY;
/**
* Calculates the distance between this and \a geom.
*
* \since QGIS 3.0 \a geom is a pointer
*/
virtual double distance( const QgsAbstractGeometry *geom, QString *errorMsg = nullptr ) const = 0;
/**
* Checks if \a geom intersects this.
*
* \since QGIS 3.0 \a geom is a pointer
*/
virtual bool intersects( const QgsAbstractGeometry *geom, QString *errorMsg = nullptr ) const = 0;
/**
* Checks if \a geom touches this.
*
* \since QGIS 3.0 \a geom is a pointer
*/
virtual bool touches( const QgsAbstractGeometry *geom, QString *errorMsg = nullptr ) const = 0;
/**
* Checks if \a geom crosses this.
*
* \since QGIS 3.0 \a geom is a pointer
*/
virtual bool crosses( const QgsAbstractGeometry *geom, QString *errorMsg = nullptr ) const = 0;
/**
* Checks if \a geom is within this.
*
* \since QGIS 3.0 \a geom is a pointer
*/
virtual bool within( const QgsAbstractGeometry *geom, QString *errorMsg = nullptr ) const = 0;
/**
* Checks if \a geom overlaps this.
*
* \since QGIS 3.0 \a geom is a pointer
*/
virtual bool overlaps( const QgsAbstractGeometry *geom, QString *errorMsg = nullptr ) const = 0;
/**
* Checks if \a geom contains this.
*
* \since QGIS 3.0 \a geom is a pointer
*/
virtual bool contains( const QgsAbstractGeometry *geom, QString *errorMsg = nullptr ) const = 0;
/**
* Checks if \a geom is disjoint from this.
*
* \since QGIS 3.0 \a geom is a pointer
*/
virtual bool disjoint( const QgsAbstractGeometry *geom, QString *errorMsg = nullptr ) const = 0;
/**
* Returns the Dimensional Extended 9 Intersection Model (DE-9IM) representation of the
* relationship between the geometries.
* \param geom geometry to relate to
* \param errorMsg destination storage for any error message
* \returns DE-9IM string for relationship, or an empty string if an error occurred
* \since QGIS 2.12
*/
virtual QString relate( const QgsAbstractGeometry *geom, QString *errorMsg = nullptr ) const = 0;
/**
* Tests whether two geometries are related by a specified Dimensional Extended 9 Intersection Model (DE-9IM)
* pattern.
* \param geom geometry to relate to
* \param pattern DE-9IM pattern for match
* \param errorMsg destination storage for any error message
* \returns true if geometry relationship matches with pattern
* \since QGIS 2.14
*/
virtual bool relatePattern( const QgsAbstractGeometry *geom, const QString &pattern, QString *errorMsg = nullptr ) const = 0;
virtual double area( QString *errorMsg = nullptr ) const = 0;
virtual double length( QString *errorMsg = nullptr ) const = 0;
/**
* Returns true if the geometry is valid.
*
* If the geometry is invalid, \a errorMsg will be filled with the reported geometry error.
*
* The \a allowSelfTouchingHoles argument specifies whether self-touching holes are permitted.
* OGC validity states that self-touching holes are NOT permitted, whilst other vendor
* validity checks (e.g. ESRI) permit self-touching holes.
*/
virtual bool isValid( QString *errorMsg = nullptr, bool allowSelfTouchingHoles = false ) const = 0;
/**
* Checks if this is equal to \a geom.
* If both are Null geometries, `false` is returned.
*
* \since QGIS 3.0 \a geom is a pointer
*/
virtual bool isEqual( const QgsAbstractGeometry *geom, QString *errorMsg = nullptr ) const = 0;
virtual bool isEmpty( QString *errorMsg ) const = 0;
/**
* Determines whether the geometry is simple (according to OGC definition).
* \since QGIS 3.0
*/
virtual bool isSimple( QString *errorMsg = nullptr ) const = 0;
/**
* Splits this geometry according to a given line.
* \param splitLine the line that splits the geometry
* \param[out] newGeometries list of new geometries that have been created with the split
* \param topological true if topological editing is enabled
* \param[out] topologyTestPoints points that need to be tested for topological completeness in the dataset
* \param[out] errorMsg error messages emitted, if any
* \returns 0 in case of success, 1 if geometry has not been split, error else
*/
virtual QgsGeometryEngine::EngineOperationResult splitGeometry( const QgsLineString &splitLine,
QVector<QgsGeometry > &newGeometries SIP_OUT,
bool topological,
QgsPointSequence &topologyTestPoints, QString *errorMsg = nullptr ) const
{
Q_UNUSED( splitLine );
Q_UNUSED( newGeometries );
Q_UNUSED( topological );
Q_UNUSED( topologyTestPoints );
Q_UNUSED( errorMsg );
return MethodNotImplemented;
}
virtual QgsAbstractGeometry *offsetCurve( double distance, int segments, int joinStyle, double miterLimit, QString *errorMsg = nullptr ) const = 0 SIP_FACTORY;
protected:
const QgsAbstractGeometry *mGeometry = nullptr;
QgsGeometryEngine( const QgsAbstractGeometry *geometry )
: mGeometry( geometry )
{}
};
#endif // QGSGEOMETRYENGINE_H