Skip to content

Commit

Permalink
Merge pull request #49544 from mhugent/wms_featureinfo_xml
Browse files Browse the repository at this point in the history
Handle GetFeatureInfo with type text/xml
  • Loading branch information
mhugent committed Dec 9, 2022
2 parents e86dc5f + bbce881 commit 36b4bc8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
10 changes: 1 addition & 9 deletions src/providers/wms/qgswmscapabilities.cpp
Expand Up @@ -528,15 +528,7 @@ bool QgsWmsCapabilities::parseResponse( const QByteArray &response, QgsWmsParser
format = QgsRaster::IdentifyFormatText;
else if ( f == QLatin1String( "text/html" ) )
format = QgsRaster::IdentifyFormatHtml;
else if ( f.startsWith( QLatin1String( "GML." ) ) )
format = QgsRaster::IdentifyFormatFeature; // 1.0
else if ( f == QLatin1String( "application/vnd.ogc.gml" ) )
format = QgsRaster::IdentifyFormatFeature;
else if ( f == QLatin1String( "application/json" ) )
format = QgsRaster::IdentifyFormatFeature;
else if ( f == QLatin1String( "application/geojson" ) )
format = QgsRaster::IdentifyFormatFeature;
else if ( f.contains( QLatin1String( "gml" ), Qt::CaseInsensitive ) )
else if ( f.startsWith( QLatin1String( "GML." ) ) || f == QLatin1String( "application/vnd.ogc.gml" ) || f == QLatin1String( "application/json" ) || f == QLatin1String( "application/geojson" ) || f.contains( QLatin1String( "gml" ), Qt::CaseInsensitive ) || f == QLatin1String( "text/xml" ) )
format = QgsRaster::IdentifyFormatFeature;

mIdentifyFormats.insert( format, f );
Expand Down
11 changes: 7 additions & 4 deletions src/providers/wms/qgswmsprovider.cpp
Expand Up @@ -3588,10 +3588,13 @@ QgsRasterIdentifyResult QgsWmsProvider::identify( const QgsPointXY &point, QgsRa

if ( isXml && parseServiceExceptionReportDom( body, mErrorCaption, mError ) )
{
QgsMessageLog::logMessage( tr( "Get feature info request error (Title: %1; Error: %2; URL: %3)" )
.arg( mErrorCaption, mError,
requestUrl.toString() ), tr( "WMS" ) );
continue;
if ( !mError.isEmpty() ) //xml is not necessarily an exception
{
QgsMessageLog::logMessage( tr( "Get feature info request error (Title: %1; Error: %2; URL: %3)" )
.arg( mErrorCaption, mError,
requestUrl.toString() ), tr( "WMS" ) );
continue;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/src/providers/testqgswmscapabilities.cpp
Expand Up @@ -456,7 +456,7 @@ class TestQgsWmsCapabilities: public QObject
QTest::addColumn<int>( "capability" );

QTest::newRow( "text/plain" ) << QByteArray( "text/plain" ) << static_cast<int>( QgsRasterInterface::IdentifyText );
QTest::newRow( "text/xml" ) << QByteArray( "text/xml" ) << static_cast<int>( QgsRasterInterface::NoCapabilities );
QTest::newRow( "text/xml" ) << QByteArray( "text/xml" ) << static_cast<int>( QgsRasterInterface::IdentifyFeature );
QTest::newRow( "text/html" ) << QByteArray( "text/html" ) << static_cast<int>( QgsRasterInterface::IdentifyHtml );
QTest::newRow( "application/json" ) << QByteArray( "application/json" ) << static_cast<int>( QgsRasterInterface::IdentifyFeature );
QTest::newRow( "application/geojson" ) << QByteArray( "application/geojson" ) << static_cast<int>( QgsRasterInterface::IdentifyFeature );
Expand Down

0 comments on commit 36b4bc8

Please sign in to comment.