Skip to content
Permalink
Browse files

[mssql] Forward port more of 62af54e

But avoid the inexact Filter test when we are doing an
exact intersection request

Refs #15752
  • Loading branch information
nyalldawson committed Oct 8, 2018
1 parent b792290 commit 5503ba48bb863d79b28bf23696e71a7cf22dda09
Showing with 6 additions and 2 deletions.
  1. +6 −2 src/providers/mssql/qgsmssqlfeatureiterator.cpp
@@ -145,8 +145,12 @@ void QgsMssqlFeatureIterator::BuildStatement( const QgsFeatureRequest &request )
mStatement += QStringLiteral( " WHERE " );
if ( !mDisableInvalidGeometryHandling )
mStatement += QStringLiteral( "[%1].STIsValid() = 1 AND " ).arg( mSource->mGeometryColName );
mStatement += QStringLiteral( "[%1].STIntersects([%2]::STGeomFromText('POLYGON((%3))',%4)) = 1" ).arg(
mSource->mGeometryColName, mSource->mGeometryColType, r, QString::number( mSource->mSRId ) );

// use the faster filter method only when we don't need an exact intersect test -- filter doesn't give exact
// results when the layer has a spatial index
QString test = mRequest.flags() & QgsFeatureRequest::ExactIntersect ? QStringLiteral( "STIntersects" ) : QStringLiteral( "Filter" );
mStatement += QStringLiteral( "[%1].%2([%3]::STGeomFromText('POLYGON((%4))',%5)) = 1" ).arg(
mSource->mGeometryColName, test, mSource->mGeometryColType, r, QString::number( mSource->mSRId ) );
filterAdded = true;
}

0 comments on commit 5503ba4

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