Skip to content

Commit

Permalink
Merge pull request #9526 from rldhont/fix-server-getfeatureinfo-withf…
Browse files Browse the repository at this point in the history
…ilter-withoutcrs

[Bugfix][Server] In WMS GetFeatureInfo CRS param not mandatory when FILTER param
  • Loading branch information
rldhont committed Mar 21, 2019
2 parents fcb572e + 34e67c1 commit 59e5a68
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
16 changes: 14 additions & 2 deletions src/server/services/wms/qgswmsrenderer.cpp
Expand Up @@ -1093,8 +1093,16 @@ namespace QgsWms
QgsMapSettings mapSettings;
std::unique_ptr<QImage> outputImage( createImage( imageWidth, imageHeight ) );

// The CRS parameter is considered as mandatory in configureMapSettings
// but in the case of filter parameter, CRS parameter has not to be mandatory
bool mandatoryCrsParam = true;
if ( filtersDefined && !ijDefined && !xyDefined && mWmsParameters.crs().isEmpty() )
{
mandatoryCrsParam = false;
}

// configure map settings (background, DPI, ...)
configureMapSettings( outputImage.get(), mapSettings );
configureMapSettings( outputImage.get(), mapSettings, mandatoryCrsParam );

QgsMessageLog::logMessage( "mapSettings.destinationCrs(): " + mapSettings.destinationCrs().authid() );
QgsMessageLog::logMessage( "mapSettings.extent(): " + mapSettings.extent().toString() );
Expand Down Expand Up @@ -1231,7 +1239,7 @@ namespace QgsWms
return image.release();
}

void QgsRenderer::configureMapSettings( const QPaintDevice *paintDevice, QgsMapSettings &mapSettings ) const
void QgsRenderer::configureMapSettings( const QPaintDevice *paintDevice, QgsMapSettings &mapSettings, bool mandatoryCrsParam ) const
{
if ( !paintDevice )
{
Expand All @@ -1254,6 +1262,10 @@ namespace QgsWms
crs = QString( "EPSG:4326" );
mapExtent.invert();
}
else if ( crs.isEmpty() && !mandatoryCrsParam )
{
crs = QString( "EPSG:4326" );
}

QgsCoordinateReferenceSystem outputCRS;

Expand Down
3 changes: 2 additions & 1 deletion src/server/services/wms/qgswmsrenderer.h
Expand Up @@ -197,9 +197,10 @@ namespace QgsWms
* Configures map settings according to WMS parameters.
* \param paintDevice The device that is used for painting (for dpi)
* \param mapSettings Map settings to use for rendering
* \param mandatoryCrsParam does the CRS parameter has to be considered mandatory
* may throw an exception
*/
void configureMapSettings( const QPaintDevice *paintDevice, QgsMapSettings &mapSettings ) const;
void configureMapSettings( const QPaintDevice *paintDevice, QgsMapSettings &mapSettings, bool mandatoryCrsParam = true ) const;

QDomDocument featureInfoDocument( QList<QgsMapLayer *> &layers, const QgsMapSettings &mapSettings,
const QImage *outputImage, const QString &version ) const;
Expand Down
10 changes: 10 additions & 0 deletions tests/src/python/test_qgsserver_wms_getfeatureinfo.py
Expand Up @@ -347,6 +347,16 @@ def testGetFeatureInfoFilter(self):
urllib.parse.quote(':"NAME" = \'two\''),
'wms_getfeatureinfo_filter_no_width')

# Test a filter without CRS parameter
self.wms_request_compare('GetFeatureInfo',
'&layers=testlayer%20%C3%A8%C3%A9&' +
'INFO_FORMAT=text%2Fxml&' +
'width=600&height=400&' +
'query_layers=testlayer%20%C3%A8%C3%A9&' +
'FEATURE_COUNT=10&FILTER=testlayer%20%C3%A8%C3%A9' +
urllib.parse.quote(':"NAME" = \'two\''),
'wms_getfeatureinfo_filter_no_crs')

def testGetFeatureInfoTolerance(self):
self.wms_request_compare('GetFeatureInfo',
'&layers=layer3&styles=&' +
Expand Down
14 changes: 14 additions & 0 deletions tests/testdata/qgis_server/wms_getfeatureinfo_filter_no_crs.txt
@@ -0,0 +1,14 @@
Content-Length: 577
Content-Type: text/xml; charset=utf-8

<GetFeatureInfoResponse>
<BoundingBox maxy="44.90143568" maxx="8.20354699" miny="44.90143568" CRS="EPSG:4326" minx="8.20354699"/>
<Layer name="testlayer èé">
<Feature id="1">
<Attribute value="2" name="id"/>
<Attribute value="two" name="name"/>
<Attribute value="two àò" name="utf8nameè"/>
<BoundingBox maxy="44.9014" maxx="8.2035" miny="44.9014" CRS="EPSG:4326" minx="8.2035"/>
</Feature>
</Layer>
</GetFeatureInfoResponse>

0 comments on commit 59e5a68

Please sign in to comment.