Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Parsing GML from owslib fails with UnboundLocalError

Đang mở
#6 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
data

Hướng nghiên cứu

Bắt đầu từ điểm vào pygml.parse được xác định trong traceback và tái hiện lỗi bằng phản hồi WFS của OWSLib cùng nội dung GML được cung cấp. Theo dõi cách FeatureCollection này và hình học gml:MultiSurface của nó được xử lý; công việc được hoàn tất khi ví dụ được phân tích mà không có UnboundLocalError và hành vi này được bao phủ bởi một kiểm tra hồi quy phù hợp.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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>'
Ngôn ngữ chính
Python
Star
20
Fork
8
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của geopython/pygml

Tất cả issue của geopython/pygml

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.