@@ -71,6 +71,16 @@ class QgsAbstractGeometry
71
71
virtual ~QgsAbstractGeometry();
72
72
QgsAbstractGeometry( const QgsAbstractGeometry &geom );
73
73
74
+ virtual QgsAbstractGeometry *createEmptyWithSameType() const = 0 /Factory/;
75
+ %Docstring
76
+ Makes a new geometry with the same class and same WKB and transfers ownership.
77
+ To create it, the geometry is default constructedand then the WKB is changed.
78
+ :return: the new empty geometry. Callee takes ownership.
79
+ .. seealso:: clone
80
+ .. versionadded:: 3.0
81
+ :rtype: QgsAbstractGeometry
82
+ %End
83
+
74
84
virtual QgsAbstractGeometry *clone() const = 0 /Factory/;
75
85
%Docstring
76
86
Clones the geometry by performing a deep copy
@@ -402,6 +412,32 @@ Returns the centroid of the geometry
402
412
:rtype: QgsAbstractGeometry
403
413
%End
404
414
415
+ virtual QgsAbstractGeometry *snappedToGrid( double hSpacing, double vSpacing, double dSpacing = 0, double mSpacing = 0, double tolerance = M_PI / 180., SegmentationToleranceType toleranceType = MaximumAngle ) const = 0 /Factory/;
416
+ %Docstring
417
+ Makes a new geometry with all the points or vertices snapped to the closest point of the grid.
418
+ It transfers ownership to the callee.
419
+ If it couldn't make the gridified geometry it returns None.
420
+ It may generate an invalid geometry (in some corner cases).
421
+ It can also be thought as rounding the edges and it may be useful for removing errors.
422
+ If the geometry is curved, it will be segmentized before gridifying it.
423
+ Example:
424
+ \code
425
+ geometry->snappedToGrid(1, 1);
426
+ \endcode
427
+ In this case we use a 2D grid of 1x1 to gridify.
428
+ In this case, it can be thought like rounding the x and y of all the points/vertices to full units (remove all decimals).
429
+ \param hSpacing Horizontal spacing of the grid (x axis). 0 to disable.
430
+ \param vSpacing Vertical spacing of the grid (y axis). 0 to disable.
431
+ \param dSpacing Depth spacing of the grid (z axis). 0 (default) to disable.
432
+ \param mSpacing Custom dimension spacing of the grid (m axis). 0 (default) to disable.
433
+ \param tolerance In case of segmentation, the tolerance to use (passed to segmentize as is).
434
+ \param toleranceType In case of segmentation, the toleranceType to use (passed to segmentize as is).
435
+ :return: the segmentized geometry or None if it wasn't possible to make. Caller takes ownership.
436
+ .. seealso:: segmentize
437
+ .. versionadded:: 3.0
438
+ :rtype: QgsAbstractGeometry
439
+ %End
440
+
405
441
virtual double vertexAngle( QgsVertexId vertex ) const = 0;
406
442
%Docstring
407
443
Returns approximate angle at a vertex. This is usually the average angle between adjacent
0 commit comments