[QGIS Commit] r12340 - in trunk/qgis: python/core src/app src/core src/providers/ogr

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sun Dec 6 05:46:29 EST 2009


Author: mhugent
Date: 2009-12-06 05:46:28 -0500 (Sun, 06 Dec 2009)
New Revision: 12340

Modified:
   trunk/qgis/python/core/qgsvectordataprovider.sip
   trunk/qgis/src/app/qgisapp.cpp
   trunk/qgis/src/core/qgsvectordataprovider.h
   trunk/qgis/src/providers/ogr/qgsogrprovider.h
Log:
Fix for bug 2188. Provider has the possibility to announce that it handles geometry type handling not very strict, e.g. inserting multipolygon in polygon layers

Modified: trunk/qgis/python/core/qgsvectordataprovider.sip
===================================================================
--- trunk/qgis/python/core/qgsvectordataprovider.sip	2009-12-05 17:04:44 UTC (rev 12339)
+++ trunk/qgis/python/core/qgsvectordataprovider.sip	2009-12-06 10:46:28 UTC (rev 12340)
@@ -275,4 +275,8 @@
        */
       void enableGeometrylessFeatures(bool fetch);
 
+      /** Returns true if the provider is strict about the type of inserted features
+          (e.g. no multipolygon in a polygon layer)
+          @note: added in version 1.4*/
+      bool doesStrictFeatureTypeCheck() const;
 };

Modified: trunk/qgis/src/app/qgisapp.cpp
===================================================================
--- trunk/qgis/src/app/qgisapp.cpp	2009-12-05 17:04:44 UTC (rev 12339)
+++ trunk/qgis/src/app/qgisapp.cpp	2009-12-06 10:46:28 UTC (rev 12340)
@@ -4332,6 +4332,13 @@
     return;
   }
 
+  QgsVectorDataProvider* dp = vl->dataProvider();
+  bool providerChecksTypeStrictly = true;
+  if ( dp )
+  {
+    providerChecksTypeStrictly = dp->doesStrictFeatureTypeCheck();
+  }
+
   //get selected feature ids (as a QSet<int> )
   const QgsFeatureIds& featureIdSet = vl->selectedFeaturesIds();
   if ( featureIdSet.size() < 2 )
@@ -4351,7 +4358,7 @@
   //make a first geometry union and notify the user straight away if the union geometry type does not match the layer one
   QGis::WkbType originalType = vl->wkbType();
   QGis::WkbType newType = unionGeom->wkbType();
-  if ( unionGeom->wkbType() != vl->wkbType() )
+  if ( providerChecksTypeStrictly && unionGeom->wkbType() != vl->wkbType() )
   {
     QMessageBox::critical( 0, "Union operation canceled", tr( "The union operation would result in a geometry type that is not compatible with the current layer and therefore is canceled" ) );
     delete unionGeom;
@@ -4387,7 +4394,7 @@
 
     originalType = vl->wkbType();
     newType = unionGeom->wkbType();
-    if ( unionGeom->wkbType() != vl->wkbType() )
+    if ( providerChecksTypeStrictly && unionGeom->wkbType() != vl->wkbType() )
     {
       QMessageBox::critical( 0, "Union operation canceled", tr( "The union operation would result in a geometry type that is not compatible with the current layer and therefore is canceled" ) );
       delete unionGeom;

Modified: trunk/qgis/src/core/qgsvectordataprovider.h
===================================================================
--- trunk/qgis/src/core/qgsvectordataprovider.h	2009-12-05 17:04:44 UTC (rev 12339)
+++ trunk/qgis/src/core/qgsvectordataprovider.h	2009-12-06 10:46:28 UTC (rev 12340)
@@ -71,7 +71,7 @@
       /** DEPRECATED - do not use */
       RandomSelectGeometryAtId =     1 << 10,
       /** DEPRECATED - do not use */
-      SequentialSelectGeometryAtId = 1 << 11
+      SequentialSelectGeometryAtId = 1 << 11,
     };
 
     /** bitmask of all provider's editing capabilities */
@@ -343,6 +343,11 @@
      */
     const QMap<QString, QVariant::Type> &supportedNativeTypes() const;
 
+    /** Returns true if the provider is strict about the type of inserted features
+          (e.g. no multipolygon in a polygon layer)
+          @note: added in version 1.4*/
+    virtual bool doesStrictFeatureTypeCheck() const { return true;}
+
   protected:
     QVariant convertValue( QVariant::Type type, QString value );
 

Modified: trunk/qgis/src/providers/ogr/qgsogrprovider.h
===================================================================
--- trunk/qgis/src/providers/ogr/qgsogrprovider.h	2009-12-05 17:04:44 UTC (rev 12339)
+++ trunk/qgis/src/providers/ogr/qgsogrprovider.h	2009-12-06 10:46:28 UTC (rev 12340)
@@ -233,6 +233,11 @@
      */
     QString description() const;
 
+    /** Returns true if the provider is strict about the type of inserted features
+          (e.g. no multipolygon in a polygon layer)
+          @note: added in version 1.4*/
+    virtual bool doesStrictFeatureTypeCheck() const { return false;}
+
   protected:
     /** loads fields from input file to member attributeFields */
     void loadFields();



More information about the QGIS-commit mailing list