Skip to content

Commit

Permalink
Don't try to render non-finite points
Browse files Browse the repository at this point in the history
They occur as a result of reprojection errors, and cause a line
to be extend to the top-left of the canvas.

Fixes #9392

(cherry-picked from 454cce8)
  • Loading branch information
nyalldawson committed Mar 6, 2018
1 parent 5234212 commit 7b7f915
Show file tree
Hide file tree
Showing 4 changed files with 336 additions and 21 deletions.
14 changes: 14 additions & 0 deletions src/core/symbology/qgssymbol.cpp
Expand Up @@ -125,6 +125,13 @@ QPolygonF QgsSymbol::_getLineString( QgsRenderContext &context, const QgsCurve &
ct.transformPolygon( pts );
}

// remove non-finite points, e.g. infinite or NaN points caused by reprojecting errors
pts.erase( std::remove_if( pts.begin(), pts.end(),
[]( const QPointF point )
{
return !std::isfinite( point.x() ) || !std::isfinite( point.y() );
} ), pts.end() );

QPointF *ptr = pts.data();
for ( int i = 0; i < pts.size(); ++i, ++ptr )
{
Expand Down Expand Up @@ -161,6 +168,13 @@ QPolygonF QgsSymbol::_getPolygonRing( QgsRenderContext &context, const QgsCurve
ct.transformPolygon( poly );
}

// remove non-finite points, e.g. infinite or NaN points caused by reprojecting errors
poly.erase( std::remove_if( poly.begin(), poly.end(),
[]( const QPointF point )
{
return !std::isfinite( point.x() ) || !std::isfinite( point.y() );
} ), poly.end() );

QPointF *ptr = poly.data();
for ( int i = 0; i < poly.size(); ++i, ++ptr )
{
Expand Down

0 comments on commit 7b7f915

Please sign in to comment.