Skip to content
Permalink
Browse files

Merge pull request #5359 from nyalldawson/primitive

Rename (and make safe) QgsGeometry::geometry()
  • Loading branch information
nyalldawson committed Oct 26, 2017
2 parents 93f8abe + 3888192 commit 55203a0fc2b8e35fa2909da77a84bbfde8fcba5c
Showing with 616 additions and 550 deletions.
  1. +4 −0 doc/api_break.dox
  2. +1 −1 python/core/geometry/qgsabstractgeometry.sip
  3. +1 −1 python/core/geometry/qgscurve.sip
  4. +1 −1 python/core/geometry/qgscurvepolygon.sip
  5. +38 −7 python/core/geometry/qgsgeometry.sip
  6. +1 −1 python/core/geometry/qgsgeometrycollection.sip
  7. +1 −1 python/core/geometry/qgspoint.sip
  8. +2 −2 python/plugins/processing/algs/qgis/EliminateSelection.py
  9. +3 −3 python/plugins/processing/algs/qgis/Explode.py
  10. +1 −1 python/plugins/processing/algs/qgis/ExportGeometryInfo.py
  11. +1 −1 python/plugins/processing/algs/qgis/ExtractNodes.py
  12. +1 −1 python/plugins/processing/algs/qgis/ExtractSpecificNodes.py
  13. +2 −2 python/plugins/processing/algs/qgis/FindProjection.py
  14. +9 −9 python/plugins/processing/algs/qgis/GeometryConvert.py
  15. +3 −3 python/plugins/processing/algs/qgis/Intersection.py
  16. +1 −1 python/plugins/processing/algs/qgis/LinesToPolygons.py
  17. +3 −3 python/plugins/processing/algs/qgis/MinimumBoundingGeometry.py
  18. +1 −1 python/plugins/processing/algs/qgis/PointsAlongGeometry.py
  19. +1 −1 python/plugins/processing/algs/qgis/PointsDisplacement.py
  20. +1 −1 python/plugins/processing/algs/qgis/PointsFromPolygons.py
  21. +2 −2 python/plugins/processing/algs/qgis/PointsInPolygon.py
  22. +1 −1 python/plugins/processing/algs/qgis/PointsToPaths.py
  23. +3 −3 python/plugins/processing/algs/qgis/Polygonize.py
  24. +1 −1 python/plugins/processing/algs/qgis/PolygonsToLines.py
  25. +2 −2 python/plugins/processing/algs/qgis/RegularPoints.py
  26. +1 −1 python/plugins/processing/algs/qgis/ReverseLineDirection.py
  27. +1 −1 python/plugins/processing/algs/qgis/SetMValue.py
  28. +1 −1 python/plugins/processing/algs/qgis/SetZValue.py
  29. +2 −2 python/plugins/processing/algs/qgis/SpatialJoin.py
  30. +2 −2 python/plugins/processing/algs/qgis/SpatialJoinSummary.py
  31. +2 −2 python/plugins/processing/algs/qgis/SumLines.py
  32. +4 −4 python/plugins/processing/algs/qgis/TopoColors.py
  33. +6 −6 python/plugins/processing/algs/qgis/Union.py
  34. +2 −2 python/testing/__init__.py
  35. +4 −4 src/analysis/network/qgsvectorlayerdirector.cpp
  36. +1 −1 src/analysis/processing/qgsalgorithmboundary.cpp
  37. +4 −4 src/analysis/processing/qgsalgorithmclip.cpp
  38. +2 −2 src/analysis/processing/qgsalgorithmconvexhull.cpp
  39. +1 −1 src/analysis/processing/qgsalgorithmdropmzvalues.cpp
  40. +9 −9 src/analysis/processing/qgsalgorithmextractbylocation.cpp
  41. +1 −1 src/analysis/processing/qgsalgorithmfixgeometries.cpp
  42. +2 −2 src/analysis/processing/qgsalgorithmjoinwithlines.cpp
  43. +2 −2 src/analysis/processing/qgsalgorithmlineintersection.cpp
  44. +1 −1 src/analysis/processing/qgsalgorithmmeancoordinates.cpp
  45. +7 −7 src/analysis/processing/qgsalgorithmsplitwithlines.cpp
  46. +1 −1 src/analysis/processing/qgsalgorithmtransect.cpp
  47. +1 −1 src/analysis/vector/geometry_checker/qgsfeaturepool.cpp
  48. +1 −1 src/analysis/vector/geometry_checker/qgsgeometryanglecheck.cpp
  49. +7 −7 src/analysis/vector/geometry_checker/qgsgeometryareacheck.cpp
  50. +6 −7 src/analysis/vector/geometry_checker/qgsgeometrycheck.cpp
  51. +4 −4 src/analysis/vector/geometry_checker/qgsgeometrycheckerutils.cpp
  52. +1 −1 src/analysis/vector/geometry_checker/qgsgeometrycheckerutils.h
  53. +4 −4 src/analysis/vector/geometry_checker/qgsgeometrycontainedcheck.cpp
  54. +1 −1 src/analysis/vector/geometry_checker/qgsgeometrydegeneratepolygoncheck.cpp
  55. +2 −2 src/analysis/vector/geometry_checker/qgsgeometryduplicatecheck.cpp
  56. +1 −1 src/analysis/vector/geometry_checker/qgsgeometryduplicatenodescheck.cpp
  57. +8 −8 src/analysis/vector/geometry_checker/qgsgeometryfollowboundariescheck.cpp
  58. +4 −4 src/analysis/vector/geometry_checker/qgsgeometrygapcheck.cpp
  59. +1 −1 src/analysis/vector/geometry_checker/qgsgeometryholecheck.cpp
  60. +1 −1 src/analysis/vector/geometry_checker/qgsgeometrymultipartcheck.cpp
  61. +4 −4 src/analysis/vector/geometry_checker/qgsgeometryoverlapcheck.cpp
  62. +1 −1 src/analysis/vector/geometry_checker/qgsgeometryoverlapcheck.h
  63. +1 −1 src/analysis/vector/geometry_checker/qgsgeometrypointinpolygoncheck.cpp
  64. +1 −1 src/analysis/vector/geometry_checker/qgsgeometrysegmentlengthcheck.cpp
  65. +5 −3 src/analysis/vector/geometry_checker/qgsgeometryselfintersectioncheck.cpp
  66. +1 −1 src/analysis/vector/geometry_checker/qgsgeometrysliverpolygoncheck.cpp
  67. +1 −1 src/analysis/vector/geometry_checker/qgsgeometrytypecheck.cpp
  68. +8 −8 src/analysis/vector/qgsgeometrysnapper.cpp
  69. +1 −1 src/app/dwg/qgsdwgimporter.cpp
  70. +16 −16 src/app/nodetool/qgsnodetool.cpp
  71. +1 −1 src/app/nodetool/qgsselectedfeature.cpp
  72. +1 −1 src/app/qgsmaptooladdpart.cpp
  73. +1 −1 src/app/qgsselectbyformdialog.cpp
  74. +1 −1 src/core/dxf/qgsdxfexport.cpp
  75. +1 −1 src/core/expression/qgsexpression.cpp
  76. +44 −44 src/core/expression/qgsexpressionfunction.cpp
  77. +1 −1 src/core/geometry/qgsabstractgeometry.h
  78. +1 −1 src/core/geometry/qgscurve.cpp
  79. +1 −1 src/core/geometry/qgscurve.h
  80. +1 −1 src/core/geometry/qgscurvepolygon.cpp
  81. +1 −1 src/core/geometry/qgscurvepolygon.h
  82. +31 −25 src/core/geometry/qgsgeometry.cpp
  83. +31 −7 src/core/geometry/qgsgeometry.h
  84. +1 −1 src/core/geometry/qgsgeometrycollection.cpp
  85. +1 −1 src/core/geometry/qgsgeometrycollection.h
  86. +3 −3 src/core/geometry/qgsgeos.cpp
  87. +1 −1 src/core/geometry/qgsinternalgeometryengine.cpp
  88. +1 −1 src/core/geometry/qgspoint.cpp
  89. +1 −1 src/core/geometry/qgspoint.h
  90. +3 −3 src/core/providers/memory/qgsmemoryfeatureiterator.cpp
  91. +3 −3 src/core/qgsdistancearea.cpp
  92. +1 −1 src/core/qgsjsonutils.cpp
  93. +2 −2 src/core/qgsmaphittest.cpp
  94. +5 −5 src/core/qgsmaptopixelgeometrysimplifier.cpp
  95. +3 −3 src/core/qgspallabeling.cpp
  96. +3 −3 src/core/qgstracer.cpp
  97. +1 −1 src/core/qgsvectordataprovider.cpp
  98. +9 −9 src/core/qgsvectorfilewriter.cpp
  99. +2 −2 src/core/qgsvectorlayereditutils.cpp
  100. +3 −3 src/core/qgsvectorlayerlabelprovider.cpp
  101. +2 −2 src/core/symbology/qgsfillsymbollayer.cpp
  102. +1 −1 src/core/symbology/qgsinvertedpolygonrenderer.cpp
  103. +1 −1 src/core/symbology/qgspointdistancerenderer.cpp
  104. +15 −15 src/core/symbology/qgssymbol.cpp
  105. +1 −1 src/gui/qgsexpressionselectiondialog.cpp
  106. +1 −1 src/gui/qgsmapcanvas.cpp
  107. +1 −1 src/gui/qgsmaptoolcapture.cpp
  108. +8 −8 src/gui/qgsmaptoolidentify.cpp
  109. +3 −3 src/providers/grass/qgsgrassprovider.cpp
  110. +2 −2 src/server/services/wfs/qgswfsgetfeature.cpp
  111. +1 −1 src/server/services/wms/qgswmsparameters.cpp
  112. +2 −2 src/server/services/wms/qgswmsrenderer.cpp
  113. +3 −3 tests/src/analysis/testqgsprocessing.cpp
  114. +10 −10 tests/src/app/testqgisappclipboard.cpp
  115. +2 −2 tests/src/core/testqgsconnectionpool.cpp
  116. +42 −42 tests/src/core/testqgsgeometry.cpp
  117. +12 −12 tests/src/core/testqgsogrutils.cpp
  118. +1 −1 tests/src/core/testqgspointlocator.cpp
  119. +24 −24 tests/src/geometry_checker/testqgsgeometrychecks.cpp
  120. +1 −1 tests/src/providers/testqgswcspublicservers.cpp
  121. +12 −12 tests/src/python/featuresourcetestbase.py
  122. +6 −6 tests/src/python/test_provider_ogr.py
  123. +2 −2 tests/src/python/test_provider_shapefile.py
  124. +10 −10 tests/src/python/test_provider_wfs.py
  125. +1 −1 tests/src/python/test_qgsfillsymbollayers.py
  126. +54 −54 tests/src/python/test_qgsgeometry.py
  127. +3 −3 tests/src/python/test_qgsjsonutils.py
  128. +1 −1 tests/src/python/test_qgslinesymbollayers.py
  129. +4 −4 tests/src/python/test_qgssymbol.py
  130. +2 −2 tests/src/python/test_qgssymbollayer.py
  131. +4 −4 tests/src/python/test_qgsvectorlayer.py
  132. +3 −3 tests/src/python/test_qgsvectorlayereditbuffer.py
  133. BIN tests/testdata/polys_overlapping_with_id.dbf
