Skip to content

Commit 7ef426b

Browse files
committed
using of configured default map units per mm for legend symbols in case no BBOX parameter is passed
1 parent 09b8a57 commit 7ef426b

File tree

6 files changed

+361
-306
lines changed

6 files changed

+361
-306
lines changed

python/server/auto_generated/qgsserverprojectutils.sip.in

+9
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,15 @@ Returns the maximum number of atlas features which can be printed in a request
161161
:param project: the QGIS project
162162

163163
:return: the number of atlas features
164+
%End
165+
166+
double wmsDefaultMapUnitsPerMm( const QgsProject &project );
167+
%Docstring
168+
Returns the denominator of the default scale used in case of the scale is not given
169+
170+
:param project: the QGIS project
171+
172+
:return: the denominator of the scale
164173
%End
165174

166175
bool wmsUseLayerIds( const QgsProject &project );

src/app/qgsprojectproperties.cpp

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

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

646+
mWMSDefaultMapUnitsPerMm->setValue( QgsProject::instance()->readDoubleEntry( QStringLiteral( "WMSDefaultMapUnitsPerMm" ), QStringLiteral( "/" ), 1 ) );
647+
646648
mWMTSUrlLineEdit->setText( QgsProject::instance()->readEntry( QStringLiteral( "WMTSUrl" ), QStringLiteral( "/" ), QString() ) );
647649
mWMTSMinScaleLineEdit->setValue( QgsProject::instance()->readNumEntry( QStringLiteral( "WMTSMinScale" ), QStringLiteral( "/" ), 5000 ) );
648650

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

1305+
double defaultMapUnitsPerMm = mWMSDefaultMapUnitsPerMm->value();
1306+
QgsProject::instance()->writeEntry( QStringLiteral( "WMSDefaultMapUnitsPerMm" ), QStringLiteral( "/" ), defaultMapUnitsPerMm );
1307+
13031308
QgsProject::instance()->writeEntry( QStringLiteral( "WMTSUrl" ), QStringLiteral( "/" ), mWMTSUrlLineEdit->text() );
13041309
QgsProject::instance()->writeEntry( QStringLiteral( "WMTSMinScale" ), QStringLiteral( "/" ), mWMTSMinScaleLineEdit->value() );
13051310
bool wmtsProject = false;

src/server/qgsserverprojectutils.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ int QgsServerProjectUtils::wmsMaxAtlasFeatures( const QgsProject &project )
116116
return project.readNumEntry( QStringLiteral( "WMSMaxAtlasFeatures" ), QStringLiteral( "/" ), 1 );
117117
}
118118

119+
double QgsServerProjectUtils::wmsDefaultMapUnitsPerMm( const QgsProject &project )
120+
{
121+
return project.readDoubleEntry( QStringLiteral( "WMSDefaultMapUnitsPerMm" ), QStringLiteral( "/" ), 1 );
122+
}
123+
119124
bool QgsServerProjectUtils::wmsInfoFormatSia2045( const QgsProject &project )
120125
{
121126
QString sia2045 = project.readEntry( QStringLiteral( "WMSInfoFormatSIA2045" ), QStringLiteral( "/" ), "" );

src/server/qgsserverprojectutils.h

+7
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,13 @@ namespace QgsServerProjectUtils
154154
*/
155155
SERVER_EXPORT int wmsMaxAtlasFeatures( const QgsProject &project );
156156

157+
/**
158+
* Returns the denominator of the default scale used in case of the scale is not given
159+
* \param project the QGIS project
160+
* \return the denominator of the scale
161+
*/
162+
SERVER_EXPORT double wmsDefaultMapUnitsPerMm( const QgsProject &project );
163+
157164
/**
158165
* Returns if layer ids are used as name in WMS.
159166
* \param project the QGIS project

src/server/services/wms/qgswmsrenderer.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ namespace QgsWms
117117
QList<QgsMapLayer *> layers = mContext.layersToRender();
118118
configureLayers( layers );
119119

120-
// getting scale from bbox
120+
// getting scale from bbox or default size
121121
QgsLegendSettings settings = mWmsParameters.legendSettings();
122122
if ( !mWmsParameters.bbox().isEmpty() )
123123
{
@@ -127,6 +127,11 @@ namespace QgsWms
127127
settings.setMapScale( mapSettings.scale() );
128128
settings.setMapUnitsPerPixel( mapSettings.mapUnitsPerPixel() );
129129
}
130+
else
131+
{
132+
double defaultMapUnitsPerPixel = QgsServerProjectUtils::wmsDefaultMapUnitsPerMm( *mContext.project() ) / mContext.dotsPerMm();
133+
settings.setMapUnitsPerPixel( defaultMapUnitsPerPixel );
134+
}
130135

131136
// init renderer
132137
QgsLegendRenderer renderer( &model, settings );

0 commit comments

Comments
 (0)