Skip to content
Permalink
Browse files

#9062 (FIX): Set relevant fields to related layer

Fix the #9062 issue to avoid that OgrFeatureIterator always fetchs all
feature attributes
  • Loading branch information
ahuarte47 committed Nov 13, 2013
1 parent cecfff0 commit d3cd331c448a5172307ef377da7347d8b3c2675b
Showing with 25 additions and 0 deletions.
  1. +25 −0 src/providers/ogr/qgsogrfeatureiterator.cpp
@@ -91,6 +91,31 @@ void QgsOgrFeatureIterator::ensureRelevantFields()
{
mFetchGeometry = ( mRequest.filterType() == QgsFeatureRequest::FilterRect ) || !( mRequest.flags() & QgsFeatureRequest::NoGeometry );
QgsAttributeList attrs = ( mRequest.flags() & QgsFeatureRequest::SubsetOfAttributes ) ? mRequest.subsetOfAttributes() : P->attributeIndexes();

// Assigns to Layer managed the relevant fields of the current FeatureRequest.
#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800
if ( OGR_L_TestCapability( ogrLayer, OLCIgnoreFields ) )
{
QVector<const char*> ignoredFields;
OGRFeatureDefnH featDefn = OGR_L_GetLayerDefn( ogrLayer );

for ( int i = 0, fieldCount = OGR_FD_GetFieldCount( featDefn ); i < fieldCount; i++ )
{
if ( !attrs.contains( i ) )
{
// add to ignored fields
ignoredFields.append( OGR_Fld_GetNameRef( OGR_FD_GetFieldDefn( featDefn, i ) ) );
}
}

if ( !mFetchGeometry ) ignoredFields.append( "OGR_GEOMETRY" );
ignoredFields.append( "OGR_STYLE" ); // not used by QGIS
ignoredFields.append( NULL );

OGR_L_SetIgnoredFields( ogrLayer, ignoredFields.data() );
}
#endif

P->setRelevantFields( mFetchGeometry, attrs );
P->mRelevantFieldsForNextFeature = true;
}

0 comments on commit d3cd331

Please sign in to comment.
You can’t perform that action at this time.