@@ -1269,6 +1269,10 @@ QgsGeometry {#qgis_api_break_3_0_QgsGeometry}
value instead of a pointer. The biggest impact with this change is that PyQGIS code should not compare a geometry
result to None, but instead either use a boolean test (`if g.buffer(10):`) or explicitly use the isNull()
method to determine if a geometry is valid.
- The QgsAbstractGeometry getter was renamed from geometry() to get(), and the setter from setGeometry() to set().
This was done to avoid the awkward "feature.geometry().geometry()" expression! Note that calling QgsGeometry.get()
can force a detach and full clone of the geometry, so it is preferable to use the faster QgsGeometry::constGet()
method if the geometry is not being modified.
- isEmpty() was renamed to isNull() to differentiate a missing geometry from a geometry which is empty (eg an
empty geometry collection)
- wkbSize() and asWkb() has been replaced by exportToWkb(). WKB representation is no longer cached within QgsGeometry
@@ -269,7 +269,7 @@ class QgsAbstractGeometry
:rtype: bool
%End

virtual void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex /Out/, QgsVertexId &nextVertex /Out/ ) = 0;
virtual void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex /Out/, QgsVertexId &nextVertex /Out/ ) const = 0;
%Docstring
Returns the vertices adjacent to a specified ``vertex`` within a geometry.
.. versionadded:: 3.0
@@ -102,7 +102,7 @@ class QgsCurve: QgsAbstractGeometry

