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

No proper time parser in ebnf #20

Closed Nadyita closed 1 month ago

Nadyita commented 1 month ago

Hey guys!

I just noticed that when running the parser, it currently bails on the Wiki entry 30 (Mo-Fr 08:00-17:00; PH SH off). Yes, this is invalid, but even if I fix it to be 30 (Mo-Fr 08:00-17:00; PH,SH off), I noticed the parser supports neither off, nor list of weekdays, not semicolons at all. I fixed this in a dev branch of mine, but I was wondering if that's even worth pushing if the resulting data cannot be parsed by your library. The generated JSON looks like this:

      {
        "name": "school zone",
        "tags": {
          "maxspeed": "50",
          "maxspeed:conditional": "30 @ (Mo-Fr 08:00-17:00; PH,SH off)"
        }
      },

So is it worth PRing my changes, or is there no plan to support date/time-ranges like this one anyway?

westnordost commented 1 month ago

What parser? The parser that parses the wiki page or the parser that parses the JSON?

What exactly is the issue? Is there an error? Is the entry not displayed?

Nadyita commented 1 month ago

Oh sorry if that was unclear. So the parser in parser/ (the one writtern in Python) has some issues parsing the current wiki page. This is due to the wiki-entry 30 (Mo-Fr 08:00-17:00; PH SH off). Simply put, there are 5 issues:

  1. The wiki page should read 30 (Mo-Fr 08:00-17:00; PH,SH off)
  2. The python parser that parses the wiki to JSON doesn't know PH, or SH (and also So instead of Su)
  3. The python parser that parses the wiki to JSON doesn't knowcomma-separated weekedays
  4. The python parser that parses the wiki to JSON doesn't know off
  5. The python parser that parses the wiki to JSON doesn't know semicolon-separated list of times

I have all this fixed in my local branch, and now my question is: is it worth pushing this as a PR, or would the Kotlin code then bail out, because it's unable to deal with "maxspeed:conditional": "30 @ (Mo-Fr 08:00-17:00; PH,SH off)"?

Currently, that python-based parser throws an exception, which is why I startwed investigating.

Update: I created a PR, so you can see for yourself what I fixed.