Skip to content

Commit

Permalink
[ogr] Fix combination of filterrect and filterfids ignores filterrect…
Browse files Browse the repository at this point in the history
… check
  • Loading branch information
nyalldawson committed Jun 3, 2018
1 parent 4ddf58c commit 0af5fb9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/providers/ogr/qgsogrfeatureiterator.cpp
Expand Up @@ -227,7 +227,8 @@ bool QgsOgrFeatureIterator::fetchFeatureWithId( QgsFeatureId id, QgsFeature &fea
return false;
}

readFeature( std::move( fet ), feature );
if ( !readFeature( std::move( fet ), feature ) )
return false;

feature.setValid( true );
geometryToDestinationCrs( feature, mTransform );
Expand Down Expand Up @@ -367,7 +368,7 @@ bool QgsOgrFeatureIterator::readFeature( gdal::ogr_feature_unique_ptr fet, QgsFe
feature.initAttributes( mSource->mFields.count() );
feature.setFields( mSource->mFields ); // allow name-based attribute lookups

bool useIntersect = !mRequest.filterRect().isNull() && mRequest.flags() & QgsFeatureRequest::ExactIntersect;
bool useIntersect = !mRequest.filterRect().isNull();
bool geometryTypeFilter = mSource->mOgrGeometryTypeFilter != wkbUnknown;
if ( mFetchGeometry || useIntersect || geometryTypeFilter )
{
Expand All @@ -393,7 +394,11 @@ bool QgsOgrFeatureIterator::readFeature( gdal::ogr_feature_unique_ptr fet, QgsFe
{
// OK
}
else if ( ( useIntersect && ( !feature.hasGeometry() || !feature.geometry().intersects( mFilterRect ) ) )
else if ( ( useIntersect && ( !feature.hasGeometry()
|| ( mRequest.flags() & QgsFeatureRequest::ExactIntersect && !feature.geometry().intersects( mFilterRect ) )
|| ( !( mRequest.flags() & QgsFeatureRequest::ExactIntersect ) && !feature.geometry().boundingBoxIntersects( mFilterRect ) )
)
)
|| ( geometryTypeFilter && ( !feature.hasGeometry() || QgsOgrProvider::ogrWkbSingleFlatten( ( OGRwkbGeometryType )feature.geometry().wkbType() ) != mSource->mOgrGeometryTypeFilter ) ) )
{
return false;
Expand Down

0 comments on commit 0af5fb9

Please sign in to comment.