Skip to content
Permalink
Browse files

fix feature info for WMS 1.3

  • Loading branch information
jef-n committed May 21, 2012
1 parent d28b655 commit 8b86d8330e0afc26bbe086203bd879207a1b4dc0
Showing with 46 additions and 40 deletions.
  1. +46 −40 src/providers/wms/qgswmsprovider.cpp
@@ -3740,51 +3740,57 @@ QStringList QgsWmsProvider::identifyAs( const QgsPoint& point, QString format )
++layers, ++styles )
{
// Is sublayer visible?
if ( mActiveSubLayerVisibility.find( *layers ).value() )
if ( !mActiveSubLayerVisibility.find( *layers ).value() )
continue;

// Is sublayer queryable?
if ( !mQueryableForLayer.find( *layers ).value() )
continue;

QgsDebugMsg( "Layer '" + *layers + "' is queryable." );

QUrl requestUrl( mGetFeatureInfoUrlBase );
setQueryItem( requestUrl, "SERVICE", "WMS" );
setQueryItem( requestUrl, "VERSION", mCapabilities.version );
setQueryItem( requestUrl, "REQUEST", "GetFeatureInfo" );
setQueryItem( requestUrl, "BBOX", bbox );
setQueryItem( requestUrl, crsKey, mImageCrs );
setQueryItem( requestUrl, "WIDTH", QString::number( mCachedViewWidth ) );
setQueryItem( requestUrl, "HEIGHT", QString::number( mCachedViewHeight ) );
setQueryItem( requestUrl, "LAYERS", *layers );
setQueryItem( requestUrl, "STYLES", *styles );
setQueryItem( requestUrl, "FORMAT", mImageMimeType );
setQueryItem( requestUrl, "QUERY_LAYERS", *layers );
setQueryItem( requestUrl, "INFO_FORMAT", format );

if ( mCapabilities.version == "1.3.0" || mCapabilities.version == "1.3" )
{
setQueryItem( requestUrl, "I", QString::number( point.x() ) );
setQueryItem( requestUrl, "J", QString::number( point.y() ) );
}
else
{
// Is sublayer queryable?
if ( mQueryableForLayer.find( *layers ).value() )
{
QgsDebugMsg( "Layer '" + *layers + "' is queryable." );

QUrl requestUrl( mGetFeatureInfoUrlBase );
setQueryItem( requestUrl, "SERVICE", "WMS" );
setQueryItem( requestUrl, "VERSION", mCapabilities.version );
setQueryItem( requestUrl, "REQUEST", "GetFeatureInfo" );
setQueryItem( requestUrl, "BBOX", bbox );
setQueryItem( requestUrl, crsKey, mImageCrs );
setQueryItem( requestUrl, "WIDTH", QString::number( mCachedViewWidth ) );
setQueryItem( requestUrl, "HEIGHT", QString::number( mCachedViewHeight ) );
setQueryItem( requestUrl, "LAYERS", *layers );
setQueryItem( requestUrl, "STYLES", *styles );
setQueryItem( requestUrl, "FORMAT", mImageMimeType );
setQueryItem( requestUrl, "QUERY_LAYERS", *layers );
setQueryItem( requestUrl, "INFO_FORMAT", 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() );
setQueryItem( requestUrl, "X", QString::number( point.x() ) );
setQueryItem( requestUrl, "Y", QString::number( point.y() ) );
}

QgsDebugMsg( QString( "getfeatureinfo: %1" ).arg( requestUrl.toString() ) );
QNetworkRequest request( requestUrl );
setAuthorization( request );
mIdentifyReply = QgsNetworkAccessManager::instance()->get( request );
connect( mIdentifyReply, SIGNAL( finished() ), this, SLOT( identifyReplyFinished() ) );
if ( mFeatureCount > 0 )
{
setQueryItem( requestUrl, "FEATURE_COUNT", QString::number( mFeatureCount ) );
}

while ( mIdentifyReply )
{
QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents );
}
QgsDebugMsg( QString( "getfeatureinfo: %1" ).arg( requestUrl.toString() ) );
QNetworkRequest request( requestUrl );
setAuthorization( request );
mIdentifyReply = QgsNetworkAccessManager::instance()->get( request );
connect( mIdentifyReply, SIGNAL( finished() ), this, SLOT( identifyReplyFinished() ) );

results << mIdentifyResult;
}
while ( mIdentifyReply )
{
QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents );
}

results << mIdentifyResult;
}

QgsDebugMsg( "Exiting with: " + results.join( "\n------\n" ) );

0 comments on commit 8b86d83

Please sign in to comment.
You can’t perform that action at this time.