Skip to content

Commit

Permalink
[oracle] Always check bounding box intersection when using filter rect
Browse files Browse the repository at this point in the history
Because oracle sdo_filter sometimes returns results outside
the given filter (depending on the spatial index), and is
only designed for use as a fast "first-pass" filter.

From the Oracle docs:

"This operator performs only a primary filter operation..

The secondary filtering operation, performed by the SDO_RELATE operator,
can be used to determine with certainty if objects interact spatially."

Instead of using SDO_RELATE we can instead just do a bounding
box intersection inside QGIS if an exact intersection is not
required.

Fixes failing provider conformance test suite for oracle provider.

(cherry-picked from f9a8d9f)
  • Loading branch information
nyalldawson committed May 24, 2018
1 parent 3921bf5 commit bbb5990
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/providers/oracle/qgsoraclefeatureiterator.cpp
Expand Up @@ -301,16 +301,16 @@ bool QgsOracleFeatureIterator::fetchFeature( QgsFeature& feature )

if (( mRequest.flags() & QgsFeatureRequest::ExactIntersect ) == 0 )
{
// couldn't use sdo_filter earlier
if ( !mSource->mHasSpatialIndex )
// even if we could use sdo_filter earlier, we still need to double-check the results
// as sdo_filter can return results outside the filter (it's only a first-pass
// filtering operation!)

// only want features which intersect with bbox
if ( !feature.geometry()->boundingBox().intersects( mRequest.filterRect() ) )
{
// only intersect with bbox
if ( !feature.geometry()->boundingBox().intersects( mRequest.filterRect() ) )
{
// skip feature that don't intersect with our rectangle
QgsDebugMsg( "no bbox intersect" );
continue;
}
// skip feature that don't intersect with our rectangle
QgsDebugMsg( "no bbox intersect" );
continue;
}
}
else if ( !mConnection->hasSpatial() || !mSource->mHasSpatialIndex )
Expand Down

0 comments on commit bbb5990

Please sign in to comment.