File: qgsgeometryengine.sip.in

package info (click to toggle)
qgis 3.40.11%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,183,800 kB
  • sloc: cpp: 1,595,841; python: 372,637; xml: 23,474; sh: 3,761; perl: 3,664; ansic: 2,257; sql: 2,137; yacc: 1,068; lex: 577; javascript: 540; lisp: 411; makefile: 154
file content (345 lines) | stat: -rw-r--r-- 13,430 bytes parent folder | download | duplicates (6)
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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
/************************************************************************
 * This file has been generated automatically from                      *
 *                                                                      *
 * src/core/geometry/qgsgeometryengine.h                                *
 *                                                                      *
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 ************************************************************************/





class QgsGeometryEngine
{
%Docstring(signature="appended")
A geometry engine is a low-level representation of a
:py:class:`QgsAbstractGeometry` object, optimised for use with external
geometry libraries such as GEOS.

:py:class:`QgsGeometryEngine` objects provide a mechanism for optimized
evaluation of geometric algorithms, including spatial relationships
between geometries and operations such as buffers or clipping.

:py:class:`QgsGeometryEngine` objects are not created directly, but are
instead created by calling
:py:func:`QgsGeometry.createGeometryEngine()`.

Many methods available in the :py:class:`QgsGeometryEngine` class can
benefit from pre-preparing geometries. For instance, whenever a large
number of spatial relationships will be tested (such as calling
:py:func:`~intersects`, :py:func:`~within`, etc) then the geometry
should first be prepared by calling :py:func:`~prepareGeometry` before
performing the tests.

Example
-------------------------------------

.. code-block:: python

       # polygon_geometry contains a complex polygon, with many vertices
       polygon_geometry = QgsGeometry.fromWkt('Polygon((...))')

       # create a QgsGeometryEngine representation of the polygon
       polygon_geometry_engine = QgsGeometry.createGeometryEngine(polygon_geometry.constGet())

       # since we'll be performing many intersects tests, we can speed up these tests considerably
       # by first "preparing" the geometry engine
       polygon_geometry_engine.prepareGeometry()

