Skip to content

Commit baa5d90

Browse files
committed
[FEATURE] allow to configure maximum request size for WMS requests (fixes #16182)
Hardwired setting was 2000, which is still default.
1 parent 4a74176 commit baa5d90

File tree

8 files changed

+102
-43
lines changed

8 files changed

+102
-43
lines changed

python/core/raster/qgsrasterdataprovider.sip

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,10 @@ class QgsRasterDataProvider : QgsDataProvider, QgsRasterInterface
312312
static QString identifyFormatLabel( QgsRaster::IdentifyFormat format );
313313
static Capability identifyFormatToCapability( QgsRaster::IdentifyFormat format );
314314

315+
//! Step width and height for raster iterations
316+
virtual int stepWidth() const;
317+
virtual int stepHeight() const;
318+
315319
signals:
316320
/** Emit a signal to notify of the progress event.
317321
* Emitted theProgress is in percents (0.0-100.0) */

src/core/raster/qgsrasterdataprovider.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,10 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider, public QgsRast
441441
static QString identifyFormatLabel( QgsRaster::IdentifyFormat format );
442442
static Capability identifyFormatToCapability( QgsRaster::IdentifyFormat format );
443443

444+
//! Step width and height for raster iterations
445+
virtual int stepWidth() const { return 2000; }
446+
virtual int stepHeight() const { return 2000; }
447+
444448
signals:
445449

446450
/** Emit a signal to notify of the progress event.

src/core/raster/qgsrasteriterator.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,24 @@
1616
#include "qgsrasterinterface.h"
1717
#include "qgsrasterprojector.h"
1818
#include "qgsrasterviewport.h"
19+
#include "qgsrasterdataprovider.h"
1920

2021
QgsRasterIterator::QgsRasterIterator( QgsRasterInterface* input )
2122
: mInput( input )
2223
, mFeedback( nullptr )
2324
, mMaximumTileWidth( 2000 )
2425
, mMaximumTileHeight( 2000 )
2526
{
27+
for ( QgsRasterInterface *ri = input; ri; ri = ri->input() )
28+
{
29+
QgsRasterDataProvider *rdp = dynamic_cast<QgsRasterDataProvider*>( ri );
30+
if ( rdp )
31+
{
32+
mMaximumTileWidth = rdp->stepWidth();
33+
mMaximumTileHeight = rdp->stepHeight();
34+
break;
35+
}
36+
}
2637
}
2738

2839
void QgsRasterIterator::startRasterRead( int bandNumber, int nCols, int nRows, const QgsRectangle& extent, QgsRasterBlockFeedback* feedback )

src/providers/wms/qgswmscapabilities.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,14 @@ bool QgsWmsSettings::parseUri( const QString& uriString )
117117
mMaxHeight = uri.param( QStringLiteral( "maxHeight" ) ).toInt();
118118
}
119119

120+
mStepWidth = 2000;
121+
mStepHeight = 2000;
122+
if ( uri.hasParam( QStringLiteral( "stepWidth" ) ) && uri.hasParam( QStringLiteral( "stepHeight" ) ) )
123+
{
124+
mStepWidth = uri.param( QStringLiteral( "stepWidth" ) ).toInt();
125+
mStepHeight = uri.param( QStringLiteral( "stepHeight" ) ).toInt();
126+
}
127+
120128
if ( uri.hasParam( QStringLiteral( "tileMatrixSet" ) ) )
121129
{
122130
mTiled = true;

src/providers/wms/qgswmscapabilities.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,12 @@ class QgsWmsSettings
566566
int mMaxWidth;
567567
int mMaxHeight;
568568

569+
/**
570+
* Step size when iterating the layer
571+
*/
572+
int mStepWidth;
573+
int mStepHeight;
574+
569575
//! Data source URI of the WMS for this layer
570576
QString mHttpUri;
571577

src/providers/wms/qgswmsprovider.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ class QgsWmsProvider : public QgsRasterDataProvider
226226
*/
227227
static QString prepareUri( QString uri );
228228

229+
int stepWidth() const override { return mSettings.mStepWidth; }
230+
int stepHeight() const override { return mSettings.mStepHeight; }
231+
229232
//! Helper struct for tile requests
230233
struct TileRequest
231234
{
@@ -309,7 +312,6 @@ class QgsWmsProvider : public QgsRasterDataProvider
309312

310313
void parseOperationMetadata( QDomElement const &e );
311314

312-
313315
/**
314316
* \brief Calculates the combined extent of the layers selected by layersDrawn
315317
*

src/providers/wms/qgswmssourceselect.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ QgsWMSSourceSelect::QgsWMSSourceSelect( QWidget * parent, Qt::WindowFlags fl, bo
7575

7676
mTileWidth->setValidator( new QIntValidator( 0, 9999, this ) );
7777
mTileHeight->setValidator( new QIntValidator( 0, 9999, this ) );
78+
mStepWidth->setValidator( new QIntValidator( 0, 999999, this ) );
79+
mStepHeight->setValidator( new QIntValidator( 0, 999999, this ) );
7880
mFeatureCount->setValidator( new QIntValidator( 0, 9999, this ) );
7981

8082
mImageFormatGroup = new QButtonGroup;
@@ -492,6 +494,12 @@ void QgsWMSSourceSelect::addClicked()
492494
uri.setParam( QStringLiteral( "maxHeight" ), mTileHeight->text() );
493495
}
494496

497+
if ( mStepWidth->text().toInt() > 0 && mStepHeight->text().toInt() > 0 )
498+
{
499+
uri.setParam( QStringLiteral( "stepWidth" ), mStepWidth->text() );
500+
uri.setParam( QStringLiteral( "stepHeight" ), mStepHeight->text() );
501+
}
502+
495503
if ( lstTilesets->selectedItems().isEmpty() )
496504
{
497505
collectSelectedLayers( layers, styles, titles );

src/ui/qgswmssourceselectbase.ui

Lines changed: 58 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
</property>
1616
<property name="windowIcon">
1717
<iconset>
18-
<normaloff/>
19-
</iconset>
18+
<normaloff>.</normaloff>.</iconset>
2019
</property>
2120
<property name="sizeGripEnabled">
2221
<bool>true</bool>
@@ -66,12 +65,12 @@
6665
</item>
6766
<item row="1" column="0" colspan="2">
6867
<widget class="QPushButton" name="btnConnect">
69-
<property name="toolTip">
70-
<string>Connect to selected service</string>
71-
</property>
7268
<property name="enabled">
7369
<bool>false</bool>
7470
</property>
71+
<property name="toolTip">
72+
<string>Connect to selected service</string>
73+
</property>
7574
<property name="text">
7675
<string>C&amp;onnect</string>
7776
</property>
@@ -89,25 +88,25 @@
8988
</item>
9089
<item row="1" column="4">
9190
<widget class="QPushButton" name="btnEdit">
92-
<property name="toolTip">
93-
<string>Edit selected service connection</string>
94-
</property>
9591
<property name="enabled">
9692
<bool>false</bool>
9793
</property>
94+
<property name="toolTip">
95+
<string>Edit selected service connection</string>
96+
</property>
9897
<property name="text">
9998
<string>Edit</string>
10099
</property>
101100
</widget>
102101
</item>
103102
<item row="1" column="5">
104103
<widget class="QPushButton" name="btnDelete">
105-
<property name="toolTip">
106-
<string>Remove connection to selected service</string>
107-
</property>
108104
<property name="enabled">
109105
<bool>false</bool>
110106
</property>
107+
<property name="toolTip">
108+
<string>Remove connection to selected service</string>
109+
</property>
111110
<property name="text">
112111
<string>Remove</string>
113112
</property>
@@ -220,17 +219,44 @@
220219
<string>Options</string>
221220
</property>
222221
<layout class="QGridLayout">
222+
<item row="1" column="0">
223+
<widget class="QLabel" name="label_2">
224+
<property name="text">
225+
<string>Tile size</string>
226+
</property>
227+
<property name="buddy">
228+
<cstring>mTileWidth</cstring>
229+
</property>
230+
</widget>
231+
</item>
232+
<item row="5" column="0">
233+
<widget class="QCheckBox" name="mContextualLegendCheckbox">
234+
<property name="text">
235+
<string>Use contextual WMS Legend</string>
236+
</property>
237+
</widget>
238+
</item>
223239
<item row="3" column="0" colspan="2">
224-
<widget class="QLabel" name="labelCoordRefSys">
240+
<widget class="QLabel" name="label_3">
225241
<property name="text">
226-
<string>Coordinate Reference System</string>
242+
<string>Feature limit for GetFeatureInfo</string>
227243
</property>
228244
<property name="buddy">
229-
<cstring>btnChangeSpatialRefSys</cstring>
245+
<cstring>mFeatureCount</cstring>
230246
</property>
231247
</widget>
232248
</item>
249+
<item row="1" column="1">
250+
<widget class="QLineEdit" name="mTileWidth"/>
251+
</item>
233252
<item row="3" column="2">
253+
<widget class="QLineEdit" name="mFeatureCount">
254+
<property name="text">
255+
<string>10</string>
256+
</property>
257+
</widget>
258+
</item>
259+
<item row="4" column="2">
234260
<widget class="QPushButton" name="btnChangeSpatialRefSys">
235261
<property name="enabled">
236262
<bool>false</bool>
@@ -240,45 +266,34 @@
240266
</property>
241267
</widget>
242268
</item>
243-
<item row="1" column="1">
244-
<widget class="QLineEdit" name="mTileWidth"/>
245-
</item>
246-
<item row="1" column="0">
247-
<widget class="QLabel" name="label_2">
269+
<item row="4" column="0" colspan="2">
270+
<widget class="QLabel" name="labelCoordRefSys">
248271
<property name="text">
249-
<string>Tile size</string>
272+
<string>Coordinate Reference System</string>
250273
</property>
251274
<property name="buddy">
252-
<cstring>mTileWidth</cstring>
275+
<cstring>btnChangeSpatialRefSys</cstring>
253276
</property>
254277
</widget>
255278
</item>
256279
<item row="1" column="2">
257280
<widget class="QLineEdit" name="mTileHeight"/>
258281
</item>
259-
<item row="2" column="0" colspan="2">
260-
<widget class="QLabel" name="label_3">
282+
<item row="2" column="0">
283+
<widget class="QLabel" name="label_4">
261284
<property name="text">
262-
<string>Feature limit for GetFeatureInfo</string>
285+
<string>Request step size</string>
263286
</property>
264287
<property name="buddy">
265-
<cstring>mFeatureCount</cstring>
288+
<cstring>mTileWidth</cstring>
266289
</property>
267290
</widget>
268291
</item>
269-
<item row="2" column="2">
270-
<widget class="QLineEdit" name="mFeatureCount">
271-
<property name="text">
272-
<string>10</string>
273-
</property>
274-
</widget>
292+
<item row="2" column="1">
293+
<widget class="QLineEdit" name="mStepWidth"/>
275294
</item>
276-
<item row="4" column="0">
277-
<widget class="QCheckBox" name="mContextualLegendCheckbox">
278-
<property name="text">
279-
<string>Use contextual WMS Legend</string>
280-
</property>
281-
</widget>
295+
<item row="2" column="2">
296+
<widget class="QLineEdit" name="mStepHeight"/>
282297
</item>
283298
</layout>
284299
</widget>
@@ -496,19 +511,20 @@
496511
<tabstop>lstLayers</tabstop>
497512
<tabstop>mTileWidth</tabstop>
498513
<tabstop>mTileHeight</tabstop>
514+
<tabstop>mStepWidth</tabstop>
515+
<tabstop>mStepHeight</tabstop>
499516
<tabstop>mFeatureCount</tabstop>
500517
<tabstop>btnChangeSpatialRefSys</tabstop>
501518
<tabstop>mContextualLegendCheckbox</tabstop>
502-
<tabstop>mLayerUpButton</tabstop>
503-
<tabstop>mLayerDownButton</tabstop>
504-
<tabstop>mLayerOrderTreeWidget</tabstop>
519+
<tabstop>leLayerName</tabstop>
505520
<tabstop>lstTilesets</tabstop>
506521
<tabstop>leSearchTerm</tabstop>
507522
<tabstop>btnSearch</tabstop>
508523
<tabstop>tableWidgetWMSList</tabstop>
509524
<tabstop>btnAddWMS</tabstop>
510-
<tabstop>leLayerName</tabstop>
511-
<tabstop>buttonBox</tabstop>
525+
<tabstop>mLayerOrderTreeWidget</tabstop>
526+
<tabstop>mLayerDownButton</tabstop>
527+
<tabstop>mLayerUpButton</tabstop>
512528
</tabstops>
513529
<resources/>
514530
<connections>

0 commit comments

Comments
 (0)