diff --git a/python/PyQt6/core/auto_generated/qgsmaplayerutils.sip.in b/python/PyQt6/core/auto_generated/qgsmaplayerutils.sip.in index 062c4c4483b4..17e49d042697 100644 --- a/python/PyQt6/core/auto_generated/qgsmaplayerutils.sip.in +++ b/python/PyQt6/core/auto_generated/qgsmaplayerutils.sip.in @@ -9,6 +9,7 @@ + class QgsMapLayerUtils { %Docstring(signature="appended") diff --git a/python/core/auto_generated/qgsmaplayerutils.sip.in b/python/core/auto_generated/qgsmaplayerutils.sip.in index 062c4c4483b4..17e49d042697 100644 --- a/python/core/auto_generated/qgsmaplayerutils.sip.in +++ b/python/core/auto_generated/qgsmaplayerutils.sip.in @@ -9,6 +9,7 @@ + class QgsMapLayerUtils { %Docstring(signature="appended") diff --git a/resources/qgis_global_settings.ini b/resources/qgis_global_settings.ini index 5924a8ea7c8b..5a8d7c30cb33 100644 --- a/resources/qgis_global_settings.ini +++ b/resources/qgis_global_settings.ini @@ -48,6 +48,7 @@ xyz\items\OpenStreetMap\url=https://tile.openstreetmap.org/{z}/{x}/{y}.png xyz\items\OpenStreetMap\username= xyz\items\OpenStreetMap\zmax=19 xyz\items\OpenStreetMap\zmin=0 +xyz\items\OpenStreetMap\tile-pixel-ratio=1 xyz\items\Mapzen Global Terrain\authcfg= xyz\items\Mapzen Global Terrain\password= diff --git a/src/analysis/processing/qgsalgorithmrasterize.cpp b/src/analysis/processing/qgsalgorithmrasterize.cpp index c59031e6673a..c2883aa86c69 100644 --- a/src/analysis/processing/qgsalgorithmrasterize.cpp +++ b/src/analysis/processing/qgsalgorithmrasterize.cpp @@ -197,7 +197,7 @@ QVariantMap QgsRasterizeAlgorithm::processAlgorithm( const QVariantMap ¶mete } feedback->pushInfo( QStringLiteral( "%1" ).arg( totalTiles ) ); - if ( totalTiles > 5000 ) + if ( totalTiles > MAXIMUM_OPENSTREETMAP_TILES_FETCH ) { // Prevent bulk downloading of tiles from openstreetmap.org as per OSMF tile usage policy feedback->pushFormattedMessage( QObject::tr( "Layer %1 will be skipped as the algorithm leads to bulk downloading behavior which is prohibited by the %2OpenStreetMap Foundation tile usage policy%3" ).arg( rasterLayer->name(), QStringLiteral( "" ), QStringLiteral( "" ) ), diff --git a/src/analysis/processing/qgsalgorithmxyztiles.cpp b/src/analysis/processing/qgsalgorithmxyztiles.cpp index 3359e51bf9d1..6dcd6de69314 100644 --- a/src/analysis/processing/qgsalgorithmxyztiles.cpp +++ b/src/analysis/processing/qgsalgorithmxyztiles.cpp @@ -189,7 +189,7 @@ bool QgsXyzTilesBaseAlgorithm::prepareAlgorithm( const QVariantMap ¶meters, void QgsXyzTilesBaseAlgorithm::checkLayersUsagePolicy( QgsProcessingFeedback *feedback ) { - if ( mTotalTiles > 5000 ) + if ( mTotalTiles > MAXIMUM_OPENSTREETMAP_TILES_FETCH ) { for ( QgsMapLayer *layer : std::as_const( mLayers ) ) { diff --git a/src/core/qgsmaplayerutils.h b/src/core/qgsmaplayerutils.h index 5606cbaa9ecc..d1bfe1e60448 100644 --- a/src/core/qgsmaplayerutils.h +++ b/src/core/qgsmaplayerutils.h @@ -17,6 +17,8 @@ #ifndef QGSMAPLAYERUTILS_H #define QGSMAPLAYERUTILS_H +#define MAXIMUM_OPENSTREETMAP_TILES_FETCH 5000 + #include "qgis_sip.h" #include "qgis_core.h" #include "qgis.h" diff --git a/src/gui/qgsrasterlayersaveasdialog.cpp b/src/gui/qgsrasterlayersaveasdialog.cpp index a2a15764f450..b715f5346b54 100644 --- a/src/gui/qgsrasterlayersaveasdialog.cpp +++ b/src/gui/qgsrasterlayersaveasdialog.cpp @@ -12,10 +12,12 @@ * (at your option) any later version. * * * ***************************************************************************/ + #include "qgsapplication.h" #include "qgsgdalutils.h" #include "qgslogger.h" #include "qgscoordinatetransform.h" +#include "qgsmaplayerutils.h" #include "qgsrasterlayer.h" #include "qgsrasterlayersaveasdialog.h" #include "qgsrasterdataprovider.h" @@ -963,6 +965,21 @@ void QgsRasterLayerSaveAsDialog::accept() return; } + if ( QgsMapLayerUtils::isOpenStreetMapLayer( mRasterLayer ) ) + { + const int nbTilesWidth = std::ceil( nColumns() / 256 ); + const int nbTilesHeight = std::ceil( nRows() / 256 ); + int64_t totalTiles = static_cast( nbTilesWidth ) * nbTilesHeight; + + if ( totalTiles > MAXIMUM_OPENSTREETMAP_TILES_FETCH ) + { + QMessageBox::warning( this, tr( "Save Raster Layer" ), + tr( "The number of OpenStreetMap tiles needed to produce the raster layer is too large and will lead to bulk downloading behavior which is prohibited by the %1OpenStreetMap Foundation tile usage policy%2." ).arg( QStringLiteral( "" ), QStringLiteral( "" ) ), + QMessageBox::Ok ); + return; + } + } + if ( outputFormat() == QLatin1String( "GPKG" ) && outputLayerExists() && QMessageBox::warning( this, tr( "Save Raster Layer" ), tr( "The layer %1 already exists in the target file, and overwriting layers in GeoPackage is not supported. "