Description
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
[-]Idea: AreaSpecificCarFlagEncoder[/-][+]Idea: Country-specific speed limits[/+]making speed values better customizable e.g. for country specific spe…
raunilillemets commentedon Apr 3, 2014
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?
karussell commentedon Apr 3, 2014
Sure, if there is demand and time I'll implement this. But at the moment there are more important things to do.
raunilillemets commentedon Apr 3, 2014
Ok, understandable :)
raunilillemets commentedon Apr 3, 2014
Yes, this is entirely reasonable approach.
[-]Idea: Country-specific speed limits[/-][+]Country-specific speed limits[/+]ratrun commentedon Aug 9, 2015
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.
ratrun commentedon Sep 14, 2015
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:
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.
karussell commentedon Sep 14, 2015
Thanks for this idea!
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)
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.
karussell commentedon Sep 14, 2015
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)
ratrun commentedon Sep 19, 2015
The 100mio test of reverse-country-code with following 50 mio runs in Europe and 50 mio runs in America
took 96 minutes 23 seconds on an Intel i7 [email protected] GHz. Do you think this is fast enough?
karussell commentedon Sep 19, 2015
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
karussell commentedon Sep 19, 2015
BTW: Thanks for this test!
boldtrn commentedon Nov 10, 2017
This issue should be fixed with the SpatialRuleIndex #926. Will close here for now.