       # now we are ready to quickly test intersection against many other objects
       for feature in my_layer.getFeatures():
           feature_geometry = feature.geometry()
           # test whether the feature's geometry intersects our original complex polygon
           if polygon_geometry_engine.intersects(feature_geometry.constGet()):
               print('feature intersects the polygon!')

:py:class:`QgsGeometryEngine` operations are backed by the GEOS library
(https://trac.osgeo.org/geos/).
%End

%TypeHeaderCode
#include "qgsgeometryengine.h"
%End
  public:

    enum EngineOperationResult /BaseType=IntEnum/
    {
      Success,
      NothingHappened,
      MethodNotImplemented,
      EngineError,
      NodedGeometryError,
      InvalidBaseGeometry,
      InvalidInput,
      SplitCannotSplitPoint,
    };

    virtual ~QgsGeometryEngine();

    virtual void geometryChanged() = 0;
%Docstring
Should be called whenever the geometry associated with the engine has
been modified and the engine must be updated to suit.
%End

    virtual void prepareGeometry() = 0;
%Docstring
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.

.. seealso:: :py:func:`geometryChanged`
%End

    virtual QgsAbstractGeometry *intersection( const QgsAbstractGeometry *geom, QString *errorMsg = 0, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const = 0 /Factory/;
%Docstring
Calculate the intersection of this and ``geom``.

:param geom: geometry to perform the operation
:param errorMsg: Error message returned by GEOS
:param parameters: can be used to specify parameters which control the
                   intersection results (since QGIS 3.28)
%End

    virtual QgsAbstractGeometry *difference( const QgsAbstractGeometry *geom, QString *errorMsg = 0, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const = 0 /Factory/;
%Docstring
Calculate the difference of this and ``geom``.

:param geom: geometry to perform the operation
:param errorMsg: Error message returned by GEOS
:param parameters: can be used to specify parameters which control the
                   difference results (since QGIS 3.28)
%End

    virtual QgsAbstractGeometry *combine( const QgsAbstractGeometry *geom, QString *errorMsg = 0, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const = 0 /Factory/;
%Docstring
Calculate the combination of this and ``geom``.

:param geom: geometry to perform the operation
:param errorMsg: Error message returned by GEOS
:param parameters: can be used to specify parameters which control the
                   union results (since QGIS 3.28)
%End

    virtual QgsAbstractGeometry *combine( const QVector<QgsAbstractGeometry *> &geomList, QString *errorMsg, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const = 0 /Factory/;
%Docstring
Calculate the combination of this and ``geometries``.

:param geomList: list of geometries to perform the operation
:param errorMsg: Error message returned by GEOS
:param parameters: can be used to specify parameters which control the
                   combination results (since QGIS 3.28)
%End

    virtual QgsAbstractGeometry *combine( const QVector< QgsGeometry > &geometries, QString *errorMsg = 0, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const = 0 /Factory/;
%Docstring
Calculate the combination of this and ``geometries``.

:param geometries: list of geometries to perform the operation
:param errorMsg: Error message returned by GEOS
:param parameters: can be used to specify parameters which control the
                   combination results (since QGIS 3.28)
%End

    virtual QgsAbstractGeometry *symDifference( const QgsAbstractGeometry *geom, QString *errorMsg = 0, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const = 0 /Factory/;
%Docstring
Calculate the symmetric difference of this and ``geom``.

:param geom: geometry to perform the operation
:param errorMsg: Error message returned by GEOS
:param parameters: can be used to specify parameters which control the
                   difference results (since QGIS 3.28)
%End
    virtual QgsAbstractGeometry *buffer( double distance, int segments, QString *errorMsg = 0 ) const = 0 /Factory/;

    virtual QgsAbstractGeometry *buffer( double distance, int segments, Qgis::EndCapStyle endCapStyle, Qgis::JoinStyle joinStyle, double miterLimit, QString *errorMsg = 0 ) const = 0 /Factory/;
%Docstring
Buffers a geometry.
%End
    virtual QgsAbstractGeometry *simplify( double tolerance, QString *errorMsg = 0 ) const = 0 /Factory/;
    virtual QgsAbstractGeometry *interpolate( double distance, QString *errorMsg = 0 ) const = 0 /Factory/;
    virtual QgsAbstractGeometry *envelope( QString *errorMsg = 0 ) const = 0 /Factory/;

    virtual QgsPoint *centroid( QString *errorMsg = 0 ) const = 0 /Factory/;
%Docstring
Calculates the centroid of this. May return a ```None```.
%End

    virtual QgsPoint *pointOnSurface( QString *errorMsg = 0 ) const = 0 /Factory/;
%Docstring
Calculate a point that is guaranteed to be on the surface of this. May
return a ```None```.
%End

    virtual QgsAbstractGeometry *convexHull( QString *errorMsg = 0 ) const = 0 /Factory/;
%Docstring
Calculate the convex hull of this.
%End

    virtual double distance( const QgsAbstractGeometry *geom, QString *errorMsg = 0 ) const = 0;
%Docstring
Calculates the distance between this and ``geom``.
%End

    virtual bool distanceWithin( const QgsAbstractGeometry *geom, double maxdistance, QString *errorMsg = 0 ) const = 0;
%Docstring
Checks if ``geom`` is within ``maxdistance`` distance from this geometry

.. versionadded:: 3.22
%End

    virtual bool intersects( const QgsAbstractGeometry *geom, QString *errorMsg = 0 ) const = 0;
%Docstring
Checks if ``geom`` intersects this.
%End

    virtual bool touches( const QgsAbstractGeometry *geom, QString *errorMsg = 0 ) const = 0;
%Docstring
Checks if ``geom`` touches this.
%End

    virtual bool crosses( const QgsAbstractGeometry *geom, QString *errorMsg = 0 ) const = 0;
%Docstring
Checks if ``geom`` crosses this.
%End

    virtual bool within( const QgsAbstractGeometry *geom, QString *errorMsg = 0 ) const = 0;
%Docstring
Checks if ``geom`` is within this.
%End

    virtual bool overlaps( const QgsAbstractGeometry *geom, QString *errorMsg = 0 ) const = 0;
%Docstring
Checks if ``geom`` overlaps this.
%End

    virtual bool contains( const QgsAbstractGeometry *geom, QString *errorMsg = 0 ) const = 0;
%Docstring
Checks if ``geom`` contains this.
%End

    virtual bool disjoint( const QgsAbstractGeometry *geom, QString *errorMsg = 0 ) const = 0;
%Docstring
Checks if ``geom`` is disjoint from this.
%End

    virtual QString relate( const QgsAbstractGeometry *geom, QString *errorMsg = 0 ) const = 0;
%Docstring
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

:return: DE-9IM string for relationship, or an empty string if an error
         occurred
%End

    virtual bool relatePattern( const QgsAbstractGeometry *geom, const QString &pattern, QString *errorMsg = 0 ) const = 0;
%Docstring
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

:return: ``True`` if geometry relationship matches with pattern
%End

    virtual double area( QString *errorMsg = 0 ) const = 0;
    virtual double length( QString *errorMsg = 0 ) const = 0;

    virtual bool isValid( QString *errorMsg = 0, bool allowSelfTouchingHoles = false, QgsGeometry *errorLoc = 0 ) const = 0;
%Docstring
Returns ``True`` if the geometry is valid.

If the geometry is invalid, ``errorMsg`` will be filled with the
reported geometry error.

The ``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.

If ``errorLoc`` is specified, it will be set to the geometry of the
error location.
%End

    virtual bool isEqual( const QgsAbstractGeometry *geom, QString *errorMsg = 0 ) const = 0;
%Docstring
Checks if this is equal to ``geom``. If both are Null geometries,
```False``` is returned.
%End
    virtual bool isEmpty( QString *errorMsg ) const = 0;

    virtual bool isSimple( QString *errorMsg = 0 ) const = 0;
%Docstring
Determines whether the geometry is simple (according to OGC definition).
%End

    virtual QgsGeometryEngine::EngineOperationResult splitGeometry( const QgsLineString &splitLine,
        QVector<QgsGeometry > &newGeometries /Out/,
        bool topological,
        QgsPointSequence &topologyTestPoints, QString *errorMsg = 0, bool skipIntersectionCheck = false ) const;
%Docstring
Splits this geometry according to a given line.

:param splitLine: the line that splits the geometry
:param topological: ``True`` if topological editing is enabled
:param topologyTestPoints: points that need to be tested for topological
                           completeness in the dataset
:param errorMsg: error messages emitted, if any
:param skipIntersectionCheck: set to ``True`` to skip the potentially
                              expensive initial intersection check. Only
                              set this flag if an intersection test has
                              already been performed by the caller!

:return: - 0 in case of success, 1 if geometry has not been split, error
           else
         - newGeometries: list of new geometries that have been created
           with the split
%End

    virtual QgsAbstractGeometry *offsetCurve( double distance, int segments, Qgis::JoinStyle joinStyle, double miterLimit, QString *errorMsg = 0 ) const = 0 /Factory/;
%Docstring
Offsets a curve.
%End

    void setLogErrors( bool enabled );
%Docstring
Sets whether warnings and errors encountered during the geometry
operations should be logged.

By default these errors are logged to the console and in the QGIS UI.
But for some operations errors are expected and logging these just
results in noise. In this case setting ``enabled`` to ``False`` will
avoid the automatic error reporting.

.. versionadded:: 3.16
%End

  protected:

    void logError( const QString &engineName, const QString &message ) const;
%Docstring
Logs an error ``message`` encountered during an operation.

.. seealso:: :py:func:`setLogErrors`

.. versionadded:: 3.16
%End

    QgsGeometryEngine( const QgsAbstractGeometry *geometry );
};

/************************************************************************
 * This file has been generated automatically from                      *
 *                                                                      *
 * src/core/geometry/qgsgeometryengine.h                                *
 *                                                                      *
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 ************************************************************************/