Skip to content

Commit 3f5b11b

Browse files
mangelatsnyalldawson
authored andcommittedOct 27, 2017
Make asGridified and newSameType (helper function)
1 parent 99b1c74 commit 3f5b11b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+576
-14
lines changed
 

‎python/core/geometry/qgsabstractgeometry.sip

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ class QgsAbstractGeometry
7171
virtual ~QgsAbstractGeometry();
7272
QgsAbstractGeometry( const QgsAbstractGeometry &geom );
7373

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+
7484
virtual QgsAbstractGeometry *clone() const = 0 /Factory/;
7585
%Docstring
7686
Clones the geometry by performing a deep copy
@@ -402,6 +412,32 @@ Returns the centroid of the geometry
402412
:rtype: QgsAbstractGeometry
403413
%End
404414

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+
405441
virtual double vertexAngle( QgsVertexId vertex ) const = 0;
406442
%Docstring
407443
Returns approximate angle at a vertex. This is usually the average angle between adjacent

‎python/core/geometry/qgscircularstring.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class QgsCircularString: QgsCurve
2929

3030
virtual QString geometryType() const;
3131
virtual int dimension() const;
32+
virtual QgsCircularString *createEmptyWithSameType() const /Factory/;
3233
virtual QgsCircularString *clone() const /Factory/;
3334
virtual void clear();
3435

0 commit comments

Comments
 (0)
Please sign in to comment.