virtual bool nextVertex( QgsVertexId &id, QgsPoint &vertex /Out/ ) const;

virtual void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex /Out/, QgsVertexId &nextVertex /Out/ );
virtual void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex /Out/, QgsVertexId &nextVertex /Out/ ) const;

virtual int vertexNumberFromVertexId( QgsVertexId id ) const;

@@ -152,7 +152,7 @@ Adds an interior ring to the geometry (takes ownership)

virtual bool nextVertex( QgsVertexId &id, QgsPoint &vertex /Out/ ) const;

virtual void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex /Out/, QgsVertexId &nextVertex /Out/ );
virtual void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex /Out/, QgsVertexId &nextVertex /Out/ ) const;

virtual bool hasCurvedSegments() const;

@@ -84,19 +84,50 @@ Copy constructor will prompt a deep copy of the object

~QgsGeometry();

QgsAbstractGeometry *geometry() const;
const QgsAbstractGeometry *constGet() const;
%Docstring
Returns the underlying geometry store.
.. versionadded:: 2.10
.. seealso:: setGeometry
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.

This is much faster then calling the non-const get() method.

.. note::

In QGIS 2.x this method was named geometry().

.. versionadded:: 3.0
.. seealso:: primitive()
.. seealso:: set()
:rtype: QgsAbstractGeometry
%End

