Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use different profiles for different areas #333

Closed
emiltin opened this issue Jul 11, 2012 · 11 comments
Closed

use different profiles for different areas #333

emiltin opened this issue Jul 11, 2012 · 11 comments

Comments

@emiltin
Copy link
Contributor

emiltin commented Jul 11, 2012

in our region there's a number of municipality, who each have specific way to organize bike traffic. they often want this reflected in how the routes works in their area. some want to put a high a priority on cycleways, others don't.

the differences only get bigger when you route across countries. one example would be left/right side driving and turn restrictions.

so it might be useful to be able to change/override speedprofile/lua parameters depending on the area you're extracting.

@emiltin
Copy link
Contributor Author

emiltin commented Jan 29, 2013

renamed for clarity

@emiltin
Copy link
Contributor Author

emiltin commented Jun 3, 2013

Another exampe: trunk roads are cycleable by default in UK, but not in Denmark.

@emiltin
Copy link
Contributor Author

emiltin commented Mar 17, 2014

another use case: different default values per country, for example for max speed for various way types.

@emiltin
Copy link
Contributor Author

emiltin commented Mar 18, 2014

It could be done by calling Postgis from the lua profile for each way, to determine which country it's located it. The downsize is preprocesssing will be slower. Could OSRM provide an faster/easier way to determine which country each way is located in?

@danpat
Copy link
Member

danpat commented Jun 25, 2015

@TheMarex and I were discussing this in the context of turn profiles (left/right bias, depending on country).

It would also be useful to do this on an even-more-granular level, like state/province/city. One example for this is "right-turn-on-red", which is permitted in many north american locations, but is illegal in New York City, unless permitted by a sign. The same applies to Montréal. The traffic-light turn penalty should be lower where right-turn-on-red is permitted.

@TheMarex
Copy link
Member

I would like to implement this on a lua-level similar to how we implemented the raster feature.

  • function to load admin boundary polygons and build and index from them (R-Tree based + point-in-polygon test on lowest level)
  • function to query from lua get_country(bounding_box) which returns the country code like de or gb

Blocked by:

  • Not having the coordinate of the referenced nodes (=> no bounding box) when calling way_function

@TheMarex
Copy link
Member

We might want to expose this country information alongside with country specific information in the response. This includes:

  • handedness of the country (left, right)

/cc @1ec5

@danpat
Copy link
Member

danpat commented Jul 5, 2017

I started sketching out support for this in this PR: #4167

The aim here would be to supply a GeoJSON file with polygons defining the boundaries of the regions you're interested in, then the way_function would be passed a table of the regions that the current way belongs to.

@daniel-j-h
Copy link
Member

@TimMcCauley
Copy link

TimMcCauley commented Nov 17, 2020

@emiltin @danpat maybe you can help me out on a specific issue I am trying to solve. Given a polygon, e.g. Paris or London, am I able to decrease the OSM speeds by X percent with this location dependent data logic? The OSM speeds make total sense for more rural areas, however diving in to metropolitan regions and comparing them to proprietary services they are too optimistic (which obviously makes sense). I think a factor would do most of the job; I'm just trying to figure out the best approach (I also looked into the traffic data options, however this is already going a step further and if I understood it correctly this will update to absolute values given in the CSV).

@TimMcCauley
Copy link

TimMcCauley commented Nov 25, 2020

Leaving this information here for anybody trying to achieve the same. In your lua file you can add this snippet after the maxspeed etc. handling.

  ...
  forward_sp = result.forward_speed
  backward_sp = result.backward_speed

  factor = 1.0
  if way:get_location_tag('factoriseMe') then
    factor = 0.7
  end

  if forward_sp and forward_sp > 0 then
    result.forward_speed = forward_sp * factor
  end

  if backward_sp and backward_sp > 0 then
    result.backward_speed = backward_sp * factor
  end
  ...

And then just provide a (multi)polygon with something like factoriseMe in its properties. When you run osrm-extract...

docker run -t -v "${PWD}:/data" osrm/osrm-backend:v5.23.0 osrm-extract -p /data/car-custom.lua --location-dependent-data=/data/regionwhatever.geojson /data/britain-and-ireland-latest.osm.pbf

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

No branches or pull requests

5 participants