File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,31 @@ void QgsOgrFeatureIterator::ensureRelevantFields()
9191{
9292 mFetchGeometry = ( mRequest .filterType () == QgsFeatureRequest::FilterRect ) || !( mRequest .flags () & QgsFeatureRequest::NoGeometry );
9393 QgsAttributeList attrs = ( mRequest .flags () & QgsFeatureRequest::SubsetOfAttributes ) ? mRequest .subsetOfAttributes () : P->attributeIndexes ();
94+
95+ // Assigns to Layer managed the relevant fields of the current FeatureRequest.
96+ #if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800
97+ if ( OGR_L_TestCapability ( ogrLayer, OLCIgnoreFields ) )
98+ {
99+ QVector<const char *> ignoredFields;
100+ OGRFeatureDefnH featDefn = OGR_L_GetLayerDefn ( ogrLayer );
101+
102+ for ( int i = 0 , fieldCount = OGR_FD_GetFieldCount ( featDefn ); i < fieldCount; i++ )
103+ {
104+ if ( !attrs.contains ( i ) )
105+ {
106+ // add to ignored fields
107+ ignoredFields.append ( OGR_Fld_GetNameRef ( OGR_FD_GetFieldDefn ( featDefn, i ) ) );
108+ }
109+ }
110+
111+ if ( !mFetchGeometry ) ignoredFields.append ( " OGR_GEOMETRY" );
112+ ignoredFields.append ( " OGR_STYLE" ); // not used by QGIS
113+ ignoredFields.append ( NULL );
114+
115+ OGR_L_SetIgnoredFields ( ogrLayer, ignoredFields.data () );
116+ }
117+ #endif
118+
94119 P->setRelevantFields ( mFetchGeometry , attrs );
95120 P->mRelevantFieldsForNextFeature = true ;
96121}
You can’t perform that action at this time.
0 commit comments