QgsAbstractGeometry *get();
%Docstring
Returns a modifiable (non-const) reference to the underlying abstract geometry primitive.

This method can be slow to call, as it may trigger a detachment of the geometry
and a deep copy. Where possible, use constGet() instead.

.. note::

In QGIS 2.x this method was named geometry().

.. versionadded:: 3.0
.. seealso:: constGet()
.. seealso:: set()
:rtype: QgsAbstractGeometry
%End

void setGeometry( QgsAbstractGeometry *geometry /Transfer/ );
void set( QgsAbstractGeometry *geometry /Transfer/ );
%Docstring
Sets the underlying geometry store. Ownership of geometry is transferred.
.. versionadded:: 2.10
.. seealso:: geometry

.. note::

In QGIS 2.x this method was named setGeometry().

.. versionadded:: 3.0
.. seealso:: get()
.. seealso:: constGet()
%End

bool isNull() const;
@@ -53,7 +53,7 @@ class QgsGeometryCollection: QgsAbstractGeometry

virtual QgsAbstractGeometry *boundary() const /Factory/;

virtual void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex /Out/, QgsVertexId &nextVertex /Out/ );
virtual void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex /Out/, QgsVertexId &nextVertex /Out/ ) const;

virtual int vertexNumberFromVertexId( QgsVertexId id ) const;

@@ -380,7 +380,7 @@ class QgsPoint: QgsAbstractGeometry

virtual bool nextVertex( QgsVertexId &id, QgsPoint &vertex /Out/ ) const;

virtual void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex /Out/, QgsVertexId &nextVertex /Out/ );
virtual void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex /Out/, QgsVertexId &nextVertex /Out/ ) const;


virtual double vertexAngle( QgsVertexId vertex ) const;
@@ -147,7 +147,7 @@ def processAlgorithm(self, parameters, context, feedback):
selFeat = QgsFeature()

