@@ -1985,6 +1985,31 @@ def testCollectGeometry(self):
1985
1985
wkt = geometry .asWkt ()
1986
1986
assert compareWkt (expwkt , wkt ), "Expected:\n %s\n Got:\n %s\n " % (expwkt , wkt )
1987
1987
1988
+ # collect some geometries which are already multipart
1989
+ geometries = [QgsGeometry .fromWkt ('LineString( 0 0, 1 1)' ), QgsGeometry .fromWkt ('MultiLineString((2 2, 3 3),(4 4, 5 5))' )]
1990
+ geometry = QgsGeometry .collectGeometry (geometries )
1991
+ expwkt = "MultiLineString ((0 0, 1 1),(2 2, 3 3),(4 4, 5 5))"
1992
+ wkt = geometry .asWkt ()
1993
+ assert compareWkt (expwkt , wkt ), "Expected:\n %s\n Got:\n %s\n " % (expwkt , wkt )
1994
+
1995
+ geometries = [QgsGeometry .fromWkt ('MultiLineString((2 2, 3 3),(4 4, 5 5))' ), QgsGeometry .fromWkt ('LineString( 0 0, 1 1)' )]
1996
+ geometry = QgsGeometry .collectGeometry (geometries )
1997
+ expwkt = "MultiLineString ((2 2, 3 3),(4 4, 5 5),(0 0, 1 1))"
1998
+ wkt = geometry .asWkt ()
1999
+ assert compareWkt (expwkt , wkt ), "Expected:\n %s\n Got:\n %s\n " % (expwkt , wkt )
2000
+
2001
+ geometries = [QgsGeometry .fromWkt ('Polygon((100 100, 101 100, 101 101, 100 100))' ), QgsGeometry .fromWkt ('MultiPolygon (((0 0, 1 0, 1 1, 0 1, 0 0)),((2 0, 3 0, 3 1, 2 1, 2 0)))' )]
2002
+ geometry = QgsGeometry .collectGeometry (geometries )
2003
+ expwkt = "MultiPolygon (((100 100, 101 100, 101 101, 100 100)),((0 0, 1 0, 1 1, 0 1, 0 0)),((2 0, 3 0, 3 1, 2 1, 2 0)))"
2004
+ wkt = geometry .asWkt ()
2005
+ assert compareWkt (expwkt , wkt ), "Expected:\n %s\n Got:\n %s\n " % (expwkt , wkt )
2006
+
2007
+ geometries = [QgsGeometry .fromWkt ('MultiPolygon (((0 0, 1 0, 1 1, 0 1, 0 0)),((2 0, 3 0, 3 1, 2 1, 2 0)))' ), QgsGeometry .fromWkt ('Polygon((100 100, 101 100, 101 101, 100 100))' )]
2008
+ geometry = QgsGeometry .collectGeometry (geometries )
2009
+ expwkt = "MultiPolygon (((0 0, 1 0, 1 1, 0 1, 0 0)),((2 0, 3 0, 3 1, 2 1, 2 0)),((100 100, 101 100, 101 101, 100 100)))"
2010
+ wkt = geometry .asWkt ()
2011
+ assert compareWkt (expwkt , wkt ), "Expected:\n %s\n Got:\n %s\n " % (expwkt , wkt )
2012
+
1988
2013
# test empty list
1989
2014
geometries = []
1990
2015
geometry = QgsGeometry .collectGeometry (geometries )
0 commit comments