From 092a1bf69405a454938d786f1cc9a42c140063b8 Mon Sep 17 00:00:00 2001 From: mhugent Date: Mon, 1 Jun 2009 13:23:31 +0000 Subject: [PATCH] Merge linestrings together in union operation. Otherwise geos would create a multilinestring containing the linestrings git-svn-id: http://svn.osgeo.org/qgis/trunk@10869 c8812cc2-4d05-0410-92ff-de0c093fc19c --- src/core/qgsgeometry.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/core/qgsgeometry.cpp b/src/core/qgsgeometry.cpp index 07be88e5368..c78d099afdc 100644 --- a/src/core/qgsgeometry.cpp +++ b/src/core/qgsgeometry.cpp @@ -5448,7 +5448,20 @@ QgsGeometry* QgsGeometry::combine( QgsGeometry* geometry ) try { - return fromGeosGeom( GEOSUnion( mGeos, geometry->mGeos ) ); + GEOSGeometry* unionGeom = GEOSUnion( mGeos, geometry->mGeos ); + QGis::WkbType thisGeomType = wkbType(); + QGis::WkbType otherGeomType = geometry->wkbType(); + if( (thisGeomType == QGis::WKBLineString || thisGeomType == QGis::WKBLineString25D) \ + && (otherGeomType == QGis::WKBLineString || otherGeomType == QGis::WKBLineString25D) ) + { + GEOSGeometry* mergedGeom = GEOSLineMerge(unionGeom); + if(mergedGeom) + { + GEOSGeom_destroy(unionGeom); + unionGeom = mergedGeom; + } + } + return fromGeosGeom(unionGeom); } CATCH_GEOS( new QgsGeometry( *this ) ) //return this geometry if union not possible }