# use prepared geometries for faster intersection tests
engine = QgsGeometry.createGeometryEngine(geom2Eliminate.geometry())
engine = QgsGeometry.createGeometryEngine(geom2Eliminate.constGet())
engine.prepareGeometry()

while fit.nextFeature(selFeat):
@@ -156,7 +156,7 @@ def processAlgorithm(self, parameters, context, feedback):

selGeom = selFeat.geometry()

if engine.intersects(selGeom.geometry()):
if engine.intersects(selGeom.constGet()):
# We have a candidate
iGeom = geom2Eliminate.intersection(selGeom)

@@ -89,11 +89,11 @@ def processAlgorithm(self, parameters, context, feedback):
def extractAsSingleSegments(self, geom):
segments = []
if geom.isMultipart():
for part in range(geom.geometry().numGeometries()):
segments.extend(self.getPolylineAsSingleSegments(geom.geometry().geometryN(part)))
for part in range(geom.constGet().numGeometries()):
segments.extend(self.getPolylineAsSingleSegments(geom.constGet().geometryN(part)))
else:
segments.extend(self.getPolylineAsSingleSegments(
geom.geometry()))
geom.constGet()))
return segments

def getPolylineAsSingleSegments(self, polyline):
@@ -155,7 +155,7 @@ def processAlgorithm(self, parameters, context, feedback):
def point_attributes(self, geometry):
pt = None
if not geometry.isMultipart():
pt = geometry.geometry()
pt = geometry.constGet()
else:
if geometry.numGeometries() > 0:
pt = geometry.geometryN(0)
@@ -99,7 +99,7 @@ def processAlgorithm(self, parameters, context, feedback):
sink.addFeature(f, QgsFeatureSink.FastInsert)
else:
i = 0
for part in input_geometry.geometry().coordinateSequence():
for part in input_geometry.constGet().coordinateSequence():
for ring in part:
if feedback.isCanceled():
break
@@ -104,7 +104,7 @@ def processAlgorithm(self, parameters, context, feedback):
if not input_geometry:
sink.addFeature(f, QgsFeatureSink.FastInsert)
else:
total_nodes = input_geometry.geometry().nCoordinates()
total_nodes = input_geometry.constGet().nCoordinates()

for node in indices:
if node < 0:
@@ -95,7 +95,7 @@ def processAlgorithm(self, parameters, context, feedback):
fields, QgsWkbTypes.NoGeometry, QgsCoordinateReferenceSystem())

# make intersection tests nice and fast
engine = QgsGeometry.createGeometryEngine(target_geom.geometry())
engine = QgsGeometry.createGeometryEngine(target_geom.constGet())
engine.prepareGeometry()

layer_bounds = QgsGeometry.fromRect(source.sourceExtent())
@@ -121,7 +121,7 @@ def processAlgorithm(self, parameters, context, feedback):
except:
continue

if engine.intersects(transformed_bounds.geometry()):
if engine.intersects(transformed_bounds.constGet()):
feedback.pushInfo(self.tr('Found candidate CRS: {}').format(candidate_crs.authid()))
f = QgsFeature(fields)
f.setAttributes([candidate_crs.authid()])
@@ -151,7 +151,7 @@ def convertToNodes(self, geom):
mp = QgsMultiPointV2()
# TODO: mega inefficient - needs rework when geometry iterators land
# (but at least it doesn't lose Z/M values)
for g in geom.geometry().coordinateSequence():
for g in geom.constGet().coordinateSequence():
for r in g:
for p in r:
mp.addGeometry(p)
@@ -170,7 +170,7 @@ def convertToLineStrings(self, geom):
else:
# polygons to lines
# we just use the boundary here - that consists of all rings in the (multi)polygon
boundary = QgsGeometry(geom.geometry().boundary())
boundary = QgsGeometry(geom.constGet().boundary())
# boundary will be multipart
return boundary.asGeometryCollection()

