Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetFeatureInfo - The XML can be a BoundingBox item and not a Layer item #61

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading