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++; polyData++;
} }
QString err;
try try
{ {
transformCoords( nVertices, x.data(), y.data(), z.data(), direction ); transformCoords( nVertices, x.data(), y.data(), z.data(), direction );
} }
catch ( const QgsCsException & ) catch ( const QgsCsException &e )
{ {
// rethrow the exception // record the exception, but don't rethrow it until we've recorded the coordinates we *could* transform
QgsDebugMsg( QStringLiteral( "rethrowing exception" ) ); err = e.what();
throw;
} }
QPointF *destPoint = poly.data(); QPointF *destPoint = poly.data();
@ -366,6 +366,10 @@ void QgsCoordinateTransform::transformPolygon( QPolygonF &poly, TransformDirecti
destPoint->ry() = *srcY++; destPoint->ry() = *srcY++;
destPoint++; destPoint++;
} }
// rethrow the exception
if ( !err.isEmpty() )
throw QgsCsException( err );
} }
void QgsCoordinateTransform::transformInPlace( void QgsCoordinateTransform::transformInPlace(

View File

@ -124,7 +124,14 @@ QPolygonF QgsSymbol::_getLineString( QgsRenderContext &context, const QgsCurve &
//transform the QPolygonF to screen coordinates //transform the QPolygonF to screen coordinates
if ( ct.isValid() ) 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 // 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 //transform the QPolygonF to screen coordinates
if ( ct.isValid() ) 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 // remove non-finite points, e.g. infinite or NaN points caused by reprojecting errors