Skip to content
Permalink
Browse files

[oracle] Always check bounding box intersection when using filter rect

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 Apr 21, 2018
1 parent 3921bf5 commit bbb599073f28e913457d089f5ec5a8d85d8575f6
Showing with 9 additions and 9 deletions.
  1. +9 −9 src/providers/oracle/qgsoraclefeatureiterator.cpp
@@ -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 )

0 comments on commit bbb5990

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