Skip to content
Permalink
Browse files
[FEATURE] allow to specify FEATURE_COUNT for WMS GetFeatureInfo
  • Loading branch information
jef-n committed Feb 23, 2012
1 parent 82a4931 commit d07d6ba0bb17e6e38c8d0c063d908b60bc9cea48
@@ -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
@@ -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
@@ -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() );

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

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

0 comments on commit d07d6ba

Please sign in to comment.