Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Possibility to restrict number of atlas features (default: 1)
  • Loading branch information
mhugent committed Jan 5, 2019
1 parent 9ed7b0d commit 2e7bf12
Show file tree
Hide file tree
Showing 6 changed files with 240 additions and 203 deletions.
2 changes: 2 additions & 0 deletions python/server/auto_generated/qgsserverprojectutils.sip.in
Expand Up @@ -154,6 +154,8 @@ Returns the quality for WMS images defined in a QGIS project.
:return: quality if defined in project, -1 otherwise.
%End

int wmsMaxAtlasFeatures( const QgsProject &project );

bool wmsUseLayerIds( const QgsProject &project );
%Docstring
Returns if layer ids are used as name in WMS.
Expand Down
5 changes: 5 additions & 0 deletions src/app/qgsprojectproperties.cpp
Expand Up @@ -637,6 +637,8 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa
mWMSImageQualitySpinBox->setValue( imageQuality );
}

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

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

Expand Down Expand Up @@ -1260,6 +1262,9 @@ void QgsProjectProperties::apply()
QgsProject::instance()->writeEntry( QStringLiteral( "WMSImageQuality" ), QStringLiteral( "/" ), imageQualityValue );
}

int maxAtlasFeatures = mWMSMaxAtlasFeaturesSpinBox->value();
QgsProject::instance()->writeEntry( QStringLiteral( "WMSMaxAtlasFeatures" ), QStringLiteral( "/" ), maxAtlasFeatures );

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 @@ -111,6 +111,11 @@ int QgsServerProjectUtils::wmsImageQuality( const QgsProject &project )
return project.readNumEntry( QStringLiteral( "WMSImageQuality" ), QStringLiteral( "/" ), -1 );
}

int QgsServerProjectUtils::wmsMaxAtlasFeatures( const QgsProject &project )
{
return project.readNumEntry( QStringLiteral( "WMSMaxAtlasFeatures" ), QStringLiteral( "/" ), 1 );
}

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

SERVER_EXPORT int wmsMaxAtlasFeatures( const QgsProject &project );

/**
* Returns if layer ids are used as name in WMS.
* \param project the QGIS project
Expand Down
5 changes: 5 additions & 0 deletions src/server/services/wms/qgswmsrenderer.cpp
Expand Up @@ -415,8 +415,13 @@ namespace QgsWms
QStringLiteral( "Wrong number of ATLAS_PK parameters" ) );
}

//number of atlas features might be restricted
int maxAtlasFeatures = QgsServerProjectUtils::wmsMaxAtlasFeatures( *mProject );
nAtlasFeatures = std::min( nAtlasFeatures, maxAtlasFeatures );

QString filterString;
int currentAtlasPk = 0;

for ( int i = 0; i < nAtlasFeatures; ++i )
{
if ( i > 0 )
Expand Down

0 comments on commit 2e7bf12

Please sign in to comment.