From 2f1b11b37b131d031cbf0cf6b9e618ac34b58a4d Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Mon, 29 Jan 2024 15:39:08 +0100 Subject: [PATCH] GetFeatureInfo - The XML can be a BoundingBox item and not a Layer item --- lizmap_server/get_feature_info.py | 5 +++++ test/test_server_core.py | 2 ++ 2 files changed, 7 insertions(+) diff --git a/lizmap_server/get_feature_info.py b/lizmap_server/get_feature_info.py index feac85ff..27a1cf24 100755 --- a/lizmap_server/get_feature_info.py +++ b/lizmap_server/get_feature_info.py @@ -50,6 +50,11 @@ def append_maptip(cls, string: str, layer_name: str, feature_id: Union[str, int] """ Edit the XML GetFeatureInfo by adding a maptip for a given layer and feature ID. """ root = ET.fromstring(string) for layer in root: + + if layer.tag.upper() != 'LAYER': + # The XML can be + continue + if layer.attrib['name'] != layer_name: continue diff --git a/test/test_server_core.py b/test/test_server_core.py index b38f778c..77749dcb 100755 --- a/test/test_server_core.py +++ b/test/test_server_core.py @@ -202,6 +202,7 @@ def test_edit_xml_get_feature_info_without_maptip(self): def test_edit_xml_get_feature_info_with_maptip(self): """ Test to edit a GetFeatureInfo xml with maptip. """ string = ''' + @@ -219,6 +220,7 @@ def test_edit_xml_get_feature_info_with_maptip(self): response = GetFeatureInfoFilter.append_maptip(string, "qgis_popup", 1, "foo") expected = ''' +