Possibility to restrict number of atlas features (default: 1)

This commit is contained in:
Marco Hugentobler 2019-01-05 13:26:38 +01:00
parent 9ed7b0df42
commit 2e7bf12ee1
6 changed files with 244 additions and 207 deletions

View File

@ -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.

View File

@ -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 ) );
@ -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;

View File

@ -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( "/" ), "" );

View File

@ -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

View File

@ -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 )

View File

@ -294,7 +294,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Project home</string>
<string>&amp;Project home</string>
</property>
<property name="buddy">
<cstring>titleEdit</cstring>
@ -310,7 +310,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Save paths</string>
<string>Sa&amp;ve paths</string>
</property>
<property name="buddy">
<cstring>cbxAbsolutePath</cstring>
@ -394,7 +394,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Project file</string>
<string>Pro&amp;ject file</string>
</property>
<property name="buddy">
<cstring>titleEdit</cstring>
@ -454,7 +454,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Background color</string>
<string>Back&amp;ground color</string>
</property>
<property name="buddy">
<cstring>pbnCanvasColor</cstring>
@ -645,7 +645,7 @@
<string>Automatically sets the number of decimal places to use when displaying coordinates</string>
</property>
<property name="text">
<string>Automatic</string>
<string>A&amp;utomatic</string>
</property>
<property name="checked">
<bool>true</bool>
@ -1528,7 +1528,7 @@
<item>
<widget class="QGroupBox" name="grpPythonMacros">
<property name="title">
<string>Python Macros</string>
<string>&amp;Python Macros</string>
</property>
<property name="checkable">
<bool>true</bool>
@ -1638,7 +1638,7 @@
<item row="4" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Person</string>
<string>&amp;Person</string>
</property>
<property name="buddy">
<cstring>mWMSContactPerson</cstring>
@ -1755,7 +1755,7 @@
<item row="2" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Organization</string>
<string>Or&amp;ganization</string>
</property>
<property name="buddy">
<cstring>mWMSContactOrganization</cstring>
@ -1845,10 +1845,10 @@
<string notr="true">projowsserver</string>
</property>
<layout class="QGridLayout" name="gridLayout_13">
<item row="1" column="0">
<item row="0" column="0">
<widget class="QgsCollapsibleGroupBox" name="grpWMSExt">
<property name="title">
<string>Advertised extent</string>
<string>Ad&amp;vertised extent</string>
</property>
<property name="checkable">
<bool>true</bool>
@ -1866,7 +1866,7 @@
<item row="0" column="0">
<widget class="QLabel" name="label_16">
<property name="text">
<string>Min. X</string>
<string>Min. &amp;X</string>
</property>
<property name="buddy">
<cstring>mWMSExtMinX</cstring>
@ -1883,7 +1883,7 @@
<item row="1" column="0">
<widget class="QLabel" name="label_17">
<property name="text">
<string>Min. Y</string>
<string>Min. &amp;Y</string>
</property>
<property name="buddy">
<cstring>mWMSExtMinY</cstring>
@ -1954,10 +1954,66 @@
</layout>
</widget>
</item>
<item row="2" column="0">
<item row="0" column="1">
<widget class="QgsCollapsibleGroupBox" name="grpWMSList">
<property name="title">
<string>CRS restrictions</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="collapsed" stdset="0">
<bool>false</bool>
</property>
<property name="saveCollapsedState" stdset="0">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="1" column="0">
<widget class="QToolButton" name="pbnWMSAddSRS">
<property name="toolTip">
<string>Add new CRS</string>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/symbologyAdd.svg</normaloff>:/images/themes/default/symbologyAdd.svg</iconset>
</property>
</widget>
</item>
<item row="0" column="0" colspan="4">
<widget class="QListWidget" name="mWMSList"/>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="pbnWMSSetUsedSRS">
<property name="toolTip">
<string>Fetch all CRS's from layers</string>
</property>
<property name="text">
<string>Used</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QToolButton" name="pbnWMSRemoveSRS">
<property name="toolTip">
<string>Remove selected CRS</string>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/symbologyRemove.svg</normaloff>:/images/themes/default/symbologyRemove.svg</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QgsCollapsibleGroupBox" name="mWMSPrintLayoutGroupBox">
<property name="title">
<string>Exclude layouts</string>
<string>Excl&amp;ude layouts</string>
</property>
<property name="checkable">
<bool>true</bool>
@ -2019,7 +2075,7 @@
</layout>
</widget>
</item>
<item row="2" column="1">
<item row="1" column="1">
<widget class="QgsCollapsibleGroupBox" name="mLayerRestrictionsGroupBox">
<property name="title">
<string>Exclude layers</string>
@ -2084,189 +2140,7 @@
</layout>
</widget>
</item>
<item row="1" column="1">
<widget class="QgsCollapsibleGroupBox" name="grpWMSList">
<property name="title">
<string>CRS restrictions</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="collapsed" stdset="0">
<bool>false</bool>
</property>
<property name="saveCollapsedState" stdset="0">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="1" column="0">
<widget class="QToolButton" name="pbnWMSAddSRS">
<property name="toolTip">
<string>Add new CRS</string>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/symbologyAdd.svg</normaloff>:/images/themes/default/symbologyAdd.svg</iconset>
</property>
</widget>
</item>
<item row="0" column="0" colspan="4">
<widget class="QListWidget" name="mWMSList"/>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="pbnWMSSetUsedSRS">
<property name="toolTip">
<string>Fetch all CRS's from layers</string>
</property>
<property name="text">
<string>Used</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QToolButton" name="pbnWMSRemoveSRS">
<property name="toolTip">
<string>Remove selected CRS</string>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/symbologyRemove.svg</normaloff>:/images/themes/default/symbologyRemove.svg</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="mWmsUseLayerIDs">
<property name="text">
<string>Use layer ids as names</string>
</property>
</widget>
</item>
<item row="12" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QLabel" name="mWMSImageQualityLabel">
<property name="text">
<string>Quality for JPEG images ( 10 : smaller image - 100 : best quality )</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="mWMSImageQualitySpinBox">
<property name="minimum">
<number>10</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="singleStep">
<number>5</number>
</property>
<property name="value">
<number>90</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="mAddWktGeometryCheckBox">
<property name="text">
<string>Add geometry to feature response</string>
</property>
</widget>
</item>
<item row="11" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="1">
<widget class="QLabel" name="mMaxWidthLabel">
<property name="text">
<string>Width</string>
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>6</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="4">
<widget class="QLineEdit" name="mMaxHeightLineEdit"/>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="mMaxWidthLineEdit"/>
</item>
<item row="1" column="3">
<widget class="QLabel" name="mMaxHeightLabel">
<property name="text">
<string>Height</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="5">
<widget class="QLabel" name="label_21">
<property name="text">
<string>Maximums for GetMap request</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="9" column="0" colspan="2">
<layout class="QHBoxLayout" name="grpWMSPrecision">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>GetFeatureInfo geometry precision (decimal places)</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="mWMSPrecisionSpinBox">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>17</number>
</property>
<property name="value">
<number>8</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="10" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="mWMSUrlLabel">
<property name="text">
<string>Advertised URL</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="mWMSUrlLineEdit"/>
</item>
</layout>
</item>
<item row="4" column="0" colspan="2">
<item row="2" column="0" colspan="2">
<widget class="QgsCollapsibleGroupBox" name="mWMSInspire">
<property name="title">
<string>INSPIRE (European directive)</string>
@ -2298,7 +2172,7 @@
<item row="4" column="0" colspan="2">
<widget class="QGroupBox" name="mWMSInspireScenario2">
<property name="title">
<string>Scenario 2 - INSPIRE related fields using embedded service metadata</string>
<string>Scenario &amp;2 - INSPIRE related fields using embedded service metadata</string>
</property>
<property name="checkable">
<bool>true</bool>
@ -2347,7 +2221,7 @@
<item row="3" column="0" colspan="2">
<widget class="QGroupBox" name="mWMSInspireScenario1">
<property name="title">
<string>Scenario 1 - INSPIRE related fields using referenced external service metadata</string>
<string>Scenario &amp;1 - INSPIRE related fields using referenced external service metadata</string>
</property>
<property name="checkable">
<bool>true</bool>
@ -2398,20 +2272,164 @@
</layout>
</widget>
</item>
<item row="8" column="0">
<item row="3" column="0">
<widget class="QCheckBox" name="mWmsUseLayerIDs">
<property name="text">
<string>Use layer ids as names</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="mAddWktGeometryCheckBox">
<property name="text">
<string>Add geometry to feature response</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="mAllowRequestDefinedDataSourcesBox">
<property name="text">
<string>Allow defining datasources in server requests</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="mSegmentizeFeatureInfoGeometryCheckBox">
<property name="text">
<string>Segmentize feature info geometry</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="mAllowRequestDefinedDataSourcesBox">
<item row="7" column="0" colspan="2">
<layout class="QHBoxLayout" name="grpWMSPrecision">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Allow defining datasources in server requests</string>
<string>GetFeatureInfo geometry precision (decimal places)</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="mWMSPrecisionSpinBox">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>17</number>
</property>
<property name="value">
<number>8</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="8" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="mWMSUrlLabel">
<property name="text">
<string>Advertised URL</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="mWMSUrlLineEdit"/>
</item>
</layout>
</item>
<item row="9" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="1">
<widget class="QLabel" name="mMaxWidthLabel">
<property name="text">
<string>Width</string>
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>6</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="4">
<widget class="QLineEdit" name="mMaxHeightLineEdit"/>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="mMaxWidthLineEdit"/>
</item>
<item row="1" column="3">
<widget class="QLabel" name="mMaxHeightLabel">
<property name="text">
<string>Height</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="5">
<widget class="QLabel" name="label_21">
<property name="text">
<string>Maximums for GetMap request</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="10" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QLabel" name="mWMSImageQualityLabel">
<property name="text">
<string>Quality for JPEG images ( 10 : smaller image - 100 : best quality )</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="mWMSImageQualitySpinBox">
<property name="minimum">
<number>10</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="singleStep">
<number>5</number>
</property>
<property name="value">
<number>90</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="11" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_17">
<item>
<widget class="QLabel" name="mWMSMaxAtlasFeaturesLabel">
<property name="text">
<string>Maximum features for Atlas print requests</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="mWMSMaxAtlasFeaturesSpinBox">
<property name="value">
<number>1</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>