@@ -184,23 +184,23 @@ def convertToMultiLineStrings(self, geom):
else:
# line to multiLine
ml = QgsMultiLineString()
ml.addGeometry(geom.geometry().clone())
ml.addGeometry(geom.constGet().clone())
return [QgsGeometry(ml)]
else:
# polygons to multilinestring
# we just use the boundary here - that consists of all rings in the (multi)polygon
return [QgsGeometry(geom.geometry().boundary())]
return [QgsGeometry(geom.constGet().boundary())]

def convertToPolygon(self, geom):
if QgsWkbTypes.geometryType(geom.wkbType()) == QgsWkbTypes.PointGeometry and geom.geometry().nCoordinates() < 3:
if QgsWkbTypes.geometryType(geom.wkbType()) == QgsWkbTypes.PointGeometry and geom.constGet().nCoordinates() < 3:
raise QgsProcessingException(
self.tr('Cannot convert from Point to Polygon').format(QgsWkbTypes.displayString(geom.wkbType())))
elif QgsWkbTypes.geometryType(geom.wkbType()) == QgsWkbTypes.PointGeometry:
# multipoint with at least 3 points
# TODO: mega inefficient - needs rework when geometry iterators land
# (but at least it doesn't lose Z/M values)
points = []
for g in geom.geometry().coordinateSequence():
for g in geom.constGet().coordinateSequence():
for r in g:
for p in r:
points.append(p)
@@ -212,17 +212,17 @@ def convertToPolygon(self, geom):
elif QgsWkbTypes.geometryType(geom.wkbType()) == QgsWkbTypes.LineGeometry:
if QgsWkbTypes.isMultiType(geom):
parts = []
for i in range(geom.geometry().numGeometries()):
for i in range(geom.constGet().numGeometries()):
p = QgsPolygonV2()
linestring = geom.geometry().geometryN(i).clone()
linestring = geom.constGet().geometryN(i).clone()
linestring.close()
p.setExteriorRing(linestring)
parts.append(QgsGeometry(p))
return QgsGeometry.collectGeometry(parts)
else:
# linestring to polygon
p = QgsPolygonV2()
linestring = geom.geometry().clone()
linestring = geom.constGet().clone()
linestring.close()
p.setExteriorRing(linestring)
return [QgsGeometry(p)]
@@ -152,19 +152,19 @@ def processAlgorithm(self, parameters, context, feedback):
engine = None
if len(intersects) > 0:
# use prepared geometries for faster intersection tests
engine = QgsGeometry.createGeometryEngine(geom.geometry())
engine = QgsGeometry.createGeometryEngine(geom.constGet())
engine.prepareGeometry()

for featB in sourceB.getFeatures(request):
if feedback.isCanceled():
break

tmpGeom = featB.geometry()
if engine.intersects(tmpGeom.geometry()):
if engine.intersects(tmpGeom.constGet()):
out_attributes = [featA.attributes()[i] for i in field_indices_a]
out_attributes.extend([featB.attributes()[i] for i in field_indices_b])
int_geom = QgsGeometry(geom.intersection(tmpGeom))
if int_geom.wkbType() == QgsWkbTypes.Unknown or QgsWkbTypes.flatType(int_geom.geometry().wkbType()) == QgsWkbTypes.GeometryCollection:
if int_geom.wkbType() == QgsWkbTypes.Unknown or QgsWkbTypes.flatType(int_geom.wkbType()) == QgsWkbTypes.GeometryCollection:
int_com = geom.combine(tmpGeom)
int_geom = QgsGeometry()
if int_com:
@@ -101,7 +101,7 @@ def convertWkbToPolygons(self, wkb):
return multi_wkb

