[OSRM-talk] Example of restricted access flags for way_function and turn_function

Michael Krasnyk michael.krasnyk at gmail.com
Sat Jul 1 18:00:15 UTC 2017


Hi Mateusz,

for turn restrictions you can use https://wiki.openstreetmap.
org/wiki/Relation:restriction  OSM tag.

Here is an example https://github.com/Project-OSRM/osrm-backend/blob/
e2e279bc852cd024aef1ad445a81bad2884902cd/features/car/
restrictions.feature#L11-L34 that  is similar to yours with nodes mapping
w->A, j->B, e->C, w->D.
Turns that are restricted via restriction relations will not be used to
generate edge-based graph edges. Flags source_restricted and
target_restricted as pointed by Daniel  are used to mark turns to or from
restricted or private areas and simply make turn penalty higher but still
allow the turn.

I don't think that profile tricks to pass information from way_function to
turn_function via a Lua context is a good idea, but still can be used as a
workaround.
But you have to take care about two points:
* Lua contexts are in a thread-local storage, so only single-threaded
execution with a single context is possible
* ExtractionTurn in include/extractor/extraction_turn.hpp does not contain
references to ways, so it must be extended

Regards,
Michael








On Sat, Jul 1, 2017 at 6:21 PM, Mateusz Loskot <mateusz at loskot.net> wrote:

> Daniel,
>
> Thanks for the pointers. I'll check them in details.
>
> So, I understand purpose of turn_function is to tweak penalty based on
> restrictions.
>
> I'm wondering about slightly different use case and I'm trying to
> understand which
> tool, way_function or turn_function or neither, is the right way to use.
> Shortly, in my use case a restriction is related to allowed/disallowed
> turn from one link to another.
> Let's consider simple network.
>
> C
> |
> B---A
> |
> D
>
> Let's assume, all links are bidirectional ways.
> Node B includes information about turn restriction like so:
> - turning from AB link to BD link is disallowed
> - turning from AB link to CB link is allowed
>
> AFAIU, object in turn_function has no context related to B node and
> adjecent links to,
> eg. calculate artificial high penalty to effectively block AB to BD turn
> I'm also not sure there is way to include necessary context details in
> object passed to way_function.
>
> But, perhaps I'm missing some advanced profile tricks here.
> So, does processing of such restrictions fit purpose of turn_function at
> all?
>
> One of feasible alternative approaches is to pre-process such network
> splitting the B node to B and B-prim
>
> A - B - C
> C - B' - D
>
> This would effectively disable travelling along A - B - D
>
> I'll appreciate any comments.
>
> Best regards,
> Mateusz
>
>
>
>
> On 1 July 2017 at 10:41, Daniel Hofmann <hofmann at mapbox.com> wrote:
> > You are correct, the way function can set a "restricted" flag per way
> (and
> > direction), which you can then use in the turn function to put a high
> > penalty on turns from/to "restricted" ways.
> >
> > The general idea is outlined here:
> >
> > https://www.openstreetmap.org/user/happygo/diary/40564
> >
> > Have a look at ExtractionWay, ExtractionTurn and the
> EdgeBasedGraphFactory.
> >
> > Cheers,
> > Daniel J H
> >
> > On Sat, Jul 1, 2017 at 12:08 AM, Mateusz Loskot <mateusz at loskot.net>
> wrote:
> >>
> >> Hi,
> >>
> >> I'm trying to learn about use of the way_function result flags,
> >> forward_restricted and backward_restricted, and their correspondence
> >> with turn_function machinery, especially input source_restricted and
> >> target_restricted flags.
> >>
> >> Is there any data and profile example which shoes these in action?
> >>
> >> I guess, way_function is called first and any of the restriction flags
> set
> >> here for the link are passed to turn_function. Correct?
> >>
> >> Disclaimer: I haven't looked into OSRM implementation details yet,
> >> which, once grasped, I guess, might be enlightening.
> >>
> >> Best regards,
> >> --
> >> Mateusz Loskot, http://mateusz.loskot.net
>
>
> --
> Mateusz Loskot, http://mateusz.loskot.net
>
> _______________________________________________
> OSRM-talk mailing list
> OSRM-talk at openstreetmap.org
> https://lists.openstreetmap.org/listinfo/osrm-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/osrm-talk/attachments/20170701/735e2dec/attachment.html>


More information about the OSRM-talk mailing list