Skip to content

Commit

Permalink
Fix collecting Triangle geometry types
Browse files Browse the repository at this point in the history
Fixes #36638
  • Loading branch information
nyalldawson committed Jun 10, 2020
1 parent d81f498 commit df46fba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/core/geometry/qgsgeometryeditutils.cpp
Expand Up @@ -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() );
Expand Down
8 changes: 8 additions & 0 deletions tests/src/python/test_qgsgeometry.py
Expand Up @@ -34,6 +34,7 @@
QgsCoordinateTransform,
QgsRectangle,
QgsWkbTypes,
QgsTriangle,
QgsRenderChecker,
QgsCoordinateReferenceSystem,
QgsProject
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit df46fba

Please sign in to comment.