[QGIS Commit] r11257 - in trunk/qgis/src: core providers/ogr

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon Aug 3 16:46:19 EDT 2009


Author: mhugent
Date: 2009-08-03 16:46:18 -0400 (Mon, 03 Aug 2009)
New Revision: 11257

Modified:
   trunk/qgis/src/core/qgsvectordataprovider.cpp
   trunk/qgis/src/providers/ogr/qgsogrprovider.cpp
Log:
Applied patch #1290 with modifications

Modified: trunk/qgis/src/core/qgsvectordataprovider.cpp
===================================================================
--- trunk/qgis/src/core/qgsvectordataprovider.cpp	2009-08-03 20:42:55 UTC (rev 11256)
+++ trunk/qgis/src/core/qgsvectordataprovider.cpp	2009-08-03 20:46:18 UTC (rev 11257)
@@ -28,7 +28,7 @@
 QgsVectorDataProvider::QgsVectorDataProvider( QString uri )
     : QgsDataProvider( uri ),
     mCacheMinMaxDirty( TRUE ),
-    mFetchFeaturesWithoutGeom( FALSE )
+    mFetchFeaturesWithoutGeom( TRUE )
 {
   QSettings settings;
   setEncoding( settings.value( "/UI/encoding", QString( "System" ) ).toString() );

Modified: trunk/qgis/src/providers/ogr/qgsogrprovider.cpp
===================================================================
--- trunk/qgis/src/providers/ogr/qgsogrprovider.cpp	2009-08-03 20:42:55 UTC (rev 11256)
+++ trunk/qgis/src/providers/ogr/qgsogrprovider.cpp	2009-08-03 20:46:18 UTC (rev 11257)
@@ -318,11 +318,19 @@
     return false;
 
   feature.setFeatureId( OGR_F_GetFID( fet ) );
+  // skip features without geometry
+  if ( OGR_F_GetGeometryRef( fet ) == NULL && !mFetchFeaturesWithoutGeom )
+  {
+    OGR_F_Destroy( fet );
+    return false;
+  }
 
+
   /* fetch geometry */
   if ( fetchGeometry )
   {
     OGRGeometryH geom = OGR_F_GetGeometryRef( fet );
+    // skip features without geometry
 
     // get the wkb representation
     unsigned char *wkb = new unsigned char[OGR_G_WkbSize( geom )];
@@ -337,8 +345,15 @@
     getFeatureAttribute( fet, feature, *it );
   }
 
+  if ( OGR_F_GetGeometryRef( fet ) != NULL )
+  {
+    feature.setValid( true );
+  }
+  else
+  {
+    feature.setValid( false );
+  }
   OGR_F_Destroy( fet );
-  feature.setValid( true );
   return true;
 }
 
@@ -414,8 +429,15 @@
 
   if ( fet )
   {
+    if ( OGR_F_GetGeometryRef( fet ) != NULL )
+    {
+      feature.setValid( true );
+    }
+    else
+    {
+      feature.setValid( false );
+    }
     OGR_F_Destroy( fet );
-    feature.setValid( true );
     return true;
   }
   else



More information about the QGIS-commit mailing list