Skip to content

Commit 34e67c1

Browse files
committedMar 19, 2019
[Bugfix][Server] In WMS GetFeatureInfo CRS param not mandatory when FILTER param
The CRS parameter is considered as mandatory in GetFeatureInfo even if the FILTER parameter is used without I and J parameters. To fix it, set a fake CRS in the parameter when I/J and X/Y parameters are not defined and FILTER parameter is defined.
1 parent 1e8aec4 commit 34e67c1

File tree

4 files changed

+40
-3
lines changed

4 files changed

+40
-3
lines changed
 

‎src/server/services/wms/qgswmsrenderer.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,8 +1093,16 @@ namespace QgsWms
10931093
QgsMapSettings mapSettings;
10941094
std::unique_ptr<QImage> outputImage( createImage( imageWidth, imageHeight ) );
10951095

1096+
// The CRS parameter is considered as mandatory in configureMapSettings
1097+
// but in the case of filter parameter, CRS parameter has not to be mandatory
1098+
bool mandatoryCrsParam = true;
1099+
if ( filtersDefined && !ijDefined && !xyDefined && mWmsParameters.crs().isEmpty() )
1100+
{
1101+
mandatoryCrsParam = false;
1102+
}
1103+
10961104
// configure map settings (background, DPI, ...)
1097-
configureMapSettings( outputImage.get(), mapSettings );
1105+
configureMapSettings( outputImage.get(), mapSettings, mandatoryCrsParam );
10981106

10991107
QgsMessageLog::logMessage( "mapSettings.destinationCrs(): " + mapSettings.destinationCrs().authid() );
11001108
QgsMessageLog::logMessage( "mapSettings.extent(): " + mapSettings.extent().toString() );
@@ -1231,7 +1239,7 @@ namespace QgsWms
12311239
return image.release();
12321240
}
12331241

1234-
void QgsRenderer::configureMapSettings( const QPaintDevice *paintDevice, QgsMapSettings &mapSettings ) const
1242+
void QgsRenderer::configureMapSettings( const QPaintDevice *paintDevice, QgsMapSettings &mapSettings, bool mandatoryCrsParam ) const
12351243
{
12361244
if ( !paintDevice )
12371245
{
@@ -1254,6 +1262,10 @@ namespace QgsWms
12541262
crs = QString( "EPSG:4326" );
12551263
mapExtent.invert();
12561264
}
1265+
else if ( crs.isEmpty() && !mandatoryCrsParam )
1266+
{
1267+
crs = QString( "EPSG:4326" );
1268+
}
12571269

12581270
QgsCoordinateReferenceSystem outputCRS;
12591271

‎src/server/services/wms/qgswmsrenderer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,10 @@ namespace QgsWms
197197
* Configures map settings according to WMS parameters.
198198
* \param paintDevice The device that is used for painting (for dpi)
199199
* \param mapSettings Map settings to use for rendering
200+
* \param mandatoryCrsParam does the CRS parameter has to be considered mandatory
200201
* may throw an exception
201202
*/
202-
void configureMapSettings( const QPaintDevice *paintDevice, QgsMapSettings &mapSettings ) const;
203+
void configureMapSettings( const QPaintDevice *paintDevice, QgsMapSettings &mapSettings, bool mandatoryCrsParam = true ) const;
203204

204205
QDomDocument featureInfoDocument( QList<QgsMapLayer *> &layers, const QgsMapSettings &mapSettings,
205206
const QImage *outputImage, const QString &version ) const;

‎tests/src/python/test_qgsserver_wms_getfeatureinfo.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,16 @@ def testGetFeatureInfoFilter(self):
347347
urllib.parse.quote(':"NAME" = \'two\''),
348348
'wms_getfeatureinfo_filter_no_width')
349349

350+
# Test a filter without CRS parameter
351+
self.wms_request_compare('GetFeatureInfo',
352+
'&layers=testlayer%20%C3%A8%C3%A9&' +
353+
'INFO_FORMAT=text%2Fxml&' +
354+
'width=600&height=400&' +
355+
'query_layers=testlayer%20%C3%A8%C3%A9&' +
356+
'FEATURE_COUNT=10&FILTER=testlayer%20%C3%A8%C3%A9' +
357+
urllib.parse.quote(':"NAME" = \'two\''),
358+
'wms_getfeatureinfo_filter_no_crs')
359+
350360
def testGetFeatureInfoTolerance(self):
351361
self.wms_request_compare('GetFeatureInfo',
352362
'&layers=layer3&styles=&' +
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Content-Length: 577
2+
Content-Type: text/xml; charset=utf-8
3+
4+
<GetFeatureInfoResponse>
5+
<BoundingBox maxy="44.90143568" maxx="8.20354699" miny="44.90143568" CRS="EPSG:4326" minx="8.20354699"/>
6+
<Layer name="testlayer èé">
7+
<Feature id="1">
8+
<Attribute value="2" name="id"/>
9+
<Attribute value="two" name="name"/>
10+
<Attribute value="two àò" name="utf8nameè"/>
11+
<BoundingBox maxy="44.9014" maxx="8.2035" miny="44.9014" CRS="EPSG:4326" minx="8.2035"/>
12+
</Feature>
13+
</Layer>
14+
</GetFeatureInfoResponse>

0 commit comments

Comments
 (0)