Skip to content

Commit

Permalink
Merge pull request #61 from Gustry/getfeatureinfo
Browse files Browse the repository at this point in the history
GetFeatureInfo - The XML can be a BoundingBox item and not a Layer item
  • Loading branch information
Gustry authored Jan 29, 2024
2 parents 05fd3a8 + 2f1b11b commit 4c14094
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lizmap_server/get_feature_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <BoundingBox />
continue

if layer.attrib['name'] != layer_name:
continue

Expand Down
2 changes: 2 additions & 0 deletions test/test_server_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '''<GetFeatureInfoResponse>
<BoundingBox minx="0" maxy="1" maxx="1" CRS="EPSG:2154" miny="0"/>
<Layer name="qgis_popup">
<Feature id="1">
<Attribute name="OBJECTID" value="2662"/>
Expand All @@ -219,6 +220,7 @@ def test_edit_xml_get_feature_info_with_maptip(self):
response = GetFeatureInfoFilter.append_maptip(string, "qgis_popup", 1, "<b>foo</b>")

expected = '''<GetFeatureInfoResponse>
<BoundingBox minx="0" maxy="1" maxx="1" CRS="EPSG:2154" miny="0"/>
<Layer name="qgis_popup">
<Feature id="1">
<Attribute name="OBJECTID" value="2662" />
Expand Down

0 comments on commit 4c14094

Please sign in to comment.