kshitijrajsharma / geojson2osm

Geojson To OSM Xml
MIT License
2 stars 1 forks source link

Index out of range way.nodes[0] #3

Open Beakerboy opened 6 months ago

Beakerboy commented 6 months ago

file: https://github.com/Beakerboy/OSM_Imports/blob/main/Ky_Public_Hunting_Areas.geojson

error:


File "/opt/hostedtoolcache/Python/3.11.8/x64/lib/python3.11/site-packages/geojson2osm/geojson2osm.py", line 193, in process_multi_polygon
    way.nodes.append(way.nodes[0])
                     ~~~~~~~~~^^^
IndexError: list index out of range
Beakerboy commented 6 months ago

It looks like you do not have any test coverage for most of this function: https://coveralls.io/builds/66757461/source?filename=src%2Fgeojson2osm%2Fgeojson2osm.py

kshitijrajsharma commented 5 months ago

Correct , Thanks

Beakerboy commented 5 months ago

Did you mean to close this? My pull request did not include any additional tests for the Geojson2osm.py file. I only added coverage for my new file. This bug is still present unless you changed something.

kshitijrajsharma commented 5 months ago

Apologies I confused with another issue , I meant to close previous one

Beakerboy commented 5 months ago

I’m trying to narrow down the issue. The problematic file is this

Beakerboy commented 5 months ago

I have not tested yet, but this looks suspicious. Should this:

if node_hash not in nodes_index:
    node = Node(point, {})
    nodes.append(node)
    nodes_index[node_hash] = node
    way.nodes.append(node)

instead be:

if node_hash not in nodes_index:
    node = Node(point, {})
    nodes.append(node)
    nodes_index[node_hash] = node

way.nodes.append(nodes_index[node_hash])

I think you want the node added the way in all cases, if it’s a new point or a point that has appeared in some other way.