Skip to content

Country-specific speed limits #175

Closed

Description

@raunilillemets

I am using GraphHopper to import OSM data and transform it to graph-based format for a certain program that we are currently using.

As we only work with one country's data at any time, I would like to use an class AreaSpecificCarFlagEncoder extends CarFlagEncoder that would receive the speed limits for a given area in beginning of work of the program.

(More sophisticated) alternative: input for AreaSpecificCarFlagEncoder would be N sets of (WKT geometries and sets of speed limits). AreaSpecificCarFlagEncoder would make sure that the geometries are non-intersecting; and if given way is fully in some area, then the given speed limit is used. If way is not inside any of the given areas, default values are used.
I do not know what would be the best course of action if way is partially in one or more areas. Perhaps it would be most suitable to use default speeds then.

Please comment.

Activity

  1. changed the title [-]Idea: AreaSpecificCarFlagEncoder[/-] [+]Idea: Country-specific speed limits[/+] on Mar 31, 2014
  2. added this to the 0.4 milestone on Mar 31, 2014
  3. raunilillemets commented on Apr 3, 2014

    @raunilillemets
    Author

    I reviewed Your changes in commit 2d1d038. Thank You for making the fields protected (and not final).

    Actually I hoped that You would implement the AreaSpecificCarFlagEncoder functionality Yourself (based on Your e-mail). Do You plan to add this functionality or did I mis-understood You?

  4. karussell commented on Apr 3, 2014

    @karussell
    Member

    Sure, if there is demand and time I'll implement this. But at the moment there are more important things to do.

  5. raunilillemets commented on Apr 3, 2014

    @raunilillemets
    Author

    Ok, understandable :)

  6. raunilillemets commented on Apr 3, 2014

    @raunilillemets
    Author

    Yes, this is entirely reasonable approach.

  7. changed the title [-]Idea: Country-specific speed limits[/-] [+]Country-specific speed limits[/+] on May 9, 2014
  8. removed this from the 0.4 milestone on May 17, 2014
  9. added this to the 0.5 milestone on Aug 18, 2014
  10. removed this from the 0.5 milestone on Jul 28, 2015
  11. ratrun commented on Aug 9, 2015

    @ratrun
    Contributor

    A country specific speed limit implementation should also allow handling of country specific access restrictions. It should provide the possibility to configure tables similar to http://wiki.openstreetmap.org/wiki/OSM_tags_for_routing/Access-Restrictions. The evaluation of these tables shoud be possible for all kinds of encoders, not just for cars.

  12. ratrun commented on Sep 14, 2015

    @ratrun
    Contributor

    I did some investiagtions how this feature could be implemented and found the following library, which does what is needed for reverse geocoding into a country code:
    https://github.com/bencampion/reverse-country-code
    This library does not use OSM data, but rather data from thematicmapping.org . This data is not as precise as the OSM, but I think that it would be sufficient for our purpose. Also the license should be OK.
    A totally different appraoch would be to extract the polygons on our own during parsing of the OSM data on the fly. In comparison to using the libraray mentioned or a similar library, I see a lot of draw-backs:

    1. It does not work for OSM extracs
    2. It increases the reader complexity
    3. It slows down graph Generation
    4. It will be problematic because from the sea-polygon discussions I know that the country releations will be frequently broken in OSM.

    First I thought that the reverse geo-coding task has similarities to the inner/outer city speed limit of issue #230, but after having looked on the code provided by jansoe I came to the conclusion that this is something quite different.
    Could you take a look on the library with your GIS expertiese? What approach do you prefer? I made some performance measurements with the lib and came to the conclusion that it is able to look up a lat/lon in an order of magnitute of about 0.1 ms on a 3 years old PC. I think that such performance should be sufficient.

  13. karussell commented on Sep 14, 2015

    @karussell
    Member

    Thanks for this idea!

    It does not work for OSM extracs

    valid point. We could still solve this with preprozessed and verified (less often updated) OSM geometry hosted somewhere at graphhopper.com and we fetch this data dynamically like we do with the elevation data.

    The biggest problem I see with the library is the strange commons license, which is very uncommon for software and we need to avoid that someone is bound to mention this library everywhere where GraphHopper is used. But we could ask the author if he would willing to relicense to LGPL or Apache License (preferred)

    I made some performance measurements with the lib and came to the conclusion that it is
    able to look up a lat/lon in an order of magnitute of about 0.1 ms on a 3 years old PC.

    Thanks, can you re-do your tests with 100 mio random points spread over EU and US? This way we know better what the impact for the import could be.

    The idea I have in mind will be faster as it will be based on a simple lookup via a kd-tree or quadtree. It is nearly identical to the procedure used in the already implemented city limits branch.

    I also tend to prefer similar techniques used for city and country specific stuff.

  14. karussell commented on Sep 14, 2015

    @karussell
    Member

    First I thought that the reverse geo-coding task has similarities to the inner/outer
    city speed limit of issue #230, but after having looked on the code provided by jansoe
    I came to the conclusion that this is something quite different.

    Ah, yes. No, it should be very similar. This is already very fast as no "in-polygon" check has to be done like in the proposed library, as there is just a boolean array where the index is calculated from the coordinates and this array is pre-calculated only once from any polygon list. The only extension would be to use integer/short instead of boolean to assign a number to one coordinate instead of just true/false (inside/outside of a city)

  15. ratrun commented on Sep 19, 2015

    @ratrun
    Contributor

    The 100mio test of reverse-country-code with following 50 mio runs in Europe and 50 mio runs in America

    // Europa
    lookup.getCountryCode(49+10*(rand.nextDouble()-0.5), 21 + 20*(rand.nextDouble()-0.5));
    // North America
    lookup.getCountryCode(46+10*(rand.nextDouble()-0.5), -107 + 30*(rand.nextDouble()-0.5));
    

    took 96 minutes 23 seconds on an Intel i7 [email protected] GHz. Do you think this is fast enough?

  16. karussell commented on Sep 19, 2015

    @karussell
    Member

    Hmmh, not that good. The full GH import of full Europe is faster so with that this would slow down everything too much, but this is also not suprising. So I would instead create a QuadTree (or an array at the beginning like done for the city limits) where we can check with a simple "array[index]" request which should be a lot faster

  17. karussell commented on Sep 19, 2015

    @karussell
    Member

    BTW: Thanks for this test!

  18. boldtrn commented on Nov 10, 2017

    @boldtrn
    Member

    This issue should be fixed with the SpatialRuleIndex #926. Will close here for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions