Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix rendering polys/lines with reprojection errors under proj 6
  • Loading branch information
nyalldawson committed May 21, 2019
1 parent a5e72c2 commit cf91c09
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
12 changes: 8 additions & 4 deletions src/core/qgscoordinatetransform.cpp
Expand Up @@ -346,15 +346,15 @@ void QgsCoordinateTransform::transformPolygon( QPolygonF &poly, TransformDirecti
polyData++;
}

QString err;
try
{
transformCoords( nVertices, x.data(), y.data(), z.data(), direction );
}
catch ( const QgsCsException & )
catch ( const QgsCsException &e )
{
// rethrow the exception
QgsDebugMsg( QStringLiteral( "rethrowing exception" ) );
throw;
// record the exception, but don't rethrow it until we've recorded the coordinates we *could* transform
err = e.what();
}

QPointF *destPoint = poly.data();
Expand All @@ -366,6 +366,10 @@ void QgsCoordinateTransform::transformPolygon( QPolygonF &poly, TransformDirecti
destPoint->ry() = *srcY++;
destPoint++;
}

// rethrow the exception
if ( !err.isEmpty() )
throw QgsCsException( err );
}

void QgsCoordinateTransform::transformInPlace(
Expand Down
18 changes: 16 additions & 2 deletions src/core/symbology/qgssymbol.cpp
Expand Up @@ -124,7 +124,14 @@ QPolygonF QgsSymbol::_getLineString( QgsRenderContext &context, const QgsCurve &
//transform the QPolygonF to screen coordinates
if ( ct.isValid() )
{
ct.transformPolygon( pts );
try
{
ct.transformPolygon( pts );
}
catch ( QgsCsException & )
{
// we don't abort the rendering here, instead we remove any invalid points and just plot those which ARE valid
}
}

// remove non-finite points, e.g. infinite or NaN points caused by reprojecting errors
Expand Down Expand Up @@ -176,7 +183,14 @@ QPolygonF QgsSymbol::_getPolygonRing( QgsRenderContext &context, const QgsCurve
//transform the QPolygonF to screen coordinates
if ( ct.isValid() )
{
ct.transformPolygon( poly );
try
{
ct.transformPolygon( poly );
}
catch ( QgsCsException & )
{
// we don't abort the rendering here, instead we remove any invalid points and just plot those which ARE valid
}
}

// remove non-finite points, e.g. infinite or NaN points caused by reprojecting errors
Expand Down

0 comments on commit cf91c09

Please sign in to comment.