Skip to content
Permalink
Browse files

Raster renderer: fix so that raster in projected CRS is not rendered …

…in geographic CRS if the extent exceeds -180,-90,180,90 (fixes #14229)
  • Loading branch information
rouault committed Nov 14, 2017
1 parent ec9e87d commit c09c96b03e5ed6bf043145471974eede2e34bb16
Showing with 20 additions and 5 deletions.
  1. +20 −5 src/core/raster/qgsrasterlayerrenderer.cpp
@@ -91,14 +91,29 @@ QgsRasterLayerRenderer::QgsRasterLayerRenderer( QgsRasterLayer *layer, QgsRender
if ( rendererContext.coordinateTransform().isValid() )
{
QgsDebugMsgLevel( "coordinateTransform set -> project extents.", 4 );
try
if ( rendererContext.extent().xMinimum() == -DBL_MAX &&
rendererContext.extent().yMinimum() == -DBL_MAX &&
rendererContext.extent().xMaximum() == DBL_MAX &&
rendererContext.extent().yMaximum() == DBL_MAX )
{
myProjectedViewExtent = rendererContext.coordinateTransform().transformBoundingBox( rendererContext.extent() );
// We get in this situation if the view CRS is geographical and the
// extent goes beyond -180,-90,180,90. To avoid reprojection issues to the
// layer CRS, then this dummy extent is returned by QgsMapRendererJob::reprojectToLayerExtent()
// Don't try to reproject it now to view extent as this would return
// a null rectangle.
myProjectedViewExtent = rendererContext.extent();
}
catch ( QgsCsException &cs )
else
{
QgsMessageLog::logMessage( QObject::tr( "Could not reproject view extent: %1" ).arg( cs.what() ), QObject::tr( "Raster" ) );
myProjectedViewExtent.setMinimal();
try
{
myProjectedViewExtent = rendererContext.coordinateTransform().transformBoundingBox( rendererContext.extent() );
}
catch ( QgsCsException &cs )
{
QgsMessageLog::logMessage( QObject::tr( "Could not reproject view extent: %1" ).arg( cs.what() ), QObject::tr( "Raster" ) );
myProjectedViewExtent.setMinimal();
}
}

try

0 comments on commit c09c96b

Please sign in to comment.
You can’t perform that action at this time.