def convertToPolygons(self, geometry):
surfaces = self.getSurfaces(geometry.geometry())
surfaces = self.getSurfaces(geometry.constGet())
output_wkb = self.convertWkbToPolygons(geometry.wkbType())
out_geom = None
if QgsWkbTypes.flatType(output_wkb) == QgsWkbTypes.MultiPolygon:
@@ -238,7 +238,7 @@ def createFeature(self, feedback, feature_id, type, geometries, class_field=None
while True:
if feedback.isCanceled():
break
found, point = g.geometry().nextVertex(vid)
found, point = g.constGet().nextVertex(vid)
if found:
multi_point.addGeometry(point)
else:
@@ -270,8 +270,8 @@ def createFeature(self, feedback, feature_id, type, geometries, class_field=None
elif type == 3:
# convex hull
output_geometry = geometry.convexHull()
attrs.append(output_geometry.geometry().area())
attrs.append(output_geometry.geometry().perimeter())
attrs.append(output_geometry.constGet().area())
attrs.append(output_geometry.constGet().perimeter())
f = QgsFeature()
f.setAttributes(attrs)
f.setGeometry(output_geometry)
@@ -108,7 +108,7 @@ def processAlgorithm(self, parameters, context, feedback):
sink.addFeature(input_feature, QgsFeatureSink.FastInsert)
else:
if input_geometry.type == QgsWkbTypes.PolygonGeometry:
length = input_geometry.geometry().perimeter()
length = input_geometry.constGet().perimeter()
else:
length = input_geometry.length() - end_offset
current_distance = start_offset
@@ -169,7 +169,7 @@ def searchRect(p):
dy = radius * cosinusCurrentAngle

# we want to keep any existing m/z values
point = f.geometry().geometry().clone()
point = f.geometry().constGet().clone()
point.setX(old_point.x() + dx)
point.setY(old_point.y() + dy)
f.setGeometry(QgsGeometry(point))
@@ -117,7 +117,7 @@ def processAlgorithm(self, parameters, context, feedback):
(endRow, endColumn) = raster.mapToPixel(xMax, yMin, geoTransform)

# use prepared geometries for faster intersection tests
engine = QgsGeometry.createGeometryEngine(geom.geometry())
engine = QgsGeometry.createGeometryEngine(geom.constGet())
engine.prepareGeometry()

for row in range(startRow, endRow + 1):
@@ -129,7 +129,7 @@ def processAlgorithm(self, parameters, context, feedback):
output_feature = QgsFeature()
if polygon_feature.hasGeometry():
geom = polygon_feature.geometry()
engine = QgsGeometry.createGeometryEngine(geom.geometry())
engine = QgsGeometry.createGeometryEngine(geom.constGet())
engine.prepareGeometry()

count = 0
@@ -143,7 +143,7 @@ def processAlgorithm(self, parameters, context, feedback):
if feedback.isCanceled():
break

if engine.contains(point_feature.geometry().geometry()):
if engine.contains(point_feature.geometry().constGet()):
if weight_field_index >= 0:
weight = point_feature.attributes()[weight_field_index]
try:
@@ -133,7 +133,7 @@ def processAlgorithm(self, parameters, context, feedback):
if not f.hasGeometry():
continue

point = f.geometry().geometry().clone()
point = f.geometry().constGet().clone()
if group_field_index >= 0:
group = f.attributes()[group_field_index]
else:
@@ -104,13 +104,13 @@ def processAlgorithm(self, parameters, context, feedback):

if not polygons.isEmpty():
feedback.pushInfo('Saving polygons...')
total = 50.0 / polygons.geometry().numGeometries()
for i in range(polygons.geometry().numGeometries()):
total = 50.0 / polygons.constGet().numGeometries()
for i in range(polygons.constGet().numGeometries()):
if feedback.isCanceled():
break

outFeat = QgsFeature()
geom = QgsGeometry(polygons.geometry().geometryN(i).clone())
geom = QgsGeometry(polygons.constGet().geometryN(i).clone())
outFeat.setGeometry(geom)
sink.addFeature(outFeat, QgsFeatureSink.FastInsert)
feedback.setProgress(50 + int(current * total))
@@ -92,7 +92,7 @@ def convertWkbToLines(self, wkb):
return multi_wkb

def convertToLines(self, geometry):
rings = self.getRings(geometry.geometry())
rings = self.getRings(geometry.constGet())
output_wkb = self.convertWkbToLines(geometry.wkbType())
out_geom = None
if QgsWkbTypes.flatType(output_wkb) == QgsWkbTypes.MultiLineString:

0 comments on commit 55203a0

Please sign in to comment.
You can’t perform that action at this time.