Skip to content
Permalink
Browse files

Server: respect "use layer ids" option in json getfeatureinfo

Fixes #36262
  • Loading branch information
elpaso committed May 26, 2020
1 parent 24ec1d9 commit 1e54c6b8f377aca4a1b98ff9f76c14f366ad73ce
@@ -2279,7 +2279,7 @@ namespace QgsWms

for ( const auto &feature : qgis::as_const( features ) )
{
const QString id = QStringLiteral( "%1.%2" ).arg( layer->name(), QgsJsonUtils::encodeValue( feature.id() ) );
const QString id = QStringLiteral( "%1.%2" ).arg( layerName ).arg( feature.id() );
json["features"].push_back( exporter.exportFeatureToJsonObject( feature, QVariantMap(), id ) );
}
}
@@ -2298,7 +2298,7 @@ namespace QgsWms
json["features"].push_back(
{
{"type", "Feature" },
{"id", layer->name().toStdString() },
{"id", layerName.toStdString() },
{"properties", properties }
} );
}
@@ -40,7 +40,7 @@
class TestQgsServerWMSGetFeatureInfo(TestQgsServerWMSTestBase):
"""QGIS Server WMS Tests for GetFeatureInfo request"""

# regenerate_reference = True
#regenerate_reference = True

def testGetFeatureInfo(self):
# Test getfeatureinfo response xml
@@ -752,6 +752,39 @@ def testGetFeatureInfoGroupedLayers(self):
'test_project_wms_grouped_nested_layers.qgs',
normalizeJson=True)

def testGetFeatureInfoJsonUseIdAsLayerName(self):
"""Test GH #36262 where json response + use layer id"""

self.wms_request_compare('GetFeatureInfo',
'&BBOX=44.90139177500000045,8.20335906129666981,44.90148522499999473,8.20364693870333284' +
'&CRS=EPSG:4326' +
'&WIDTH=1568&HEIGHT=509' +
'&LAYERS=testlayer_%C3%A8%C3%A9_cf86cf11_222f_4b62_929c_12cfc82b9774' +
'&STYLES=' +
'&FORMAT=image/jpeg' +
'&QUERY_LAYERS=testlayer_%C3%A8%C3%A9_cf86cf11_222f_4b62_929c_12cfc82b9774' +
'&INFO_FORMAT=application/json' +
'&I=1022&J=269' +
'&FEATURE_COUNT=10',
'wms_getfeatureinfo_json_layer_ids',
'test_project_use_layer_ids.qgs',
normalizeJson=True)

# Raster
self.wms_request_compare('GetFeatureInfo',
'&BBOX=30.1492201749999964,17.81444988978388722,30.2599248249999988,18.15548111021611533' +
'&CRS=EPSG:4326' +
'&WIDTH=1568&HEIGHT=509' +
'&LAYERS=landsat_a7d15b35_ca83_4b23_a9fb_af3fbdd60d15' +
'&STYLES=' +
'&FORMAT=image/jpeg' +
'&QUERY_LAYERS=landsat_a7d15b35_ca83_4b23_a9fb_af3fbdd60d15' +
'&INFO_FORMAT=application/json' +
'&I=769&J=275&FEATURE_COUNT=10',
'wms_getfeatureinfo_json_layer_ids_raster',
'test_project_use_layer_ids.qgs',
normalizeJson=True)

@unittest.skipIf(os.environ.get('TRAVIS', '') == 'true',
"This test cannot run in TRAVIS because it relies on cascading external services")
def testGetFeatureInfoCascadingLayers(self):

0 comments on commit 1e54c6b

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