[QGIS Commit] r9709 - trunk/qgis/src/providers/postgres

svn_qgis at osgeo.org svn_qgis at osgeo.org
Tue Nov 25 18:42:35 EST 2008


Author: wonder
Date: 2008-11-25 18:42:35 -0500 (Tue, 25 Nov 2008)
New Revision: 9709

Modified:
   trunk/qgis/src/providers/postgres/qgspostgresprovider.cpp
Log:
Allow opening layers with M dimension, but explicitly disable editation of geometries (would corrupt M dimension) and creation of new features (would keep invalid M dimension).


Modified: trunk/qgis/src/providers/postgres/qgspostgresprovider.cpp
===================================================================
--- trunk/qgis/src/providers/postgres/qgspostgresprovider.cpp	2008-11-25 23:37:13 UTC (rev 9708)
+++ trunk/qgis/src/providers/postgres/qgspostgresprovider.cpp	2008-11-25 23:42:35 UTC (rev 9709)
@@ -2524,27 +2524,27 @@
         fType = QString::fromUtf8( PQgetvalue( result, 0, 0 ) );
       }
     }
-    if ( fType == "POINT" )
+    if ( fType == "POINT" || fType == "POINTM" )
     {
       geomType = QGis::WKBPoint;
     }
-    else if ( fType == "MULTIPOINT" )
+    else if ( fType == "MULTIPOINT" || fType == "MULTIPOINTM" )
     {
       geomType = QGis::WKBMultiPoint;
     }
-    else if ( fType == "LINESTRING" )
+    else if ( fType == "LINESTRING" || fType == "LINESTRINGM" )
     {
       geomType = QGis::WKBLineString;
     }
-    else if ( fType == "MULTILINESTRING" )
+    else if ( fType == "MULTILINESTRING" || fType == "MULTILINESTRINGM" )
     {
       geomType = QGis::WKBMultiLineString;
     }
-    else if ( fType == "POLYGON" )
+    else if ( fType == "POLYGON" || fType == "POLYGONM" )
     {
       geomType = QGis::WKBPolygon;
     }
-    else if ( fType == "MULTIPOLYGON" )
+    else if ( fType == "MULTIPOLYGON" || fType == "MULTIPOLYGONM" )
     {
       geomType = QGis::WKBMultiPolygon;
     }
@@ -2565,7 +2565,18 @@
                  tr( ". The database communication log was:\n" ) );
     showMessageBox( tr( "Unable to get feature type and srid" ), log );
   }
-
+  
+  // store whether the geometry includes measure value
+  if ( fType == "POINTM" || fType == "MULTIPOINTM" ||
+       fType == "LINESTRINGM" || fType == "MULTILINESTRINGM" ||
+       fType == "POLYGONM"  || fType == "MULTIPOLYGONM" )
+  {
+    // explicitly disable adding new features and editing of geometries
+    // as this would lead to corruption of measures
+    enabledCapabilities &= ~(QgsVectorDataProvider::ChangeGeometries | QgsVectorDataProvider::AddFeatures);
+  }
+    
+    
   if ( valid )
   {
     QgsDebugMsg( "SRID is " + srid );



More information about the QGIS-commit mailing list