Skip to content

Commit 2d7632f

Browse files
committedApr 23, 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.
1 parent ac7760b commit 2d7632f

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
@@ -308,22 +308,22 @@ bool QgsOracleFeatureIterator::fetchFeature( QgsFeature &feature )
308308
{
309309
if ( !feature.hasGeometry() )
310310
{
311-
QgsDebugMsg( QStringLiteral( "no geometry to intersect" ) );
311+
QgsDebugMsgLevel( QStringLiteral( "no geometry to intersect" ), 4 );
312312
continue;
313313
}
314314

315315
if ( ( mRequest.flags() & QgsFeatureRequest::ExactIntersect ) == 0 )
316316
{
317-
// couldn't use sdo_filter earlier
318-
if ( !mSource->mHasSpatialIndex )
317+
// even if we could use sdo_filter earlier, we still need to double-check the results
318+
// as sdo_filter can return results outside the filter (it's only a first-pass
319+
// filtering operation!)
320+
321+
// only want features which intersect with bbox
322+
if ( !feature.geometry().boundingBox().intersects( mFilterRect ) )
319323
{
320-
// only intersect with bbox
321-
if ( !feature.geometry().boundingBox().intersects( mFilterRect ) )
322-
{
323-
// skip feature that don't intersect with our rectangle
324-
QgsDebugMsg( QStringLiteral( "no bbox intersect" ) );
325-
continue;
326-
}
324+
// skip feature that don't intersect with our rectangle
325+
QgsDebugMsgLevel( QStringLiteral( "no bbox intersect" ), 4 );
326+
continue;
327327
}
328328
}
329329
else if ( !mConnection->hasSpatial() || !mSource->mHasSpatialIndex )
@@ -332,7 +332,7 @@ bool QgsOracleFeatureIterator::fetchFeature( QgsFeature &feature )
332332
if ( !feature.geometry().intersects( mFilterRect ) )
333333
{
334334
// skip feature that don't intersect with our rectangle
335-
QgsDebugMsg( QStringLiteral( "no exact intersect" ) );
335+
QgsDebugMsgLevel( QStringLiteral( "no exact intersect" ), 4 );
336336
continue;
337337
}
338338
}

0 commit comments

Comments
 (0)
Please sign in to comment.