Skip to content

Commit 1c3cfd1

Browse files
committed
use calculation factor for scale
1 parent 3d7cc16 commit 1c3cfd1

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

python/server/auto_generated/qgsserverprojectutils.sip.in

+2
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ Returns the denominator of the default scale used in case of the scale is not gi
170170
:param project: the QGIS project
171171

172172
:return: the denominator of the scale
173+
174+
.. versionadded:: 3.8
173175
%End
174176

175177
bool wmsUseLayerIds( const QgsProject &project );

src/app/qgsprojectproperties.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -643,13 +643,13 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa
643643

644644
mWMSMaxAtlasFeaturesSpinBox->setValue( QgsProject::instance()->readNumEntry( QStringLiteral( "WMSMaxAtlasFeatures" ), QStringLiteral( "/" ), 1 ) );
645645

646+
//connect this to crs change
646647
mWMSDefaultMapUnitsPerMm = new QDoubleSpinBox();
647-
mWMSDefaultMapUnitsPerMm->setDecimals( 3 );
648+
mWMSDefaultMapUnitsPerMm->setDecimals( 4 );
649+
mWMSDefaultMapUnitsPerMm->setSingleStep( 0.001 );
648650
mWMSDefaultMapUnitsPerMm->setValue( QgsProject::instance()->readDoubleEntry( QStringLiteral( "WMSDefaultMapUnitsPerMm" ), QStringLiteral( "/" ), 1 ) );
649-
650-
//care for map units mm, km, inches etc...
651651
mWMSDefaultMapUnitScale = new QgsScaleWidget();
652-
mWMSDefaultMapUnitScale->setScale( QgsProject::instance()->readDoubleEntry( QStringLiteral( "WMSDefaultMapUnitsPerMm" ), QStringLiteral( "/" ), 1 ) * 1000 );
652+
mWMSDefaultMapUnitScale->setScale( QgsProject::instance()->readDoubleEntry( QStringLiteral( "WMSDefaultMapUnitsPerMm" ), QStringLiteral( "/" ), 1 ) * QgsUnitTypes::fromUnitToUnitFactor( QgsProject::instance()->crs().mapUnits(), QgsUnitTypes::DistanceMillimeters ) );
653653

654654
if ( QgsProject::instance()->crs().isGeographic() )
655655
{
@@ -1324,7 +1324,7 @@ void QgsProjectProperties::apply()
13241324
}
13251325
else
13261326
{
1327-
defaultMapUnitsPerMm = mWMSDefaultMapUnitScale->scale() / 1000;
1327+
defaultMapUnitsPerMm = mWMSDefaultMapUnitScale->scale() / QgsUnitTypes::fromUnitToUnitFactor( QgsProject::instance()->crs().mapUnits(), QgsUnitTypes::DistanceMillimeters );
13281328
}
13291329

13301330
QgsProject::instance()->writeEntry( QStringLiteral( "WMSDefaultMapUnitsPerMm" ), QStringLiteral( "/" ), defaultMapUnitsPerMm );

src/server/qgsserverprojectutils.h

+1
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ namespace QgsServerProjectUtils
158158
* Returns the denominator of the default scale used in case of the scale is not given
159159
* \param project the QGIS project
160160
* \return the denominator of the scale
161+
* \since QGIS 3.8
161162
*/
162163
SERVER_EXPORT double wmsDefaultMapUnitsPerMm( const QgsProject &project );
163164

0 commit comments

Comments
 (0)