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
(cherry picked from commit 66303f2)
  • Loading branch information
elpaso authored and nyalldawson committed May 27, 2020
1 parent eceb7c3 commit 94b15abe797a9022ddb8a7d2fd4face3639743ef
@@ -2224,7 +2224,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 ) );
}
}
@@ -2243,7 +2243,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,21 +752,55 @@ def testGetFeatureInfoGroupedLayers(self):
'test_project_wms_grouped_nested_layers.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):
"""Test that we can get feature info on cascading WMS layers"""

project_name = 'bug_gh31177_gfi_cascading_wms.qgs'
self.wms_request_compare('GetFeatureInfo',
'&BBOX=852729.31,5631138.51,853012.18,5631346.17' +
'&CRS=EPSG:3857' +
'&WIDTH=850&HEIGHT=624' +
'&QUERY_LAYERS=Alberate' +
'&INFO_FORMAT=application/vnd.ogc.gml' +
'&I=509&J=289' +
'&FEATURE_COUNT=10',
'wms_getfeatureinfo_cascading_issue31177',
project_name)
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):
"""Test that we can get feature info on cascading WMS layers"""

project_name = 'bug_gh31177_gfi_cascading_wms.qgs'
self.wms_request_compare('GetFeatureInfo',
'&BBOX=852729.31,5631138.51,853012.18,5631346.17' +
'&CRS=EPSG:3857' +
'&WIDTH=850&HEIGHT=624' +
'&QUERY_LAYERS=Alberate' +
'&INFO_FORMAT=application/vnd.ogc.gml' +
'&I=509&J=289' +
'&FEATURE_COUNT=10',
'wms_getfeatureinfo_cascading_issue31177',
project_name)


if __name__ == '__main__':

0 comments on commit 94b15ab

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