[QGIS Commit] r12327 - in trunk/qgis: python/core src/app src/core

svn_qgis at osgeo.org svn_qgis at osgeo.org
Thu Dec 3 11:26:58 EST 2009


Author: mhugent
Date: 2009-12-03 11:26:57 -0500 (Thu, 03 Dec 2009)
New Revision: 12327

Modified:
   trunk/qgis/python/core/qgsgeometry.sip
   trunk/qgis/src/app/qgisapp.cpp
   trunk/qgis/src/core/qgsgeometry.h
Log:
Fix for merge of adjacent multipolygons, ticket #2188

Modified: trunk/qgis/python/core/qgsgeometry.sip
===================================================================
--- trunk/qgis/python/core/qgsgeometry.sip	2009-12-03 15:10:23 UTC (rev 12326)
+++ trunk/qgis/python/core/qgsgeometry.sip	2009-12-03 16:26:57 UTC (rev 12327)
@@ -309,5 +309,10 @@
       @note added in version 1.2 */
     bool deletePart( int partNum );
 
+    /**Converts single type geometry into multitype geometry
+     e.g. a polygon into a multipolygon geometry with one polygon
+    @return true in case of success and false else*/
+    bool convertToMultiType();
+
 }; // class QgsGeometry
 

Modified: trunk/qgis/src/app/qgisapp.cpp
===================================================================
--- trunk/qgis/src/app/qgisapp.cpp	2009-12-03 15:10:23 UTC (rev 12326)
+++ trunk/qgis/src/app/qgisapp.cpp	2009-12-03 16:26:57 UTC (rev 12327)
@@ -4229,6 +4229,15 @@
     }
   }
 
+  //convert unionGeom to a multipart geometry in case it is necessary to match the layer type
+  QGis::WkbType t = vl->wkbType();
+  bool layerIsMultiType = ( t == QGis::WKBMultiPoint || t == QGis::WKBMultiPoint25D || t == QGis::WKBMultiLineString \
+                            || t == QGis::WKBMultiLineString25D || t == QGis::WKBMultiPolygon || t == QGis::WKBMultiPoint25D );
+  if ( layerIsMultiType && !unionGeom->isMultipart() )
+  {
+    unionGeom->convertToMultiType();
+  }
+
   QApplication::restoreOverrideCursor();
   progress.setValue( featureList.size() );
   return unionGeom;

Modified: trunk/qgis/src/core/qgsgeometry.h
===================================================================
--- trunk/qgis/src/core/qgsgeometry.h	2009-12-03 15:10:23 UTC (rev 12326)
+++ trunk/qgis/src/core/qgsgeometry.h	2009-12-03 16:26:57 UTC (rev 12327)
@@ -348,7 +348,12 @@
       @note added in version 1.2 */
     bool deletePart( int partNum );
 
+    /**Converts single type geometry into multitype geometry
+     e.g. a polygon into a multipolygon geometry with one polygon
+    @return true in case of success and false else*/
+    bool convertToMultiType();
 
+
   private:
     // Private variables
 
@@ -410,11 +415,6 @@
                        const GEOSCoordSequence*  old_sequence,
                        GEOSCoordSequence** new_sequence );
 
-    /**Converts single type geometry into multitype geometry
-     e.g. a polygon into a multipolygon geometry with one polygon
-    @return true in case of success and false else*/
-    bool convertToMultiType();
-
     /**Translates a single vertex by dx and dy.
      @param ptr pointer to the wkb fragment containing the vertex
     @param wkbPosition position in wkb array. Is increased automatically by the function



More information about the QGIS-commit mailing list