Skip to content

Commit a0addce

Browse files
author
mhugent
committed
Applied patch #1290 with modifications
git-svn-id: http://svn.osgeo.org/qgis/trunk@11257 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 37fef1b commit a0addce

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

src/core/qgsvectordataprovider.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
QgsVectorDataProvider::QgsVectorDataProvider( QString uri )
2929
: QgsDataProvider( uri ),
3030
mCacheMinMaxDirty( TRUE ),
31-
mFetchFeaturesWithoutGeom( FALSE )
31+
mFetchFeaturesWithoutGeom( TRUE )
3232
{
3333
QSettings settings;
3434
setEncoding( settings.value( "/UI/encoding", QString( "System" ) ).toString() );

src/providers/ogr/qgsogrprovider.cpp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,11 +318,19 @@ bool QgsOgrProvider::featureAtId( int featureId,
318318
return false;
319319

320320
feature.setFeatureId( OGR_F_GetFID( fet ) );
321+
// skip features without geometry
322+
if ( OGR_F_GetGeometryRef( fet ) == NULL && !mFetchFeaturesWithoutGeom )
323+
{
324+
OGR_F_Destroy( fet );
325+
return false;
326+
}
327+
321328

322329
/* fetch geometry */
323330
if ( fetchGeometry )
324331
{
325332
OGRGeometryH geom = OGR_F_GetGeometryRef( fet );
333+
// skip features without geometry
326334

327335
// get the wkb representation
328336
unsigned char *wkb = new unsigned char[OGR_G_WkbSize( geom )];
@@ -337,8 +345,15 @@ bool QgsOgrProvider::featureAtId( int featureId,
337345
getFeatureAttribute( fet, feature, *it );
338346
}
339347

348+
if ( OGR_F_GetGeometryRef( fet ) != NULL )
349+
{
350+
feature.setValid( true );
351+
}
352+
else
353+
{
354+
feature.setValid( false );
355+
}
340356
OGR_F_Destroy( fet );
341-
feature.setValid( true );
342357
return true;
343358
}
344359

@@ -414,8 +429,15 @@ bool QgsOgrProvider::nextFeature( QgsFeature& feature )
414429

415430
if ( fet )
416431
{
432+
if ( OGR_F_GetGeometryRef( fet ) != NULL )
433+
{
434+
feature.setValid( true );
435+
}
436+
else
437+
{
438+
feature.setValid( false );
439+
}
417440
OGR_F_Destroy( fet );
418-
feature.setValid( true );
419441
return true;
420442
}
421443
else

0 commit comments

Comments
 (0)