Skip to content

Commit f9a8d9f

Browse files
committedMay 3, 2018
[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 2d7632f)
1 parent fb16dab commit f9a8d9f

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed
 

‎src/providers/oracle/qgsoraclefeatureiterator.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -305,22 +305,22 @@ bool QgsOracleFeatureIterator::fetchFeature( QgsFeature &feature )
305305
{
306306
if ( !feature.hasGeometry() )
307307
{
308-
QgsDebugMsg( QStringLiteral( "no geometry to intersect" ) );
308+
QgsDebugMsgLevel( QStringLiteral( "no geometry to intersect" ), 4 );
309309
continue;
310310
}
311311

312312
if ( ( mRequest.flags() & QgsFeatureRequest::ExactIntersect ) == 0 )
313313
{
314-
// couldn't use sdo_filter earlier
315-
if ( !mSource->mHasSpatialIndex )
314+
// even if we could use sdo_filter earlier, we still need to double-check the results
315+
// as sdo_filter can return results outside the filter (it's only a first-pass
316+
// filtering operation!)
317+
318+
// only want features which intersect with bbox
319+
if ( !feature.geometry().boundingBox().intersects( mFilterRect ) )
316320
{
317-
// only intersect with bbox
318-
if ( !feature.geometry().boundingBox().intersects( mFilterRect ) )
319-
{
320-
// skip feature that don't intersect with our rectangle
321-
QgsDebugMsg( QStringLiteral( "no bbox intersect" ) );
322-
continue;
323-
}
321+
// skip feature that don't intersect with our rectangle
322+
QgsDebugMsgLevel( QStringLiteral( "no bbox intersect" ), 4 );
323+
continue;
324324
}
325325
}
326326
else if ( !mConnection->hasSpatial() || !mSource->mHasSpatialIndex )
@@ -329,7 +329,7 @@ bool QgsOracleFeatureIterator::fetchFeature( QgsFeature &feature )
329329
if ( !feature.geometry().intersects( mFilterRect ) )
330330
{
331331
// skip feature that don't intersect with our rectangle
332-
QgsDebugMsg( QStringLiteral( "no exact intersect" ) );
332+
QgsDebugMsgLevel( QStringLiteral( "no exact intersect" ), 4 );
333333
continue;
334334
}
335335
}

0 commit comments

Comments
 (0)
Please sign in to comment.