@@ -716,22 +716,38 @@ bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
716716 // resize the tolerance using the change of size of an 1-BBOX from the source CoordinateSystem to the target CoordinateSystem
717717 if ( ct && !(( QgsCoordinateTransform* )ct )->isShortCircuited () )
718718 {
719- QgsPoint center = rendererContext.extent ().center ();
720- double rectSize = ct->sourceCrs ().geographicFlag () ? 0.0008983 /* ~100/(40075014/360=111319.4833) */ : 100 ;
719+ try
720+ {
721+ QgsPoint center = rendererContext.extent ().center ();
722+ double rectSize = ct->sourceCrs ().geographicFlag () ? 0.0008983 /* ~100/(40075014/360=111319.4833) */ : 100 ;
723+
724+ QgsRectangle sourceRect = QgsRectangle ( center.x (), center.y (), center.x () + rectSize, center.y () + rectSize );
725+ QgsRectangle targetRect = ct->transform ( sourceRect );
721726
722- QgsRectangle sourceRect = QgsRectangle ( center.x (), center.y (), center.x () + rectSize, center.y () + rectSize );
723- QgsRectangle targetRect = ct->transform ( sourceRect );
727+ QgsDebugMsg ( QString ( " Simplify - SourceTransformRect=%1" ).arg ( sourceRect.toString ( 16 ) ) );
728+ QgsDebugMsg ( QString ( " Simplify - TargetTransformRect=%1" ).arg ( targetRect.toString ( 16 ) ) );
729+
730+ if ( !sourceRect.isEmpty () && sourceRect.isFinite () && !targetRect.isEmpty () && targetRect.isFinite () )
731+ {
732+ QgsPoint minimumSrcPoint ( sourceRect.xMinimum (), sourceRect.yMinimum () );
733+ QgsPoint maximumSrcPoint ( sourceRect.xMaximum (), sourceRect.yMaximum () );
734+ QgsPoint minimumDstPoint ( targetRect.xMinimum (), targetRect.yMinimum () );
735+ QgsPoint maximumDstPoint ( targetRect.xMaximum (), targetRect.yMaximum () );
724736
725- QgsPoint minimumSrcPoint ( sourceRect.xMinimum (), sourceRect.yMinimum () );
726- QgsPoint maximumSrcPoint ( sourceRect.xMaximum (), sourceRect.yMaximum () );
727- QgsPoint minimumDstPoint ( targetRect.xMinimum (), targetRect.yMinimum () );
728- QgsPoint maximumDstPoint ( targetRect.xMaximum (), targetRect.yMaximum () );
737+ double sourceHypothenuse = sqrt ( minimumSrcPoint.sqrDist ( maximumSrcPoint ) );
738+ double targetHypothenuse = sqrt ( minimumDstPoint.sqrDist ( maximumDstPoint ) );
729739
730- double sourceHypothenuse = sqrt ( minimumSrcPoint. sqrDist ( maximumSrcPoint ) );
731- double targetHypothenuse = sqrt ( minimumDstPoint. sqrDist ( maximumDstPoint ) );
740+ QgsDebugMsg ( QString ( " Simplify - SourceHypothenuse=%1 " ). arg ( sourceHypothenuse ) );
741+ QgsDebugMsg ( QString ( " Simplify - TargetHypothenuse=%1 " ). arg ( targetHypothenuse ) );
732742
733- if ( targetHypothenuse != 0 )
734- map2pixelTol *= ( sourceHypothenuse / targetHypothenuse );
743+ if ( targetHypothenuse != 0 )
744+ map2pixelTol *= ( sourceHypothenuse / targetHypothenuse );
745+ }
746+ }
747+ catch ( QgsCsException &cse )
748+ {
749+ QgsMessageLog::logMessage ( tr ( " Simplify transform error caught: %1" ).arg ( cse.what () ), tr ( " CRS" ) );
750+ }
735751 }
736752
737753 QgsSimplifyMethod simplifyMethod;
0 commit comments