Skip to content
Permalink
Browse files

ogr provider: actually only use relevant fields in feature iterator (f…

…ixes #9062)
  • Loading branch information
jef-n committed Nov 13, 2013
1 parent eabfa48 commit af73f30c27b5ee4860842d79eb59ad3b584e0965
@@ -91,7 +91,7 @@ void QgsOgrFeatureIterator::ensureRelevantFields()
{
mFetchGeometry = ( mRequest.filterType() == QgsFeatureRequest::FilterRect ) || !( mRequest.flags() & QgsFeatureRequest::NoGeometry );
QgsAttributeList attrs = ( mRequest.flags() & QgsFeatureRequest::SubsetOfAttributes ) ? mRequest.subsetOfAttributes() : P->attributeIndexes();
P->setRelevantFields( mFetchGeometry, attrs );
P->setRelevantFields( ogrLayer, mFetchGeometry, attrs );
P->mRelevantFieldsForNextFeature = true;
}

@@ -555,7 +555,7 @@ QStringList QgsOgrProvider::subLayers() const
// Count features for geometry types
QMap<OGRwkbGeometryType, int> fCount;
// TODO: avoid reading attributes, setRelevantFields cannot be called here because it is not constant
//setRelevantFields( true, QgsAttributeList() );
//setRelevantFields( ogrLayer, true, QgsAttributeList() );
OGR_L_ResetReading( layer );
OGRFeatureH fet;
while (( fet = OGR_L_GetNextFeature( layer ) ) )
@@ -714,7 +714,7 @@ QString QgsOgrProvider::storageType() const
return ogrDriverName;
}

void QgsOgrProvider::setRelevantFields( bool fetchGeometry, const QgsAttributeList &fetchAttributes )
void QgsOgrProvider::setRelevantFields( OGRLayerH ogrLayer, bool fetchGeometry, const QgsAttributeList &fetchAttributes )
{
#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800
if ( OGR_L_TestCapability( ogrLayer, OLCIgnoreFields ) )
@@ -972,7 +972,7 @@ bool QgsOgrProvider::addFeature( QgsFeature& f )

bool QgsOgrProvider::addFeatures( QgsFeatureList & flist )
{
setRelevantFields( true, attributeIndexes() );
setRelevantFields( ogrLayer, true, attributeIndexes() );

bool returnvalue = true;
for ( QgsFeatureList::iterator it = flist.begin(); it != flist.end(); ++it )
@@ -1074,7 +1074,7 @@ bool QgsOgrProvider::changeAttributeValues( const QgsChangedAttributesMap & attr

clearMinMaxCache();

setRelevantFields( true, attributeIndexes() );
setRelevantFields( ogrLayer, true, attributeIndexes() );

for ( QgsChangedAttributesMap::const_iterator it = attr_map.begin(); it != attr_map.end(); ++it )
{
@@ -1170,7 +1170,7 @@ bool QgsOgrProvider::changeGeometryValues( QgsGeometryMap & geometry_map )
OGRFeatureH theOGRFeature = 0;
OGRGeometryH theNewGeometry = 0;

setRelevantFields( true, attributeIndexes() );
setRelevantFields( ogrLayer, true, attributeIndexes() );

for ( QgsGeometryMap::iterator it = geometry_map.begin(); it != geometry_map.end(); ++it )
{
@@ -2382,7 +2382,7 @@ void QgsOgrProvider::recalculateFeatureCount()
{
featuresCounted = 0;
OGR_L_ResetReading( ogrLayer );
setRelevantFields( true, QgsAttributeList() );
setRelevantFields( ogrLayer, true, QgsAttributeList() );
OGR_L_ResetReading( ogrLayer );
OGRFeatureH fet;
while (( fet = OGR_L_GetNextFeature( ogrLayer ) ) )
@@ -270,7 +270,7 @@ class QgsOgrProvider : public QgsVectorDataProvider
void recalculateFeatureCount();

/** tell OGR, which fields to fetch in nextFeature/featureAtId (ie. which not to ignore) */
void setRelevantFields( bool fetchGeometry, const QgsAttributeList& fetchAttributes );
void setRelevantFields( OGRLayerH ogrLayer, bool fetchGeometry, const QgsAttributeList& fetchAttributes );

/** convert a QgsField to work with OGR */
static bool convertField( QgsField &field, const QTextCodec &encoding );

0 comments on commit af73f30

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