Skip to content

Commit

Permalink
using of configured default map units per mm for legend symbols in ca…
Browse files Browse the repository at this point in the history
…se no BBOX parameter is passed
  • Loading branch information
signedav committed Apr 11, 2019
1 parent 09b8a57 commit 7ef426b
Show file tree
Hide file tree
Showing 6 changed files with 361 additions and 306 deletions.
9 changes: 9 additions & 0 deletions python/server/auto_generated/qgsserverprojectutils.sip.in
Expand Up @@ -161,6 +161,15 @@ Returns the maximum number of atlas features which can be printed in a request
:param project: the QGIS project

:return: the number of atlas features
%End

double wmsDefaultMapUnitsPerMm( const QgsProject &project );
%Docstring
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
%End

bool wmsUseLayerIds( const QgsProject &project );
Expand Down
5 changes: 5 additions & 0 deletions src/app/qgsprojectproperties.cpp
Expand Up @@ -643,6 +643,8 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa

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

mWMSDefaultMapUnitsPerMm->setValue( QgsProject::instance()->readDoubleEntry( QStringLiteral( "WMSDefaultMapUnitsPerMm" ), QStringLiteral( "/" ), 1 ) );

mWMTSUrlLineEdit->setText( QgsProject::instance()->readEntry( QStringLiteral( "WMTSUrl" ), QStringLiteral( "/" ), QString() ) );
mWMTSMinScaleLineEdit->setValue( QgsProject::instance()->readNumEntry( QStringLiteral( "WMTSMinScale" ), QStringLiteral( "/" ), 5000 ) );

Expand Down Expand Up @@ -1300,6 +1302,9 @@ void QgsProjectProperties::apply()
int maxAtlasFeatures = mWMSMaxAtlasFeaturesSpinBox->value();
QgsProject::instance()->writeEntry( QStringLiteral( "WMSMaxAtlasFeatures" ), QStringLiteral( "/" ), maxAtlasFeatures );

double defaultMapUnitsPerMm = mWMSDefaultMapUnitsPerMm->value();
QgsProject::instance()->writeEntry( QStringLiteral( "WMSDefaultMapUnitsPerMm" ), QStringLiteral( "/" ), defaultMapUnitsPerMm );

QgsProject::instance()->writeEntry( QStringLiteral( "WMTSUrl" ), QStringLiteral( "/" ), mWMTSUrlLineEdit->text() );
QgsProject::instance()->writeEntry( QStringLiteral( "WMTSMinScale" ), QStringLiteral( "/" ), mWMTSMinScaleLineEdit->value() );
bool wmtsProject = false;
Expand Down
5 changes: 5 additions & 0 deletions src/server/qgsserverprojectutils.cpp
Expand Up @@ -116,6 +116,11 @@ int QgsServerProjectUtils::wmsMaxAtlasFeatures( const QgsProject &project )
return project.readNumEntry( QStringLiteral( "WMSMaxAtlasFeatures" ), QStringLiteral( "/" ), 1 );
}

double QgsServerProjectUtils::wmsDefaultMapUnitsPerMm( const QgsProject &project )
{
return project.readDoubleEntry( QStringLiteral( "WMSDefaultMapUnitsPerMm" ), QStringLiteral( "/" ), 1 );
}

bool QgsServerProjectUtils::wmsInfoFormatSia2045( const QgsProject &project )
{
QString sia2045 = project.readEntry( QStringLiteral( "WMSInfoFormatSIA2045" ), QStringLiteral( "/" ), "" );
Expand Down
7 changes: 7 additions & 0 deletions src/server/qgsserverprojectutils.h
Expand Up @@ -154,6 +154,13 @@ namespace QgsServerProjectUtils
*/
SERVER_EXPORT int wmsMaxAtlasFeatures( const QgsProject &project );

/**
* 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
*/
SERVER_EXPORT double wmsDefaultMapUnitsPerMm( const QgsProject &project );

/**
* Returns if layer ids are used as name in WMS.
* \param project the QGIS project
Expand Down
7 changes: 6 additions & 1 deletion src/server/services/wms/qgswmsrenderer.cpp
Expand Up @@ -117,7 +117,7 @@ namespace QgsWms
QList<QgsMapLayer *> layers = mContext.layersToRender();
configureLayers( layers );

// getting scale from bbox
// getting scale from bbox or default size
QgsLegendSettings settings = mWmsParameters.legendSettings();
if ( !mWmsParameters.bbox().isEmpty() )
{
Expand All @@ -127,6 +127,11 @@ namespace QgsWms
settings.setMapScale( mapSettings.scale() );
settings.setMapUnitsPerPixel( mapSettings.mapUnitsPerPixel() );
}
else
{
double defaultMapUnitsPerPixel = QgsServerProjectUtils::wmsDefaultMapUnitsPerMm( *mContext.project() ) / mContext.dotsPerMm();
settings.setMapUnitsPerPixel( defaultMapUnitsPerPixel );
}

// init renderer
QgsLegendRenderer renderer( &model, settings );
Expand Down

0 comments on commit 7ef426b

Please sign in to comment.