Giter Site home page Giter Site logo

westnordost / osm-legal-default-speeds Goto Github PK

View Code? Open in Web Editor NEW
20.0 20.0 7.0 2.52 MB

Infer default legal speed limits from OpenStreetMap tags

Home Page: https://westnordost.github.io/osm-legal-default-speeds

License: BSD 3-Clause "New" or "Revised" License

Kotlin 84.49% Python 15.51%
maxspeed openstreetmap osm

osm-legal-default-speeds's People

Contributors

easbar avatar flamedek avatar ianthetechie avatar karussell avatar tordans avatar westnordost avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

osm-legal-default-speeds's Issues

Set the website field for this repo

You should set the website field for this repo (in the about bit top right of the code homepage) to the demo page!

Nice little site too by the way!

Performance tuning

We tried to integrate the library into GraphHopper but we are currently facing a rather big slow down. E.g. for this PBF we normally have an import time of around 23sec and with the latest integration this takes ~60-70s. For planet PBF the slow down exists too but the bigger problem in these cases are the memory errors like GC overhead limit exceeded that don't go away even with 20GB more RAM.

As the GC seems to be very active it could be also the reason for the slow down but I'm unsure as although I gave it several GBs it wasn't faster. I also tried to reduce the regex compilations with a cache but without success.

What only helped was to avoid calling limitSpeedsTo. For that I replaced createResultTags with:

if (exactRoadType != null) {
  val result = exactRoadType.tags.toMutableMap()
  result.putAll(tags.filter { !it.isImplicitMaxSpeed })
  return Result(exactRoadType.name, result, Certitude.Exact)
}

Is it possible to make calling this optional? The reduction of the other speeds is not really needed in our case as we would reduce it ourselves via Math.min which would be simpler+faster. (Or maybe do this only when fetched from the map but a custom map implementation would be necessary)

I tried to avoid the pattern matching and used indexOfs instead and the improvement was significant but not enough for us (only down to 33sec).

Provide method to check if OSM tag is used or return list of involved tags

See discussion here:

Alternatively, we could add a new method to the default speed limits library that outputs all tags used by the currently loaded legal speed limits, so that no maintenance of this functionality is needed.

A method might be a bit better suited as one could also test if tag "startsWith" a certain string etc.

cannot parse wiki

I'm relative sure I did something incorrectly. Maybe when I added Indonesia to the wiki or are there certain requirements for the python version?

I followed the readme and tried to create the json with:

python parser/main.py

but I got:


Traceback (most recent call last):
  File "/home/user/code/osm-legal-default-speeds/parser/parsers/parse_utils.py", line 126, in parse_speed_table
    parsed_speeds = speed_parse_func(speeds)
  File "/home/user/code/osm-legal-default-speeds/parser/parsers/osm_restrictions.py", line 92, in parse_speeds
    parse_tree = parser.parse(s)
  File "/home/user/.pyenv/versions/3.8.3/lib/python3.8/site-packages/lark/lark.py", line 581, in parse
    return self.parser.parse(text, start=start, on_error=on_error)
  File "/home/user/.pyenv/versions/3.8.3/lib/python3.8/site-packages/lark/parser_frontends.py", line 106, in parse
    return self.parser.parse(stream, chosen_start, **kw)
  File "/home/user/.pyenv/versions/3.8.3/lib/python3.8/site-packages/lark/parsers/earley.py", line 297, in parse
    to_scan = self._parse(lexer, columns, to_scan, start_symbol)
  File "/home/user/.pyenv/versions/3.8.3/lib/python3.8/site-packages/lark/parsers/xearley.py", line 144, in _parse
    to_scan = scan(i, to_scan)
  File "/home/user/.pyenv/versions/3.8.3/lib/python3.8/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 'a' in the current parser context, at line 1 col 30

55 mph (articulated),55 mph (agricultural)
                             ^
Expected one of: 
	* NUMBER
	* EVENT
	* WEIGHT_QUALIFIER
	* MONTH
	* LPAR
	* WEIGHT
	* WEEKDAY
	* TIME
	* RESTRICTION_CONDITIONAL


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "parser/main.py", line 31, in <module>
    result = parse_speed_table(speed_table, parse_speeds)
  File "/home/user/code/osm-legal-default-speeds/parser/parsers/parse_utils.py", line 129, in parse_speed_table
    warnings.append(f'{country_and_subdivision_name}: Unable to parse \'{vehicle_type}\' for \'{road_type}\'')
NameError: name 'country_and_subdivision_name' is not defined

Include dependency in JVM project fails

from graphhopper/graphhopper#2392

To reproduce, it should be enough to create a new Java or Kotlin project and try to include this library (unconfirmed).

Execution failed for task ':compileKotlin'.
> Error while evaluating property 'filteredArgumentsMap' of task ':compileKotlin'
   > Could not resolve all files for configuration ':compileClasspath'.
      > Could not resolve de.westnordost:osm-legal-default-speeds:1.1.
        Required by:
            project :
         > No matching variant of de.westnordost:osm-legal-default-speeds:1.1 was found. The consumer was configured to find an API of a library compatible with Java 11, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' but:
             - Variant 'nativeApiElements-published' capability de.westnordost:osm-legal-default-speeds:1.1 declares a library:
                 - Incompatible because this component declares a usage of 'kotlin-api' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native' and the consumer needed an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm'
                 - Other compatible attributes:
                     - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                     - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                     - Doesn't say anything about its target Java version (required compatibility with Java 11)
                     - Doesn't say anything about its elements (required them packaged as a jar)

This error doesn't ring a bell, but some keywords (nativeApiElements-published etc.) may be useful to search for details on this error.

support for maxspeed:forward & backward

Should the library support this tagging?

A tagging like maxspeed:forward=80 could be recognized and returned as maxspeed=80 or the tag could be just copied into the output (and maxspeed should be avoided).

If it is not supported then a consumer might get the wrong maxspeed I think. (but maybe I'm using it wrong - let me know :) )

maxspeed:advisory=130 although no motorway

For

junction=roundabout
highway=tertiary
rural=yes

I get:

maxspeed:advisory=130
...

Is this a bug?

Please note that I do not get this tagging in the wild but I provide "rural=yes" in the replacerFn as
(name, eval) -> eval.invoke() || "rural".equals(name)

Handle `source:maxspeed=DE:zone*` or `maxspeed:type=DE:zone*`

In Germany, I noticed that some data has a source-tag but no explicit maxspeed tag.

This is the case for the value DE:rural (or urban) which are supported by the app for both variants

However, there is also a "zone" schema, that is not yet supported. In the time I invested to look into this I did not figure out why there are so many different ways to describe the same information (as far as I can tell), but I found multiple combinations of key and value with "zone" in it.

Taginfo:

Examples from the app:

There are some more variants in https://github.com/FixMyBerlin/osm-scripts/blob/main/utils/Highways-MaxspeedData/utils/addMaxspeedProperty.ts or https://github.com/FixMyBerlin/osm-scripts/blob/main/utils/Highways-MaxspeedData/utils/addMaxspeedSourceProperty.ts#L61-L73.


Suggestions on what to do with this…

  • Add a list of unsupported special cases to the readme (with link on the demo page)
  • Add support for those special cases

PS: I hope, at some point someone will take the time to cleanup that tagging mess …

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.