Skip to content

Commit

Permalink
[FEATURE] allow to configure maximum request size for WMS requests (f…
Browse files Browse the repository at this point in the history
…ixes #16182)

Hardwired setting was 2000, which is still default.
  • Loading branch information
jef-n committed Feb 21, 2017
1 parent 4a74176 commit baa5d90
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 43 deletions.
4 changes: 4 additions & 0 deletions python/core/raster/qgsrasterdataprovider.sip
Expand Up @@ -312,6 +312,10 @@ class QgsRasterDataProvider : QgsDataProvider, QgsRasterInterface
static QString identifyFormatLabel( QgsRaster::IdentifyFormat format );
static Capability identifyFormatToCapability( QgsRaster::IdentifyFormat format );

//! Step width and height for raster iterations
virtual int stepWidth() const;
virtual int stepHeight() const;

signals:
/** Emit a signal to notify of the progress event.
* Emitted theProgress is in percents (0.0-100.0) */
Expand Down
4 changes: 4 additions & 0 deletions src/core/raster/qgsrasterdataprovider.h
Expand Up @@ -441,6 +441,10 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider, public QgsRast
static QString identifyFormatLabel( QgsRaster::IdentifyFormat format );
static Capability identifyFormatToCapability( QgsRaster::IdentifyFormat format );

//! Step width and height for raster iterations
virtual int stepWidth() const { return 2000; }
virtual int stepHeight() const { return 2000; }

signals:

/** Emit a signal to notify of the progress event.
Expand Down
11 changes: 11 additions & 0 deletions src/core/raster/qgsrasteriterator.cpp
Expand Up @@ -16,13 +16,24 @@
#include "qgsrasterinterface.h"
#include "qgsrasterprojector.h"
#include "qgsrasterviewport.h"
#include "qgsrasterdataprovider.h"

QgsRasterIterator::QgsRasterIterator( QgsRasterInterface* input )
: mInput( input )
, mFeedback( nullptr )
, mMaximumTileWidth( 2000 )
, mMaximumTileHeight( 2000 )
{
for ( QgsRasterInterface *ri = input; ri; ri = ri->input() )
{
QgsRasterDataProvider *rdp = dynamic_cast<QgsRasterDataProvider*>( ri );
if ( rdp )
{
mMaximumTileWidth = rdp->stepWidth();
mMaximumTileHeight = rdp->stepHeight();
break;
}
}
}

void QgsRasterIterator::startRasterRead( int bandNumber, int nCols, int nRows, const QgsRectangle& extent, QgsRasterBlockFeedback* feedback )
Expand Down
8 changes: 8 additions & 0 deletions src/providers/wms/qgswmscapabilities.cpp
Expand Up @@ -117,6 +117,14 @@ bool QgsWmsSettings::parseUri( const QString& uriString )
mMaxHeight = uri.param( QStringLiteral( "maxHeight" ) ).toInt();
}

mStepWidth = 2000;
mStepHeight = 2000;
if ( uri.hasParam( QStringLiteral( "stepWidth" ) ) && uri.hasParam( QStringLiteral( "stepHeight" ) ) )
{
mStepWidth = uri.param( QStringLiteral( "stepWidth" ) ).toInt();
mStepHeight = uri.param( QStringLiteral( "stepHeight" ) ).toInt();
}

if ( uri.hasParam( QStringLiteral( "tileMatrixSet" ) ) )
{
mTiled = true;
Expand Down
6 changes: 6 additions & 0 deletions src/providers/wms/qgswmscapabilities.h
Expand Up @@ -566,6 +566,12 @@ class QgsWmsSettings
int mMaxWidth;
int mMaxHeight;

/**
* Step size when iterating the layer
*/
int mStepWidth;
int mStepHeight;

//! Data source URI of the WMS for this layer
QString mHttpUri;

Expand Down
4 changes: 3 additions & 1 deletion src/providers/wms/qgswmsprovider.h
Expand Up @@ -226,6 +226,9 @@ class QgsWmsProvider : public QgsRasterDataProvider
*/
static QString prepareUri( QString uri );

int stepWidth() const override { return mSettings.mStepWidth; }
int stepHeight() const override { return mSettings.mStepHeight; }

//! Helper struct for tile requests
struct TileRequest
{
Expand Down Expand Up @@ -309,7 +312,6 @@ class QgsWmsProvider : public QgsRasterDataProvider

void parseOperationMetadata( QDomElement const &e );


/**
* \brief Calculates the combined extent of the layers selected by layersDrawn
*
Expand Down
8 changes: 8 additions & 0 deletions src/providers/wms/qgswmssourceselect.cpp
Expand Up @@ -75,6 +75,8 @@ QgsWMSSourceSelect::QgsWMSSourceSelect( QWidget * parent, Qt::WindowFlags fl, bo

mTileWidth->setValidator( new QIntValidator( 0, 9999, this ) );
mTileHeight->setValidator( new QIntValidator( 0, 9999, this ) );
mStepWidth->setValidator( new QIntValidator( 0, 999999, this ) );
mStepHeight->setValidator( new QIntValidator( 0, 999999, this ) );
mFeatureCount->setValidator( new QIntValidator( 0, 9999, this ) );

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

if ( mStepWidth->text().toInt() > 0 && mStepHeight->text().toInt() > 0 )
{
uri.setParam( QStringLiteral( "stepWidth" ), mStepWidth->text() );
uri.setParam( QStringLiteral( "stepHeight" ), mStepHeight->text() );
}

if ( lstTilesets->selectedItems().isEmpty() )
{
collectSelectedLayers( layers, styles, titles );
Expand Down
100 changes: 58 additions & 42 deletions src/ui/qgswmssourceselectbase.ui
Expand Up @@ -15,8 +15,7 @@
</property>
<property name="windowIcon">
<iconset>
<normaloff/>
</iconset>
<normaloff>.</normaloff>.</iconset>
</property>
<property name="sizeGripEnabled">
<bool>true</bool>
Expand Down Expand Up @@ -66,12 +65,12 @@
</item>
<item row="1" column="0" colspan="2">
<widget class="QPushButton" name="btnConnect">
<property name="toolTip">
<string>Connect to selected service</string>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Connect to selected service</string>
</property>
<property name="text">
<string>C&amp;onnect</string>
</property>
Expand All @@ -89,25 +88,25 @@
</item>
<item row="1" column="4">
<widget class="QPushButton" name="btnEdit">
<property name="toolTip">
<string>Edit selected service connection</string>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Edit selected service connection</string>
</property>
<property name="text">
<string>Edit</string>
</property>
</widget>
</item>
<item row="1" column="5">
<widget class="QPushButton" name="btnDelete">
<property name="toolTip">
<string>Remove connection to selected service</string>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Remove connection to selected service</string>
</property>
<property name="text">
<string>Remove</string>
</property>
Expand Down Expand Up @@ -220,17 +219,44 @@
<string>Options</string>
</property>
<layout class="QGridLayout">
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Tile size</string>
</property>
<property name="buddy">
<cstring>mTileWidth</cstring>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="mContextualLegendCheckbox">
<property name="text">
<string>Use contextual WMS Legend</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="labelCoordRefSys">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Coordinate Reference System</string>
<string>Feature limit for GetFeatureInfo</string>
</property>
<property name="buddy">
<cstring>btnChangeSpatialRefSys</cstring>
<cstring>mFeatureCount</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="mTileWidth"/>
</item>
<item row="3" column="2">
<widget class="QLineEdit" name="mFeatureCount">
<property name="text">
<string>10</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QPushButton" name="btnChangeSpatialRefSys">
<property name="enabled">
<bool>false</bool>
Expand All @@ -240,45 +266,34 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="mTileWidth"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<item row="4" column="0" colspan="2">
<widget class="QLabel" name="labelCoordRefSys">
<property name="text">
<string>Tile size</string>
<string>Coordinate Reference System</string>
</property>
<property name="buddy">
<cstring>mTileWidth</cstring>
<cstring>btnChangeSpatialRefSys</cstring>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="mTileHeight"/>
</item>
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="label_3">
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Feature limit for GetFeatureInfo</string>
<string>Request step size</string>
</property>
<property name="buddy">
<cstring>mFeatureCount</cstring>
<cstring>mTileWidth</cstring>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="mFeatureCount">
<property name="text">
<string>10</string>
</property>
</widget>
<item row="2" column="1">
<widget class="QLineEdit" name="mStepWidth"/>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="mContextualLegendCheckbox">
<property name="text">
<string>Use contextual WMS Legend</string>
</property>
</widget>
<item row="2" column="2">
<widget class="QLineEdit" name="mStepHeight"/>
</item>
</layout>
</widget>
Expand Down Expand Up @@ -496,19 +511,20 @@
<tabstop>lstLayers</tabstop>
<tabstop>mTileWidth</tabstop>
<tabstop>mTileHeight</tabstop>
<tabstop>mStepWidth</tabstop>
<tabstop>mStepHeight</tabstop>
<tabstop>mFeatureCount</tabstop>
<tabstop>btnChangeSpatialRefSys</tabstop>
<tabstop>mContextualLegendCheckbox</tabstop>
<tabstop>mLayerUpButton</tabstop>
<tabstop>mLayerDownButton</tabstop>
<tabstop>mLayerOrderTreeWidget</tabstop>
<tabstop>leLayerName</tabstop>
<tabstop>lstTilesets</tabstop>
<tabstop>leSearchTerm</tabstop>
<tabstop>btnSearch</tabstop>
<tabstop>tableWidgetWMSList</tabstop>
<tabstop>btnAddWMS</tabstop>
<tabstop>leLayerName</tabstop>
<tabstop>buttonBox</tabstop>
<tabstop>mLayerOrderTreeWidget</tabstop>
<tabstop>mLayerDownButton</tabstop>
<tabstop>mLayerUpButton</tabstop>
</tabstops>
<resources/>
<connections>
Expand Down

3 comments on commit baa5d90

@nirvn
Copy link
Contributor

@nirvn nirvn commented on baa5d90 Feb 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jef-n , this commit has broken XYZ support (verified through git dissect).

Symptoms: if you add a XYZ layer in a non WGS84 projection (I'm seeing it with a UTM projection), the XYZ layer goes into an infinite loop, never rendering its content.

@jef-n
Copy link
Member Author

@jef-n jef-n commented on baa5d90 Feb 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nirvn fixed in f924578

@nirvn
Copy link
Contributor

@nirvn nirvn commented on baa5d90 Feb 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jef-n , thanks.

Please sign in to comment.