Parsing GML from owslib fails with UnboundLocalError
评估
调研方向
从 traceback 中确定的入口点 pygml.parse 开始,使用提供的 OWSLib WFS 响应和 GML 内容重现该故障。跟踪此 FeatureCollection 及其 gml:MultiSurface 几何图形的处理方式;完成标准是示例能够在没有 UnboundLocalError 的情况下完成解析,并且该行为由适当的回归检查覆盖。
由索引模型根据 Issue 内容生成。
描述
I'm trying to parse a Geography Markup Language (GML) string as returned by owslib when querying a Web Feature Service (WFS). Unfortunately, this fails with UnboundLocalError.
Example:
from owslib.wfs import WebFeatureService
import pygml
wfs11 = WebFeatureService(url='http://geoserv.weichand.de:8080/geoserver/wfs', version='1.1.0')
response = wfs11.getfeature(typename='bvv:gmd_ex', bbox=(4500000,5500000,4500500,5500500), srsname='urn:x-ogc:def:crs:EPSG:31468')
content = response.read()
geom = pygml.parse(content)
Result:
Traceback (most recent call last):
File "/data/gholl/checkouts/protocode/mwe/pygml-unboundlocalerror.py", line 6, in <module>
geom = pygml.parse(content)
File "/data/gholl/mambaforge/envs/py310/lib/python3.10/site-packages/pygml/parse.py", line 58, in parse
return Geometry(result)
UnboundLocalError: local variable 'result' referenced before assignment
The first 2000 characters of content are:
b'<?xml version="1.0" encoding="UTF-8"?><wfs:FeatureCollection xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:bvv="http://www.geodaten.bayern.de" xmlns:wfs="http://www.opengis.net/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:ows="http://www.opengis.net/ows" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" numberOfFeatures="4" timeStamp="2022-07-22T10:52:20.920Z" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd http://www.geodaten.bayern.de http://geoserv.weichand.de:8080/geoserver/wfs?service=WFS&version=1.1.0&request=DescribeFeatureType&typeName=bvv%3Agmd_ex"><gml:featureMembers><bvv:gmd_ex gml:id="gmd_ex.795"><bvv:land>BY</bvv:land><bvv:modellart>Basis-DLM#DTK25</bvv:modellart><bvv:objart>75003</bvv:objart><bvv:objart_txt>AX_KommunalesGebiet</bvv:objart_txt><bvv:objid>DEBYBDLMjK0001BW</bvv:objid><bvv:hdu_x>0</bvv:hdu_x><bvv:beginn>2016-05-24T20:29:37Z</bvv:beginn><bvv:adm>6003</bvv:adm><bvv:bez_gem>Weiden i.d.OPf.</bvv:bez_gem><bvv:bez_krs>Weiden i.d.OPf.</bvv:bez_krs><bvv:bez_lan>Freistaat Bayern</bvv:bez_lan><bvv:bez_rbz>Oberpfalz</bvv:bez_rbz><bvv:sch>09363000</bvv:sch><bvv:geom><gml:MultiSurface srsName="urn:x-ogc:def:crs:EPSG:31468" srsDimension="2"><gml:surfaceMember><gml:Polygon><gml:exterior><gml:LinearRing><gml:posList>5503715.86999956 4518551.38 5503731.78999956 4518559.73 5503708.02999956 4518562.46 5503684.51999956 4518566.97 5503668.41999956 4518571.48 5503656.81999956 4518577.92 5503631.05999956 4518589.84 5503596.90999956 4518604.01 5503574.04999956 4518612.39 5503532.67999956 4518628.61 5503499.89999956 4518642.95 5503476.89999956 4518658.89 5503452.56999956 4518679.061 5503434.37899956 4518700.005 5503422.69599956 4518706.57 5503420.66999956 4518707.143 5503407.34399956 4518710.915 5503396.02899956 4518711.76 5503355.57999956 4518706.38 5503322.18999956 4518702.9 5503309.20999956 4518702.23 5503287.339'
The last 500 are:
b'4503293.03 5503289.13999956 4503279.32</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon></gml:surfaceMember><gml:surfaceMember><gml:Polygon><gml:exterior><gml:LinearRing><gml:posList>5505832.00999956 4503039.55 5505870.15999956 4503060.21 5505852.12999956 4503089.39 5505819.14999956 4503065.62 5505832.00999956 4503039.55</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon></gml:surfaceMember></gml:MultiSurface></bvv:geom></bvv:gmd_ex></gml:featureMembers></wfs:FeatureCollection>'
- 主要语言
- Python
- 星标
- 20
- 派生
- 9
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
geopython/pygml 的其他 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
huggingface/smolagents#3106 ·
维护者通常 2 天内回复
-
area:scripts area:tests bug priority:later
难度 2/5 1-3 小时 新手友好度 72/100
Ikalus1988/MisakaNet#4358 ·
维护者通常 1 天内回复
-
Discovered ports from service discovery are never propagated to modules in Module.load()可能已有人在做 @vishalmore90 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 70/100
OWASP/Nettacker#1828 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
aws-samples/sample-per-model-bedrock#708 ·
维护者通常 1 天内回复
-
maintenance
难度 2/5 1-3 小时 新手友好度 62/100