Fix rendering polys/lines with reprojection errors under proj 6

This commit is contained in:
Nyall Dawson 2019-05-21 21:20:32 +10:00
parent a5e72c2c33
commit cf91c09c3c
2 changed files with 24 additions and 6 deletions

View File

@ -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();
@ -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(

View File

@ -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
@ -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