Skip to content

Commit

Permalink
[FEATURE] allow to specify FEATURE_COUNT for WMS GetFeatureInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Feb 23, 2012
1 parent 82a4931 commit d07d6ba
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 9 deletions.
10 changes: 10 additions & 0 deletions src/providers/wms/qgswmsprovider.cpp
Expand Up @@ -91,6 +91,7 @@ QgsWmsProvider::QgsWmsProvider( QString const &uri )
, mErrors( 0 )
, mUserName( QString::null )
, mPassword( QString::null )
, mFeatureCount( 0 )
{
// URL may contain username/password information for a WMS
// requiring authentication. In this case the URL is prefixed
Expand Down Expand Up @@ -162,6 +163,10 @@ void QgsWmsProvider::parseUri( QString uri )
}
qSort( mResolutions );
}
else if ( item.startsWith( "featureCount=" ) )
{
mFeatureCount = item.mid( 13 ).toInt();
}
else if ( item.startsWith( "url=" ) )
{
// strip the authentication information from the front of the uri
Expand Down Expand Up @@ -2954,6 +2959,11 @@ QStringList QgsWmsProvider::identifyAs( const QgsPoint& point, QString format )
setQueryItem( requestUrl, "X", QString::number( point.x() ) );
setQueryItem( requestUrl, "Y", QString::number( point.y() ) );

if( mFeatureCount > 0 )
{
setQueryItem( requestUrl, "FEATURE_COUNT", QString::number( mFeatureCount ) );
}

// X,Y in WMS 1.1.1; I,J in WMS 1.3.0
// requestUrl += QString( "&I=%1&J=%2" ).arg( point.x() ).arg( point.y() );

Expand Down
3 changes: 3 additions & 0 deletions src/providers/wms/qgswmsprovider.h
Expand Up @@ -959,6 +959,9 @@ class QgsWmsProvider : public QgsRasterDataProvider
int mTileHeight;
QVector<double> mResolutions;

//! FEATURE_COUNT for GetFeatureInfo
int mFeatureCount;

//! whether to use hrefs from GetCapabilities (default) or
// the given base urls for GetMap and GetFeatureInfo
bool mIgnoreGetMapUrl;
Expand Down
12 changes: 8 additions & 4 deletions src/providers/wms/qgswmssourceselect.cpp
Expand Up @@ -71,6 +71,7 @@ QgsWMSSourceSelect::QgsWMSSourceSelect( QWidget * parent, Qt::WFlags fl, bool ma

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

mImageFormatGroup = new QButtonGroup;

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

if ( mFeatureCount->text().toInt() > 0 )
{
if( !connArgs.isEmpty() )
connArgs += ",";
connArgs += QString( "featureCount=%1" ).arg( mFeatureCount->text().toInt() );
}

if ( !connArgs.isEmpty() )
{
if ( connInfo.startsWith( "username=" ) || connInfo.startsWith( "ignoreUrl=" ) )
Expand All @@ -483,10 +491,6 @@ void QgsWMSSourceSelect::addClicked()
}
QgsDebugMsg( "crs = " + crs );

// TODO: do it without QgisApp
//QgisApp::instance()->addRasterLayer( connInfo,
// leLayerName->text().isEmpty() ? layers.join( "/" ) : leLayerName->text(),
// "wms", layers, styles, format, crs );
emit addRasterLayer( connInfo,
leLayerName->text().isEmpty() ? layers.join( "/" ) : leLayerName->text(),
"wms", layers, styles, format, crs );
Expand Down
24 changes: 19 additions & 5 deletions src/ui/qgswmssourceselectbase.ui
Expand Up @@ -220,7 +220,7 @@
<item row="0" column="1" colspan="2">
<widget class="QLineEdit" name="leLayerName"/>
</item>
<item row="2" column="0" colspan="2">
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="labelCoordRefSys">
<property name="text">
<string>Coordinate Reference System</string>
Expand All @@ -230,7 +230,7 @@
</property>
</widget>
</item>
<item row="2" column="2">
<item row="3" column="2">
<widget class="QPushButton" name="btnChangeSpatialRefSys">
<property name="enabled">
<bool>false</bool>
Expand All @@ -241,20 +241,34 @@
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="mTileWidth">
</widget>
<widget class="QLineEdit" name="mTileWidth"/>
</item>
<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="1" column="2">
<widget class="QLineEdit" name="mTileHeight">
<widget class="QLineEdit" name="mTileHeight"/>
</item>
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Feature limit for GetFeatureInfo</string>
</property>
<property name="buddy">
<cstring>mFeatureCount</cstring>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="mFeatureCount"/>
</item>
</layout>
</widget>
</item>
Expand Down

0 comments on commit d07d6ba

Please sign in to comment.