Skip to content

Commit

Permalink
[mssql] Forward port more of 62af54e
Browse files Browse the repository at this point in the history
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 5503ba4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/providers/mssql/qgsmssqlfeatureiterator.cpp
Expand Up @@ -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;
}

Expand Down

0 comments on commit 5503ba4

Please sign in to comment.