[QGIS Commit] r10869 - trunk/qgis/src/core

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon Jun 1 09:23:32 EDT 2009


Author: mhugent
Date: 2009-06-01 09:23:31 -0400 (Mon, 01 Jun 2009)
New Revision: 10869

Modified:
   trunk/qgis/src/core/qgsgeometry.cpp
Log:
Merge linestrings together in union operation. Otherwise geos would create a multilinestring containing the linestrings

Modified: trunk/qgis/src/core/qgsgeometry.cpp
===================================================================
--- trunk/qgis/src/core/qgsgeometry.cpp	2009-06-01 10:53:53 UTC (rev 10868)
+++ trunk/qgis/src/core/qgsgeometry.cpp	2009-06-01 13:23:31 UTC (rev 10869)
@@ -5448,7 +5448,20 @@
 
   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
 }



More information about the QGIS-commit mailing list