Skip to content
Permalink
Browse files

Merge pull request #5150 from pblottiere/server_bugfix_ogc_getfeature…

…info_invalid_format

[server][bugfix] Fix OGC test getfeatureinfo:invalid-info_format
  • Loading branch information
pblottiere committed Oct 3, 2017
2 parents 58f64bb + 04cdf49 commit 8a09a197ccda645a7d91effec6ff9d5075dcf310
@@ -1179,8 +1179,12 @@ namespace QgsWms
f = Format::XML;
else if ( fStr.startsWith( QLatin1String( "text/html" ), Qt::CaseInsensitive ) )
f = Format::HTML;
else if ( fStr.startsWith( QLatin1String( "text/plain" ), Qt::CaseInsensitive ) )
f = Format::TEXT;
else if ( fStr.startsWith( QLatin1String( "application/vnd.ogc.gml" ), Qt::CaseInsensitive ) )
f = Format::GML;
else
f = Format::NONE;

return f;
}
@@ -998,7 +998,13 @@ namespace QgsWms
QByteArray ba;

QgsWmsParameters::Format infoFormat = mWmsParameters.infoFormat();
if ( infoFormat == QgsWmsParameters::Format::TEXT )

if ( infoFormat == QgsWmsParameters::Format::NONE )
{
throw QgsBadRequestException( QStringLiteral( "InvalidFormat" ),
QStringLiteral( "Invalid INFO_FORMAT parameter" ) );
}
else if ( infoFormat == QgsWmsParameters::Format::TEXT )
ba = convertFeatureInfoToText( result );
else if ( infoFormat == QgsWmsParameters::Format::HTML )
ba = convertFeatureInfoToHtml( result );
@@ -88,6 +88,16 @@ def test_project_wms(self):
'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320',
'wms_getfeatureinfo-text-html')

# Test getfeatureinfo response text
self.wms_request_compare('GetFeatureInfo',
'&layers=testlayer%20%C3%A8%C3%A9&styles=&' +
'transparent=true&' +
'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
'5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320&' +
'info_format=text/plain',
'wms_getfeatureinfo-text-plain')

# Test getfeatureinfo default info_format
self.wms_request_compare('GetFeatureInfo',
'&layers=testlayer%20%C3%A8%C3%A9&styles=&' +
@@ -97,6 +107,16 @@ def test_project_wms(self):
'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320',
'wms_getfeatureinfo-text-plain')

# Test getfeatureinfo invalid info_format
self.wms_request_compare('GetFeatureInfo',
'&layers=testlayer%20%C3%A8%C3%A9&styles=&' +
'transparent=true&' +
'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
'5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320&' +
'info_format=InvalidFormat',
'wms_getfeatureinfo-invalid-format')

# Regression for #8656
# Mind the gap! (the space in the FILTER expression)
self.wms_request_compare('GetFeatureInfo',
@@ -0,0 +1,6 @@
*****
Content-Type: text/xml; charset=utf-8

<ServiceExceptionReport version="1.3.0" xmlns="http://www.opengis.net/ogc">
<ServiceException code="InvalidFormat">Invalid INFO_FORMAT parameter</ServiceException>
</ServiceExceptionReport>

0 comments on commit 8a09a19

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