Skip to content
Permalink
Browse files

Fix collecting Triangle geometry types

Fixes #36638
  • Loading branch information
nyalldawson committed Jun 10, 2020
1 parent d81f498 commit df46fba33823415b8310c986795f8c51550a0fa6
Showing with 9 additions and 0 deletions.
  1. +1 −0 src/core/geometry/qgsgeometryeditutils.cpp
  2. +8 −0 tests/src/python/test_qgsgeometry.py
@@ -138,6 +138,7 @@ QgsGeometry::OperationResult QgsGeometryEditUtils::addPart( QgsAbstractGeometry
added = geomCollection->addGeometry( poly.release() );
}
else if ( QgsWkbTypes::flatType( part->wkbType() ) == QgsWkbTypes::Polygon
|| QgsWkbTypes::flatType( part->wkbType() ) == QgsWkbTypes::Triangle
|| QgsWkbTypes::flatType( part->wkbType() ) == QgsWkbTypes::CurvePolygon )
{
added = geomCollection->addGeometry( part.release() );
@@ -34,6 +34,7 @@
QgsCoordinateTransform,
QgsRectangle,
QgsWkbTypes,
QgsTriangle,
QgsRenderChecker,
QgsCoordinateReferenceSystem,
QgsProject
@@ -2107,6 +2108,13 @@ def testCollectGeometry(self):
wkt = geometry.asWkt()
assert compareWkt(expwkt, wkt), "Expected:\n%s\nGot:\n%s\n" % (expwkt, wkt)

geometries = [QgsGeometry(QgsTriangle(QgsPoint(0, 0, 5), QgsPoint(1, 0, 6), QgsPoint(1, 1, 7))),
QgsGeometry(QgsTriangle(QgsPoint(100, 100, 9), QgsPoint(101, 100, -1), QgsPoint(101, 101, 4)))]
geometry = QgsGeometry.collectGeometry(geometries)
expwkt = "MultiPolygonZ (((0 0 5, 1 0 6, 1 1 7, 0 0 5)),((100 100 9, 101 100 -1, 101 101 4, 100 100 9)))"
wkt = geometry.asWkt()
assert compareWkt(expwkt, wkt), "Expected:\n%s\nGot:\n%s\n" % (expwkt, wkt)

# test empty list
geometries = []
geometry = QgsGeometry.collectGeometry(geometries)

0 comments on commit df46fba

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