Skip to content

Commit d07d6ba

Browse files
committed
[FEATURE] allow to specify FEATURE_COUNT for WMS GetFeatureInfo
1 parent 82a4931 commit d07d6ba

File tree

4 files changed

+40
-9
lines changed

4 files changed

+40
-9
lines changed

src/providers/wms/qgswmsprovider.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ QgsWmsProvider::QgsWmsProvider( QString const &uri )
9191
, mErrors( 0 )
9292
, mUserName( QString::null )
9393
, mPassword( QString::null )
94+
, mFeatureCount( 0 )
9495
{
9596
// URL may contain username/password information for a WMS
9697
// requiring authentication. In this case the URL is prefixed
@@ -162,6 +163,10 @@ void QgsWmsProvider::parseUri( QString uri )
162163
}
163164
qSort( mResolutions );
164165
}
166+
else if ( item.startsWith( "featureCount=" ) )
167+
{
168+
mFeatureCount = item.mid( 13 ).toInt();
169+
}
165170
else if ( item.startsWith( "url=" ) )
166171
{
167172
// strip the authentication information from the front of the uri
@@ -2954,6 +2959,11 @@ QStringList QgsWmsProvider::identifyAs( const QgsPoint& point, QString format )
29542959
setQueryItem( requestUrl, "X", QString::number( point.x() ) );
29552960
setQueryItem( requestUrl, "Y", QString::number( point.y() ) );
29562961

2962+
if( mFeatureCount > 0 )
2963+
{
2964+
setQueryItem( requestUrl, "FEATURE_COUNT", QString::number( mFeatureCount ) );
2965+
}
2966+
29572967
// X,Y in WMS 1.1.1; I,J in WMS 1.3.0
29582968
// requestUrl += QString( "&I=%1&J=%2" ).arg( point.x() ).arg( point.y() );
29592969

src/providers/wms/qgswmsprovider.h

+3
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,9 @@ class QgsWmsProvider : public QgsRasterDataProvider
959959
int mTileHeight;
960960
QVector<double> mResolutions;
961961

962+
//! FEATURE_COUNT for GetFeatureInfo
963+
int mFeatureCount;
964+
962965
//! whether to use hrefs from GetCapabilities (default) or
963966
// the given base urls for GetMap and GetFeatureInfo
964967
bool mIgnoreGetMapUrl;

src/providers/wms/qgswmssourceselect.cpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ QgsWMSSourceSelect::QgsWMSSourceSelect( QWidget * parent, Qt::WFlags fl, bool ma
7171

7272
mTileWidth->setValidator( new QIntValidator( 0, 9999, this ) );
7373
mTileHeight->setValidator( new QIntValidator( 0, 9999, this ) );
74+
mFeatureCount->setValidator( new QIntValidator( 0, 9999, this ) );
7475

7576
mImageFormatGroup = new QButtonGroup;
7677

@@ -470,6 +471,13 @@ void QgsWMSSourceSelect::addClicked()
470471
.arg( item->data( Qt::UserRole + 6 ).toStringList().join( ";" ) );
471472
}
472473

474+
if ( mFeatureCount->text().toInt() > 0 )
475+
{
476+
if( !connArgs.isEmpty() )
477+
connArgs += ",";
478+
connArgs += QString( "featureCount=%1" ).arg( mFeatureCount->text().toInt() );
479+
}
480+
473481
if ( !connArgs.isEmpty() )
474482
{
475483
if ( connInfo.startsWith( "username=" ) || connInfo.startsWith( "ignoreUrl=" ) )
@@ -483,10 +491,6 @@ void QgsWMSSourceSelect::addClicked()
483491
}
484492
QgsDebugMsg( "crs = " + crs );
485493

486-
// TODO: do it without QgisApp
487-
//QgisApp::instance()->addRasterLayer( connInfo,
488-
// leLayerName->text().isEmpty() ? layers.join( "/" ) : leLayerName->text(),
489-
// "wms", layers, styles, format, crs );
490494
emit addRasterLayer( connInfo,
491495
leLayerName->text().isEmpty() ? layers.join( "/" ) : leLayerName->text(),
492496
"wms", layers, styles, format, crs );

src/ui/qgswmssourceselectbase.ui

+19-5
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@
220220
<item row="0" column="1" colspan="2">
221221
<widget class="QLineEdit" name="leLayerName"/>
222222
</item>
223-
<item row="2" column="0" colspan="2">
223+
<item row="3" column="0" colspan="2">
224224
<widget class="QLabel" name="labelCoordRefSys">
225225
<property name="text">
226226
<string>Coordinate Reference System</string>
@@ -230,7 +230,7 @@
230230
</property>
231231
</widget>
232232
</item>
233-
<item row="2" column="2">
233+
<item row="3" column="2">
234234
<widget class="QPushButton" name="btnChangeSpatialRefSys">
235235
<property name="enabled">
236236
<bool>false</bool>
@@ -241,20 +241,34 @@
241241
</widget>
242242
</item>
243243
<item row="1" column="1">
244-
<widget class="QLineEdit" name="mTileWidth">
245-
</widget>
244+
<widget class="QLineEdit" name="mTileWidth"/>
246245
</item>
247246
<item row="1" column="0">
248247
<widget class="QLabel" name="label_2">
249248
<property name="text">
250249
<string>Tile size</string>
251250
</property>
251+
<property name="buddy">
252+
<cstring>mTileWidth</cstring>
253+
</property>
252254
</widget>
253255
</item>
254256
<item row="1" column="2">
255-
<widget class="QLineEdit" name="mTileHeight">
257+
<widget class="QLineEdit" name="mTileHeight"/>
258+
</item>
259+
<item row="2" column="0" colspan="2">
260+
<widget class="QLabel" name="label_3">
261+
<property name="text">
262+
<string>Feature limit for GetFeatureInfo</string>
263+
</property>
264+
<property name="buddy">
265+
<cstring>mFeatureCount</cstring>
266+
</property>
256267
</widget>
257268
</item>
269+
<item row="2" column="2">
270+
<widget class="QLineEdit" name="mFeatureCount"/>
271+
</item>
258272
</layout>
259273
</widget>
260274
</item>

0 commit comments

Comments
 (0)