Skip to content
Permalink
Browse files

Merge pull request #36733 from elpaso/bugfix-36262-json-export-respec…

…t-use-layer-ids

Server: respect "use layer ids" option in json getfeatureinfo
  • Loading branch information
elpaso committed May 27, 2020
2 parents 923072d + d859bb9 commit 2a70569a2c0f1a77ab62a08aaaca83bcc5014bdc
@@ -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 }
} );
}
@@ -657,7 +657,7 @@ def testGetFeatureInfoGroupedLayers(self):
'&INFO_FORMAT=application/json' +
'&I=0&J=1' +
'&FEATURE_COUNT=10',
'wms_getfeatureinfo_group_name_areas',
'wms_getfeatureinfo_group_name_areas_nested',
'test_project_wms_grouped_nested_layers.qgs',
normalizeJson=True)

@@ -670,7 +670,7 @@ def testGetFeatureInfoGroupedLayers(self):
'&INFO_FORMAT=application/json' +
'&I=0&J=1' +
'&FEATURE_COUNT=10',
'wms_getfeatureinfo_group_name_areas',
'wms_getfeatureinfo_group_name_areas_nested',
'test_project_wms_grouped_nested_layers.qgs',
normalizeJson=True)

@@ -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):

Large diffs are not rendered by default.

@@ -5,7 +5,7 @@ Content-Type: application/json; charset=utf-8
"features": [
{
"geometry": null,
"id": "as_areas.18",
"id": "as-areas-short-name.18",
"properties": {
"bearbeiter": "scholle-b",
"bemerkung": "",
@@ -0,0 +1,37 @@
*****
Content-Type: application/json; charset=utf-8

{
"features": [
{
"geometry": null,
"id": "as-areas-short-name.18",
"properties": {
"bearbeiter": "scholle-b",
"bemerkung": "",
"beschriftung": "",
"datum": "2013-06-11",
"farbe": "255 0 0",
"fid": 18,
"flaeche": 12879.0,
"flaechentyp": "Schraffur",
"gid": 34,
"last_change": "2013-06-11 10:03:45.52301+02",
"name": "",
"schraff_size": "10",
"schraff_size_prt": "30.00",
"schraff_width": "2",
"schraff_width_prt": "6.00",
"schraff_winkel": "45",
"umfang": 758.4703,
"umrissfarbe": "0 0 0",
"umrissstaerke": "1",
"umrissstaerke_prt": "3.00",
"umrisstyp": "durchgezogen",
"veranstaltung": ""
},
"type": "Feature"
}
],
"type": "FeatureCollection"
}
@@ -18,7 +18,7 @@ Content-Type: application/json; charset=utf-8
},
{
"geometry": null,
"id": "as_areas.18",
"id": "as-areas-short-name.18",
"properties": {
"bearbeiter": "scholle-b",
"bemerkung": "",
@@ -47,7 +47,7 @@ Content-Type: application/json; charset=utf-8
},
{
"geometry": null,
"id": "as_areas_query_copy.18",
"id": "as-areas-short-name-query-copy.18",
"properties": {
"bearbeiter": "scholle-b",
"bemerkung": "",
@@ -5,7 +5,7 @@ Content-Type: application/json; charset=utf-8
"features": [
{
"geometry": null,
"id": "as_areas_query_copy.18",
"id": "as-areas-short-name-query-copy.18",
"properties": {
"bearbeiter": "scholle-b",
"bemerkung": "",
@@ -0,0 +1,18 @@
Content-Length: 299
Content-Type: application/json; charset=utf-8

{
"features": [
{
"geometry": null,
"id": "testlayer_èé_cf86cf11_222f_4b62_929c_12cfc82b9774.1",
"properties": {
"alias_id": 2,
"alias_name": "two",
"utf8nameè": "two àò"
},
"type": "Feature"
}
],
"type": "FeatureCollection"
}
@@ -0,0 +1,23 @@
Content-Length: 402
Content-Type: application/json; charset=utf-8

{
"features": [
{
"id": "landsat_a7d15b35_ca83_4b23_a9fb_af3fbdd60d15",
"properties": {
"Band 1": "127",
"Band 2": "142",
"Band 3": "96",
"Band 4": "70",
"Band 5": "81",
"Band 6": "119",
"Band 7": "146",
"Band 8": "199",
"Band 9": "160"
},
"type": "Feature"
}
],
"type": "FeatureCollection"
}

0 comments on commit 2a70569

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