qgswkbptr.h is included indirectly by a large number of source files.
So this commit does the following:
- remove #include "qgsapplication.h" from qgswkbptr.h, and copy-paste the swap_endian
function where it's used.
- add the missing #include "qgsapplication.h" in other files
The rationale for this change is:
- qgswkbptr.h doesn't really needs QgsApplication, since it only used swap_endian.
We don't need to add a fake dependency on QgsApplication on every (indirect) "includers"
of qgswkbptr.h
- qgsapplication.h depends on qgsconfig.h which itself changes quite often (on every git op
at least). Before this change, a 'git commit' would trigger a rebuild of about 3500 files.
With this change we're down to ~700.
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())