Respect project scale method in processing algorithms

Algorithms which use map settings now respect the current project
scale method
This commit is contained in:
Nyall Dawson 2025-03-20 11:51:52 +10:00
parent d3c6a09702
commit 9e1ba962f5
7 changed files with 13 additions and 0 deletions

View File

@ -88,6 +88,7 @@ bool QgsDxfExportAlgorithm::prepareAlgorithm( const QVariantMap &parameters, Qgs
{ {
mMapThemeStyleOverrides = context.project()->mapThemeCollection()->mapThemeStyleOverrides( mapTheme ); mMapThemeStyleOverrides = context.project()->mapThemeCollection()->mapThemeStyleOverrides( mapTheme );
} }
mScaleMethod = context.project()->scaleMethod();
return true; return true;
} }
@ -96,6 +97,7 @@ QVariantMap QgsDxfExportAlgorithm::processAlgorithm( const QVariantMap &paramete
QgsMapSettings mapSettings; QgsMapSettings mapSettings;
mapSettings.setTransformContext( context.transformContext() ); mapSettings.setTransformContext( context.transformContext() );
mapSettings.setLayerStyleOverrides( mMapThemeStyleOverrides ); mapSettings.setLayerStyleOverrides( mMapThemeStyleOverrides );
mapSettings.setScaleMethod( mScaleMethod );
QList<QgsVectorLayer *> mapLayers; QList<QgsVectorLayer *> mapLayers;

View File

@ -41,6 +41,7 @@ class QgsDxfExportAlgorithm : public QgsProcessingAlgorithm
private: private:
QMap<QString, QString> mMapThemeStyleOverrides; QMap<QString, QString> mMapThemeStyleOverrides;
Qgis::ScaleCalculationMethod mScaleMethod = Qgis::ScaleCalculationMethod::HorizontalMiddle;
}; };
///@endcond PRIVATE ///@endcond PRIVATE

View File

@ -398,6 +398,7 @@ QVariantMap QgsExtractLabelsAlgorithm::processAlgorithm( const QVariantMap &para
mapSettings.setLayers( mMapLayers ); mapSettings.setLayers( mMapLayers );
mapSettings.setLayerStyleOverrides( mMapThemeStyleOverrides ); mapSettings.setLayerStyleOverrides( mMapThemeStyleOverrides );
mapSettings.setLabelingEngineSettings( mLabelSettings ); mapSettings.setLabelingEngineSettings( mLabelSettings );
mapSettings.setScaleMethod( mScaleMethod );
//build the expression context //build the expression context
QgsExpressionContext expressionContext; QgsExpressionContext expressionContext;
@ -613,6 +614,8 @@ bool QgsExtractLabelsAlgorithm::prepareAlgorithm( const QVariantMap &parameters,
mLabelSettings.setFlag( Qgis::LabelingFlag::DrawUnplacedLabels, includeUnplaced ); mLabelSettings.setFlag( Qgis::LabelingFlag::DrawUnplacedLabels, includeUnplaced );
mLabelSettings.setFlag( Qgis::LabelingFlag::CollectUnplacedLabels, includeUnplaced ); mLabelSettings.setFlag( Qgis::LabelingFlag::CollectUnplacedLabels, includeUnplaced );
mScaleMethod = context.project()->scaleMethod();
return true; return true;
} }

View File

@ -52,6 +52,7 @@ class QgsExtractLabelsAlgorithm : public QgsProcessingAlgorithm
QMap<QString, QString> mMapThemeStyleOverrides; QMap<QString, QString> mMapThemeStyleOverrides;
QgsLabelingEngineSettings mLabelSettings; QgsLabelingEngineSettings mLabelSettings;
QgsCoordinateReferenceSystem mCrs; QgsCoordinateReferenceSystem mCrs;
Qgis::ScaleCalculationMethod mScaleMethod = Qgis::ScaleCalculationMethod::HorizontalMiddle;
}; };
///@endcond PRIVATE ///@endcond PRIVATE

View File

@ -411,6 +411,8 @@ bool QgsRasterizeAlgorithm::prepareAlgorithm( const QVariantMap &parameters, Qgs
} }
mMapSettings.setBackgroundColor( bgColor ); mMapSettings.setBackgroundColor( bgColor );
mMapSettings.setScaleMethod( context.project()->scaleMethod() );
return mMapLayers.size() > 0; return mMapLayers.size() > 0;
} }

View File

@ -200,6 +200,8 @@ bool QgsXyzTilesBaseAlgorithm::prepareAlgorithm( const QVariantMap &parameters,
feedback->pushWarning( QObject::tr( "Background color setting ignored, the JPG format only supports fully opaque colors" ) ); feedback->pushWarning( QObject::tr( "Background color setting ignored, the JPG format only supports fully opaque colors" ) );
} }
mScaleMethod = project->scaleMethod();
return true; return true;
} }
@ -241,6 +243,7 @@ void QgsXyzTilesBaseAlgorithm::startJobs()
settings.setLayers( mLayers ); settings.setLayers( mLayers );
settings.setOutputDpi( mDpi ); settings.setOutputDpi( mDpi );
settings.setFlag( Qgis::MapSettingsFlag::Antialiasing, mAntialias ); settings.setFlag( Qgis::MapSettingsFlag::Antialiasing, mAntialias );
settings.setScaleMethod( mScaleMethod );
if ( mTileFormat == QLatin1String( "PNG" ) || mBackgroundColor.alpha() == 255 ) if ( mTileFormat == QLatin1String( "PNG" ) || mBackgroundColor.alpha() == 255 )
{ {
settings.setBackgroundColor( mBackgroundColor ); settings.setBackgroundColor( mBackgroundColor );

View File

@ -130,6 +130,7 @@ class QgsXyzTilesBaseAlgorithm : public QgsProcessingAlgorithm
QPointer<QEventLoop> mEventLoop; QPointer<QEventLoop> mEventLoop;
QList<MetaTile> mMetaTiles; QList<MetaTile> mMetaTiles;
QMap<QgsMapRendererSequentialJob *, MetaTile> mRendererJobs; QMap<QgsMapRendererSequentialJob *, MetaTile> mRendererJobs;
Qgis::ScaleCalculationMethod mScaleMethod = Qgis::ScaleCalculationMethod::HorizontalMiddle;
}; };