a-b-street / osm2lanes

A common library and set of test cases for transforming OSM tags to lane specifications
https://a-b-street.github.io/osm2lanes/
Apache License 2.0
34 stars 2 forks source link

Default speed limits via `westnordost/osm-legal-default-speeds` #244

Open tordans opened 2 years ago

tordans commented 2 years ago

For those cases where no maxspeed is given, osm2lanes could test out https://github.com/westnordost/osm-legal-default-speeds to get a set of default speed limits per country.

Unfortunately that would only work if no maxspeed is given; otherwise osm2lanes would need to compare what is received (or interpreted) from OSM with what the library responds with and try to merge both, which I image would be hard given the complexity of the table that the library relies on.

dabreegster commented 2 years ago

Thanks for forwarding!

If maxspeed is explicitly given, we could probably trust it. Maybe in the eventual web editor interface, we could warn if the tagged value disagrees significantly with the legal default.

We may have to figure out how to actually call this library, but it runs natively and on web, so it should be possible. Or maybe we just consume https://github.com/westnordost/osm-legal-default-speeds/blob/master/demo/distribution/legal_default_speeds.json (or rather, use the Python script to generate up-to-date values)

westnordost commented 2 years ago

Unfortunately that would only work if no maxspeed is given

Reverse search is implemented too: https://westnordost.github.io/osm-legal-default-speeds/#tags=maxspeed%3D100&cc=DE

Or maybe we just consume https://github.com/westnordost/osm-legal-default-speeds/blob/master/demo/distribution/legal_default_speeds.json

So in other words, port the code that interprets that JSON (to Rust) (?)

Possible, it is about ~1000 lines of code (without test code).

About 700 lines of code is the parsing of the filter expression syntax as used in the second table on the wiki page, the rest is the matching logic.

However, the library should be callable from native code as Kotlin can be compiled to native. Though, I have never tried it and don't know what it would take to do that.

dabreegster commented 2 years ago

However, the library should be callable from native code as Kotlin can be compiled to native. Though, I have never tried it and don't know what it would take to do that.

We'd also need to compile to WASM to run in web browsers, but this should work too. It's more a question of how much it complicates the build process to have non-Rust dependencies. I can investigate this when I find more time to focus on osm2lanes