Skip to content

Commit

Permalink
use calculation factor for scale
Browse files Browse the repository at this point in the history
  • Loading branch information
signedav committed Apr 11, 2019
1 parent 3d7cc16 commit 1c3cfd1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions python/server/auto_generated/qgsserverprojectutils.sip.in
Expand Up @@ -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 );
Expand Down
10 changes: 5 additions & 5 deletions src/app/qgsprojectproperties.cpp
Expand Up @@ -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() )
{
Expand Down Expand Up @@ -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 );
Expand Down
1 change: 1 addition & 0 deletions src/server/qgsserverprojectutils.h
Expand Up @@ -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 );

Expand Down

0 comments on commit 1c3cfd1

Please sign in to comment.