Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Parsing GML from owslib fails with UnboundLocalError

Abierto
#6 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
python
Área
data

Línea de trabajo

Comienza en el punto de entrada pygml.parse identificado en el traceback y reproduce el fallo con la respuesta WFS de OWSLib y el contenido GML proporcionados. Traza cómo se gestionan esta FeatureCollection y su geometría gml:MultiSurface; el trabajo estará terminado cuando el ejemplo se analice sin UnboundLocalError y el comportamiento esté cubierto por una comprobación de regresión adecuada.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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&amp;version=1.1.0&amp;request=DescribeFeatureType&amp;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>'
Lenguaje dominante
Python
Estrellas
20
Forks
8
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de geopython/pygml

Todos los issues de geopython/pygml

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.