-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE][API] Add parts iterators to QgsGeometry
This allows easy iteration over all the parts of a geometry, regardless of the geometry's type. E.g. geometry = QgsGeometry.fromWkt( 'MultiPoint( 0 0, 1 1, 2 2)' ) for part in geometry.parts(): print(part.asWkt()) geometry = QgsGeometry.fromWkt( 'LineString( 0 0, 10 10 )' ) for part in geometry.parts(): print(part.asWkt()) There are two iterators available. QgsGeometry.parts() gives a non-const iterator, allowing the parts to be modified in place: geometry = QgsGeometry.fromWkt( 'MultiPoint( 0 0, 1 1, 2 2)' ) for part in geometry.parts(): part.transform(ct) For a const iteration, calling .const_parts() gives a const iterator, which cannot edit the parts but avoids a potentially expensive QgsGeometry detach and clone geometry = QgsGeometry.fromWkt( 'MultiPoint( 0 0, 1 1, 2 2)' ) for part in geometry.const_parts(): print(part.x()) (cherry picked from commit a22422c)
- Loading branch information
1 parent
282a2f8
commit 5484bb3
Showing
10 changed files
with
989 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.