Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[processing] Guard QGIS from crashing due to erroneous extent / invalid CRS in XYZ creation algorithms #60199

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions src/analysis/processing/qgsalgorithmxyztiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,15 @@ bool QgsXyzTilesBaseAlgorithm::prepareAlgorithm( const QVariantMap &parameters,
QgsRectangle extent = parameterAsExtent( parameters, QStringLiteral( "EXTENT" ), context );
QgsCoordinateReferenceSystem extentCrs = parameterAsExtentCrs( parameters, QStringLiteral( "EXTENT" ), context );
QgsCoordinateTransform ct( extentCrs, project->crs(), context.transformContext() );
mExtent = ct.transformBoundingBox( extent );
try
{
mExtent = ct.transformBoundingBox( extent );
}
catch ( QgsCsException & )
{
feedback->reportError( QObject::tr( "Could not transform the extent into the project CRS" ), true );
return false;
}

mMinZoom = parameterAsInt( parameters, QStringLiteral( "ZOOM_MIN" ), context );
mMaxZoom = parameterAsInt( parameters, QStringLiteral( "ZOOM_MAX" ), context );
Expand All @@ -167,8 +175,15 @@ bool QgsXyzTilesBaseAlgorithm::prepareAlgorithm( const QVariantMap &parameters,
mMercatorCrs = QgsCoordinateReferenceSystem( "EPSG:3857" );
mSrc2Wgs = QgsCoordinateTransform( project->crs(), mWgs84Crs, context.transformContext() );
mWgs2Mercator = QgsCoordinateTransform( mWgs84Crs, mMercatorCrs, context.transformContext() );

mWgs84Extent = mSrc2Wgs.transformBoundingBox( mExtent );
try
{
mWgs84Extent = mSrc2Wgs.transformBoundingBox( mExtent );
}
catch ( QgsCsException & )
{
feedback->reportError( QObject::tr( "Could not transform the extent into WGS84" ), true );
return false;
}

if ( parameters.contains( QStringLiteral( "TILE_WIDTH" ) ) )
{
Expand Down Expand Up @@ -212,7 +227,14 @@ void QgsXyzTilesBaseAlgorithm::startJobs()
MetaTile metaTile = mMetaTiles.takeFirst();

QgsMapSettings settings;
settings.setExtent( mWgs2Mercator.transformBoundingBox( metaTile.extent() ) );
try
{
settings.setExtent( mWgs2Mercator.transformBoundingBox( metaTile.extent() ) );
}
catch ( QgsCsException & )
{
continue;
}
settings.setOutputImageFormat( QImage::Format_ARGB32_Premultiplied );
settings.setTransformContext( mTransformContext );
settings.setDestinationCrs( mMercatorCrs );
Expand Down
Loading