Skip to content

Commit

Permalink
fix #3542
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15395 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Mar 8, 2011
1 parent 3f71eaa commit 772bd2f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions src/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -416,7 +416,7 @@ QString QgsOgrProvider::storageType() const
return ogrDriverName;
}

void QgsOgrProvider::setIgnoredFields( bool fetchGeometry, const QgsAttributeList& fetchAttributes )
void QgsOgrProvider::setRelevantFields( bool fetchGeometry, const QgsAttributeList &fetchAttributes )
{
#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800
if ( OGR_L_TestCapability( ogrLayer, OLCIgnoreFields ) )
Expand Down Expand Up @@ -447,7 +447,7 @@ bool QgsOgrProvider::featureAtId( int featureId,
bool fetchGeometry,
QgsAttributeList fetchAttributes )
{
setIgnoredFields( fetchGeometry, fetchAttributes );
setRelevantFields( fetchGeometry, fetchAttributes );

OGRFeatureH fet = OGR_L_GetFeature( ogrLayer, featureId );
if ( fet == NULL )
Expand All @@ -462,7 +462,6 @@ bool QgsOgrProvider::featureAtId( int featureId,
return false;
}


/* fetch geometry */
if ( fetchGeometry )
{
Expand Down Expand Up @@ -633,7 +632,7 @@ void QgsOgrProvider::select( QgsAttributeList fetchAttributes, QgsRectangle rect
OGR_G_DestroyGeometry( filter );
}

setIgnoredFields( fetchGeometry, fetchAttributes );
setRelevantFields( fetchGeometry, fetchAttributes );

//start with first feature
OGR_L_ResetReading( ogrLayer );
Expand Down Expand Up @@ -875,6 +874,8 @@ bool QgsOgrProvider::addFeature( QgsFeature& f )

bool QgsOgrProvider::addFeatures( QgsFeatureList & flist )
{
setRelevantFields( true, mAttributeFields.keys() );

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

clearMinMaxCache();

setIgnoredFields( true, QgsAttributeList() );
setRelevantFields( true, mAttributeFields.keys() );

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

setIgnoredFields( true, QgsAttributeList() );
setRelevantFields( true, mAttributeFields.keys() );

for ( QgsGeometryMap::iterator it = geometry_map.begin(); it != geometry_map.end(); ++it )
{
Expand Down
4 changes: 2 additions & 2 deletions src/providers/ogr/qgsogrprovider.h
Expand Up @@ -251,8 +251,8 @@ class QgsOgrProvider : public QgsVectorDataProvider
/** find out the number of features of the whole layer */
void recalculateFeatureCount();

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

private:
unsigned char *getGeometryPointer( OGRFeatureH fet );
Expand Down

0 comments on commit 772bd2f

Please sign in to comment.