Skip to content

Commit

Permalink
Revert "fix(elevetion_profile): replace request.setFilterRect by `r…
Browse files Browse the repository at this point in the history
…equest.setDistanceWithin` when tolerance>0 as some providers as improved performances with setDistanceWithin"

This reverts commit ce96dee.

This commit was introduced to gain some performance when the
`tolerance` is set by using `request.setDistanceWithin` instead of
`request.setFilterRect`. However, in that case, the providers either
use `GEOS::distance` or `GEOS::distanceWithin` which is not able to
handle the Z component of a Geometry.
For example, a purely vertical line, i.e.: `LineString(X Y Z1, X Y
Z2)` will always be to an infinite distance of any geometry according
to GEOS.

In practice, this means that a purely vertical line will never be
visible in the elevation profile when the tolerance is set. Indeed,
the provider will always discard such geometry because of the usage
of `setDistanceWithin`. This issue is fixed by always using
`setFilterRect`. This might introduce a performance penalty but this
ensures that the result is always correct.
  • Loading branch information
ptitjano committed Oct 3, 2024
1 parent aeec9d5 commit 5868089
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions src/core/vector/qgsvectorlayerprofilegenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -971,14 +971,7 @@ bool QgsVectorLayerProfileGenerator::generateProfileForLines()
// get features from layer
QgsFeatureRequest request;
request.setDestinationCrs( mTargetCrs, mTransformContext );
if ( mTolerance > 0 )
{
request.setDistanceWithin( QgsGeometry( mProfileCurve->clone() ), mTolerance );
}
else
{
request.setFilterRect( mProfileCurve->boundingBox() );
}
request.setFilterRect( mProfileBufferedCurve->boundingBox() );
request.setSubsetOfAttributes( mDataDefinedProperties.referencedFields( mExpressionContext ), mFields );
request.setFeedback( mFeedback.get() );

Expand Down Expand Up @@ -1263,14 +1256,7 @@ bool QgsVectorLayerProfileGenerator::generateProfileForPolygons()
// get features from layer
QgsFeatureRequest request;
request.setDestinationCrs( mTargetCrs, mTransformContext );
if ( mTolerance > 0 )
{
request.setDistanceWithin( QgsGeometry( mProfileCurve->clone() ), mTolerance );
}
else
{
request.setFilterRect( mProfileCurve->boundingBox() );
}
request.setFilterRect( mProfileBufferedCurve->boundingBox() );
request.setSubsetOfAttributes( mDataDefinedProperties.referencedFields( mExpressionContext ), mFields );
request.setFeedback( mFeedback.get() );

Expand Down

0 comments on commit 5868089

Please sign in to comment.