westnordost / osm-legal-default-speeds

Infer default legal speed limits from OpenStreetMap tags
https://westnordost.github.io/osm-legal-default-speeds
BSD 3-Clause "New" or "Revised" License
21 stars 9 forks source link

Add wheel_restriction #16

Closed Flamedek closed 10 months ago

Flamedek commented 10 months ago

Wiki parsing failed with the following error:

Traceback (most recent call last):
  File "parser\parsers\parse_utils.py", line 126, in parse_speed_table
    parsed_speeds = speed_parse_func(speeds)
                    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "parser\parsers\osm_restrictions.py", line 92, in parse_speeds
    parse_tree = parser.parse(s)
                 ^^^^^^^^^^^^^^^
  File "Python\Python312\Lib\site-packages\lark\lark.py", line 581, in parse
    return self.parser.parse(text, start=start, on_error=on_error)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "Python\Python312\Lib\site-packages\lark\parser_frontends.py", line 106, in parse
    return self.parser.parse(stream, chosen_start, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "Python\Python312\Lib\site-packages\lark\parsers\earley.py", line 297, in parse
    to_scan = self._parse(lexer, columns, to_scan, start_symbol)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "Python\Python312\Lib\site-packages\lark\parsers\xearley.py", line 144, in _parse
    to_scan = scan(i, to_scan)
              ^^^^^^^^^^^^^^^^
  File "Python\Python312\Lib\site-packages\lark\parsers\xearley.py", line 118, in scan
    raise UnexpectedCharacters(stream, i, text_line, text_column, {item.expect.name for item in to_scan},
lark.exceptions.UnexpectedCharacters: No terminal matches 'w' in the current parser context, at line 2 col 7

95 (6 wheels)
      ^
Expected one of:
        * WEIGHT_UNIT
        * LENGTH_UNIT
        * TRAILERS
        * SEATS
        * NUMBER
        * AXLES

This PR adds support for the new wheels restriction

westnordost commented 10 months ago

Looks good, but why is there an added space 29 - 31?

Flamedek commented 10 months ago

They don't seem to be necessary and have now been removed

westnordost commented 10 months ago

Nice, I wasn't sure either. Thank you!