[OSRM-talk] How to force match service to return public transport routes only?

Patrick Agin agin.patrick at gmail.com
Tue May 1 18:18:50 UTC 2018


Understood.
Thanks Daniel,
Patrick

2018-05-01 11:23 GMT-04:00 Daniel Patterson <daniel at mapbox.com>:

> Hi Patrick,
>
>   Train ways are typically tagged directly with `train=<something>`.  Bus
> routes are typically not tagged directly on a way itself (because busses
> run on roads shared with other traffic), but rather, the way is a member of
> a bus route relation.
>
> daniel
>
> On Tue, May 1, 2018 at 8:05 AM, Patrick Agin <agin.patrick at gmail.com>
> wrote:
>
>> I understand but my question was (sorry if it was unclear), why is it
>> different between train and bus?
>>
>> 2018-05-01 10:02 GMT-04:00 Michal Palenik <michal.palenik at freemap.sk>:
>>
>>> On Tue, May 01, 2018 at 09:30:36AM -0400, Patrick Agin wrote:
>>> > Thanks Michal and Daniel for your help, I defined my subway profile
>>> and it
>>> > works well.
>>> >
>>> > Michal, can I ask you why you use this kind of code for the train
>>> profile:
>>> > train = way:get_value_by_key('train');
>>> > if ( not data. train or data. train =='') then return false;
>>>
>>> this checks way's tags
>>>
>>> >
>>> > and this kind of code for the bus:
>>> > bus = get_from_rel(relations, way, "route", "bus", "route");
>>> > if ( not data.bus =='') then return false;
>>>
>>> this one checks relations' tags (of relations that the way is a member
>>> of)
>>>
>>> > Aren't they defined the same way in osm data?
>>> > Patrick
>>> >
>>> > 2018-04-30 13:26 GMT-04:00 Patrick Agin <agin.patrick at gmail.com>:
>>> >
>>> > > Thanks again Michal I'll try it soon with subway instead of bus. Out
>>> of
>>> > > curiosity, why do you define highway in process_way function? It
>>> does not
>>> > > seem to be used elsewhere.
>>> > >
>>> > > 2018-04-30 13:03 GMT-04:00 Michal Palenik <michal.palenik at freemap.sk
>>> >:
>>> > >
>>> > >> On Mon, Apr 30, 2018 at 12:57:42PM -0400, Patrick Agin wrote:
>>> > >> > Thanks a lot to both of you. Michal, can I ask you two things:
>>> > >> > what's the purpose of adding tram and train to excludable?
>>> > >>
>>> > >> generally to ignore trains when they do not have a common ticketing
>>> > >> scheme.
>>> > >>
>>> > >> > and about get_from_rel(relations, way, "route", 'bus', "route")
>>> line, is
>>> > >> > 'bus' a reserved OSM word or is it defined by you?
>>> > >>
>>> > >> function get_from_rel(relations, way, "route", 'bus', "network")
>>> > >> will find first/random relation of route=bus which the way is a
>>> member
>>> > >> of, and then returns tag "network".
>>> > >>
>>> > >> see also
>>> > >> https://github.com/Project-OSRM/osrm-backend/issues/5032
>>> > >>
>>> > >> > I ask the question
>>> > >> > because I would like to manage subway routes.
>>> > >> > Patrick
>>> > >> >
>>> > >> > 2018-04-30 12:48 GMT-04:00 Michal Palenik <
>>> michal.palenik at freemap.sk>:
>>> > >> >
>>> > >> > > hi, I have it working
>>> > >> > > https://github.com/FreemapSlovakia/freemap-routing/blob/
>>> > >> master/oma-bus.lua
>>> > >> > > (and train profile below)
>>> > >> > >
>>> > >> > > michal
>>> > >> > >
>>> > >> > > On Mon, Apr 30, 2018 at 09:26:22AM -0700, Daniel Patterson
>>> wrote:
>>> > >> > > > Hi Patrick,
>>> > >> > > >
>>> > >> > > >   Nobody has written a "How to make a public transport
>>> profile"
>>> > >> document
>>> > >> > > > for OSRM, you'll have to piece it together from examples and
>>> reading
>>> > >> > > code.
>>> > >> > > >
>>> > >> > > >   That said, the "testbot" profile here:
>>> > >> > > > https://github.com/Project-OSRM/osrm-backend/blob/master/
>>> > >> > > profiles/testbot.lua
>>> > >> > > >
>>> > >> > > >   is fairly simple.  There are 3 functions: `process_node`,
>>> > >> > > `process_way`,
>>> > >> > > > and `process_turn`.  The `process_way` function is run for
>>> every
>>> > >> way in
>>> > >> > > the
>>> > >> > > > OSM file you input, and it decides whether to include it in
>>> the
>>> > >> routing
>>> > >> > > > graph (by setting properties on the `result` object), or to
>>> exclude
>>> > >> it
>>> > >> > > (by
>>> > >> > > > simply returning without doing any work).
>>> > >> > > >
>>> > >> > > >   As someone else pointed out in another thread, the `car.lua`
>>> > >> profile is
>>> > >> > > > pretty complex - it's developed over time, and has a lot of
>>> logic
>>> > >> in it
>>> > >> > > > that makes it hard to understand.  I'd start with the testbot
>>> > >> profile
>>> > >> > > > above, and add the stuff you think you need.
>>> > >> > > >
>>> > >> > > >   You might also want to take a look at
>>> > >> > > > https://github.com/Project-OSRM/osrm-frontend/tree/gh-pages/
>>> debug
>>> > >> which
>>> > >> > > is
>>> > >> > > > a web viewer that can show you what the routing graph looks
>>> like.
>>> > >> > > >
>>> > >> > > > daniel
>>> > >> > > >
>>> > >> > > > On Mon, Apr 30, 2018 at 8:39 AM, Patrick Agin <
>>> > >> agin.patrick at gmail.com>
>>> > >> > > > wrote:
>>> > >> > > >
>>> > >> > > > > Thanks again Daniel. Could you just give me an example
>>> (with a
>>> > >> snippet
>>> > >> > > of
>>> > >> > > > > code maybe) of a good implementation of point 1 (Lua
>>> profile that
>>> > >> only
>>> > >> > > > > includes public transport ways in the graph). I just don't
>>> have
>>> > >> any
>>> > >> > > clue
>>> > >> > > > > about implementing this and I'm not aware of any docs that
>>> could
>>> > >> help
>>> > >> > > me
>>> > >> > > > > with that.
>>> > >> > > > > Patrick
>>> > >> > > > >
>>> > >> > > > > 2018-04-30 11:30 GMT-04:00 Daniel Patterson <
>>> daniel at mapbox.com>:
>>> > >> > > > >
>>> > >> > > > >> Hi Patrick,
>>> > >> > > > >>
>>> > >> > > > >>   This could be tricky, depending on how long the traces
>>> you're
>>> > >> > > trying to
>>> > >> > > > >> match are.
>>> > >> > > > >>
>>> > >> > > > >>   The OSRM Lua profiles basically act as a filter - they
>>> decide
>>> > >> which
>>> > >> > > > >> ways from OSM are included in the routing graph, and assign
>>> > >> > > properties to
>>> > >> > > > >> edges in the graph.
>>> > >> > > > >>
>>> > >> > > > >>   The map-matching algorithm will try to snap your
>>> coordinate
>>> > >> list to
>>> > >> > > the
>>> > >> > > > >> most likely path across the routing graph.
>>> > >> > > > >>
>>> > >> > > > >>   In order to only snap to public transport paths, you'll
>>> need:
>>> > >> > > > >>
>>> > >> > > > >>     1) A Lua profile that only includes public transport
>>> ways in
>>> > >> the
>>> > >> > > > >> graph.
>>> > >> > > > >>     2) A way to ensure that all the public transport paths
>>> are
>>> > >> > > connected
>>> > >> > > > >> together (this could be difficult without including lots
>>> of extra
>>> > >> > > stuff you
>>> > >> > > > >> don't want in the graph)
>>> > >> > > > >>     3) GPS traces that are somewhat close to the actual
>>> paths
>>> > >> > > themselves,
>>> > >> > > > >> as mapped in OSM
>>> > >> > > > >>
>>> > >> > > > >>   (2) could be the really tricky bit here.  If the public
>>> > >> transport
>>> > >> > > paths
>>> > >> > > > >> are not connected, then any GPS trace you have that spans
>>> two
>>> > >> public
>>> > >> > > > >> transport routes (say, a bus change, or a train change)
>>> but those
>>> > >> > > routes
>>> > >> > > > >> aren't actually connected by the graph, will cause
>>> problems with
>>> > >> the
>>> > >> > > > >> map-matching algorithm.
>>> > >> > > > >>
>>> > >> > > > >> daniel
>>> > >> > > > >>
>>> > >> > > > >> On Mon, Apr 30, 2018 at 7:23 AM, Patrick Agin <
>>> > >> agin.patrick at gmail.com
>>> > >> > > >
>>> > >> > > > >> wrote:
>>> > >> > > > >>
>>> > >> > > > >>> Hi everyone,
>>> > >> > > > >>> I'm trying to define a profile to force match service to
>>> take
>>> > >> public
>>> > >> > > > >>> transport routes only. I tried to add residential in
>>> excludable
>>> > >> so I
>>> > >> > > can
>>> > >> > > > >>> add exclude=residential at query time but it does not
>>> change
>>> > >> > > anything to
>>> > >> > > > >>> the returned answer. Can someone help or point me towards
>>> > >> > > documentation
>>> > >> > > > >>> that could help (I've read profile.md but it does not
>>> help me
>>> > >> much).
>>> > >> > > > >>> Thanks a lot,
>>> > >> > > > >>> Patrick (newbie with osrm)
>>> > >> > > > >>>
>>> > >> > > > >>> _______________________________________________
>>> > >> > > > >>> OSRM-talk mailing list
>>> > >> > > > >>> OSRM-talk at openstreetmap.org
>>> > >> > > > >>> https://lists.openstreetmap.org/listinfo/osrm-talk
>>> > >> > > > >>>
>>> > >> > > > >>>
>>> > >> > > > >>
>>> > >> > > > >> _______________________________________________
>>> > >> > > > >> OSRM-talk mailing list
>>> > >> > > > >> OSRM-talk at openstreetmap.org
>>> > >> > > > >> https://lists.openstreetmap.org/listinfo/osrm-talk
>>> > >> > > > >>
>>> > >> > > > >>
>>> > >> > > > >
>>> > >> > > > > _______________________________________________
>>> > >> > > > > OSRM-talk mailing list
>>> > >> > > > > OSRM-talk at openstreetmap.org
>>> > >> > > > > https://lists.openstreetmap.org/listinfo/osrm-talk
>>> > >> > > > >
>>> > >> > > > >
>>> > >> > >
>>> > >> > > > _______________________________________________
>>> > >> > > > OSRM-talk mailing list
>>> > >> > > > OSRM-talk at openstreetmap.org
>>> > >> > > > https://lists.openstreetmap.org/listinfo/osrm-talk
>>> > >> > >
>>> > >> > >
>>> > >> > > --
>>> > >> > > michal palenik
>>> > >> > > www.freemap.sk
>>> > >> > > www.oma.sk
>>> > >> > >
>>> > >> > > _______________________________________________
>>> > >> > > OSRM-talk mailing list
>>> > >> > > OSRM-talk at openstreetmap.org
>>> > >> > > https://lists.openstreetmap.org/listinfo/osrm-talk
>>> > >> > >
>>> > >>
>>> > >> > _______________________________________________
>>> > >> > OSRM-talk mailing list
>>> > >> > OSRM-talk at openstreetmap.org
>>> > >> > https://lists.openstreetmap.org/listinfo/osrm-talk
>>> > >>
>>> > >>
>>> > >> --
>>> > >> michal palenik
>>> > >> www.freemap.sk
>>> > >> www.oma.sk
>>> > >>
>>> > >> _______________________________________________
>>> > >> OSRM-talk mailing list
>>> > >> OSRM-talk at openstreetmap.org
>>> > >> https://lists.openstreetmap.org/listinfo/osrm-talk
>>> > >>
>>> > >
>>> > >
>>>
>>> > _______________________________________________
>>> > OSRM-talk mailing list
>>> > OSRM-talk at openstreetmap.org
>>> > https://lists.openstreetmap.org/listinfo/osrm-talk
>>>
>>>
>>> --
>>> michal palenik
>>> www.freemap.sk
>>> www.oma.sk
>>>
>>> _______________________________________________
>>> OSRM-talk mailing list
>>> OSRM-talk at openstreetmap.org
>>> https://lists.openstreetmap.org/listinfo/osrm-talk
>>>
>>
>>
>> _______________________________________________
>> OSRM-talk mailing list
>> OSRM-talk at openstreetmap.org
>> https://lists.openstreetmap.org/listinfo/osrm-talk
>>
>>
>
> _______________________________________________
> 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/20180501/fae88fe2/attachment-0001.html>


More information about the OSRM-talk mailing list