Skip to content

Commit cf91c09

Browse files
committedMay 21, 2019
Fix rendering polys/lines with reprojection errors under proj 6
1 parent a5e72c2 commit cf91c09

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed
 

‎src/core/qgscoordinatetransform.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,15 +346,15 @@ void QgsCoordinateTransform::transformPolygon( QPolygonF &poly, TransformDirecti
346346
polyData++;
347347
}
348348

349+
QString err;
349350
try
350351
{
351352
transformCoords( nVertices, x.data(), y.data(), z.data(), direction );
352353
}
353-
catch ( const QgsCsException & )
354+
catch ( const QgsCsException &e )
354355
{
355-
// rethrow the exception
356-
QgsDebugMsg( QStringLiteral( "rethrowing exception" ) );
357-
throw;
356+
// record the exception, but don't rethrow it until we've recorded the coordinates we *could* transform
357+
err = e.what();
358358
}
359359

360360
QPointF *destPoint = poly.data();
@@ -366,6 +366,10 @@ void QgsCoordinateTransform::transformPolygon( QPolygonF &poly, TransformDirecti
366366
destPoint->ry() = *srcY++;
367367
destPoint++;
368368
}
369+
370+
// rethrow the exception
371+
if ( !err.isEmpty() )
372+
throw QgsCsException( err );
369373
}
370374

371375
void QgsCoordinateTransform::transformInPlace(

‎src/core/symbology/qgssymbol.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,14 @@ QPolygonF QgsSymbol::_getLineString( QgsRenderContext &context, const QgsCurve &
124124
//transform the QPolygonF to screen coordinates
125125
if ( ct.isValid() )
126126
{
127-
ct.transformPolygon( pts );
127+
try
128+
{
129+
ct.transformPolygon( pts );
130+
}
131+
catch ( QgsCsException & )
132+
{
133+
// we don't abort the rendering here, instead we remove any invalid points and just plot those which ARE valid
134+
}
128135
}
129136

130137
// 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
176183
//transform the QPolygonF to screen coordinates
177184
if ( ct.isValid() )
178185
{
179-
ct.transformPolygon( poly );
186+
try
187+
{
188+
ct.transformPolygon( poly );
189+
}
190+
catch ( QgsCsException & )
191+
{
192+
// we don't abort the rendering here, instead we remove any invalid points and just plot those which ARE valid
193+
}
180194
}
181195

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

0 commit comments

Comments
 (0)
Please sign in to comment.