Skip to content
Permalink
Browse files

use calculation factor for scale

  • Loading branch information
signedav committed Apr 10, 2019
1 parent 3d7cc16 commit 1c3cfd1e136e8d61ecf6b1cacf8f2bbf93e76fc1
@@ -170,6 +170,8 @@ Returns the denominator of the default scale used in case of the scale is not gi
:param project: the QGIS project

:return: the denominator of the scale

.. versionadded:: 3.8
%End

bool wmsUseLayerIds( const QgsProject &project );
@@ -643,13 +643,13 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa

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

//connect this to crs change
mWMSDefaultMapUnitsPerMm = new QDoubleSpinBox();
mWMSDefaultMapUnitsPerMm->setDecimals( 3 );
mWMSDefaultMapUnitsPerMm->setDecimals( 4 );
mWMSDefaultMapUnitsPerMm->setSingleStep( 0.001 );
mWMSDefaultMapUnitsPerMm->setValue( QgsProject::instance()->readDoubleEntry( QStringLiteral( "WMSDefaultMapUnitsPerMm" ), QStringLiteral( "/" ), 1 ) );

//care for map units mm, km, inches etc...
mWMSDefaultMapUnitScale = new QgsScaleWidget();
mWMSDefaultMapUnitScale->setScale( QgsProject::instance()->readDoubleEntry( QStringLiteral( "WMSDefaultMapUnitsPerMm" ), QStringLiteral( "/" ), 1 ) * 1000 );
mWMSDefaultMapUnitScale->setScale( QgsProject::instance()->readDoubleEntry( QStringLiteral( "WMSDefaultMapUnitsPerMm" ), QStringLiteral( "/" ), 1 ) * QgsUnitTypes::fromUnitToUnitFactor( QgsProject::instance()->crs().mapUnits(), QgsUnitTypes::DistanceMillimeters ) );

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

QgsProject::instance()->writeEntry( QStringLiteral( "WMSDefaultMapUnitsPerMm" ), QStringLiteral( "/" ), defaultMapUnitsPerMm );
@@ -158,6 +158,7 @@ namespace QgsServerProjectUtils
* Returns the denominator of the default scale used in case of the scale is not given
* \param project the QGIS project
* \return the denominator of the scale
* \since QGIS 3.8
*/
SERVER_EXPORT double wmsDefaultMapUnitsPerMm( const QgsProject &project );

0 comments on commit 1c3cfd1

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