enzet / map-machine

Python renderer for OpenStreetMap with custom icons intended to display as many map features as possible
MIT License
515 stars 34 forks source link

Fix `placement` tag processing #128

Closed enzet closed 2 years ago

enzet commented 2 years ago

Reported by @Zero3 in #83:

This feature crashes map-machine when processing ways that are tagged with placement but not lanes (which is the case for ~3.000 ways according to the overpass turbo query way["placement"][!"lanes"]).

I think map-machine should handle that situation gracefully instead :).

Stack trace:

  File "C:\Users\Zero3\AppData\Roaming\Python\Python38\Scripts\map-machine-script.py", line 33, in <module>
    sys.exit(load_entry_point('map-machine==0.1.3', 'console_scripts', 'map-machine')())
  File "C:\Users\Zero3\AppData\Roaming\Python\Python38\site-packages\map_machine\main.py", line 32, in main
    mapper.render_map(arguments)
  File "C:\Users\Zero3\AppData\Roaming\Python\Python38\site-packages\map_machine\mapper.py", line 311, in render_map
    constructor.construct()
  File "C:\Users\Zero3\AppData\Roaming\Python\Python38\site-packages\map_machine\constructor.py", line 205, in construct
    self.construct_ways()
  File "C:\Users\Zero3\AppData\Roaming\Python\Python38\site-packages\map_machine\constructor.py", line 214, in construct_ways
    self.construct_line(way, [], [way.nodes])
  File "C:\Users\Zero3\AppData\Roaming\Python\Python38\site-packages\map_machine\constructor.py", line 273, in construct_line
    road: Road = Road(
  File "C:\Users\Zero3\AppData\Roaming\Python\Python38\site-packages\map_machine\feature\road.py", line 455, in __init__
    self.placement_offset += self.lanes[lane_number].get_width(
IndexError: list index out of range