geopython / geopython/pygml

Parsing GML from owslib fails with UnboundLocalError

Open
#6 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
20
Forks
8
PR merge metrics
No merged PRs in 30d

Description

I'm trying to parse a Geography Markup Language (GML) string as returned by [owslib](https://geopython.github.io/OWSLib/usage.html#wfs) 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
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'BYBasis-DLM#DTK2575003AX_KommunalesGebietDEBYBDLMjK0001BW02016-05-24T20:29:37Z6003Weiden i.d.OPf.Weiden i.d.OPf.Freistaat BayernOberpfalz093630005503715.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.325505832.00999956 4503039.55 5505870.15999956 4503060.21 5505852.12999956 4503089.39 5505819.14999956 4503065.62 5505832.00999956 4503039.55'
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.