[OSRM-talk] arrive to destination on the adequate side in two-way streets

Stephen Woodbridge woodbri at swoodbridge.com
Tue Mar 10 13:51:32 UTC 2015

On 3/10/2015 5:31 AM, Fernando Pacheco wrote:
> I understand the idea.
> I had imagined something similar but with existing spatial information
> and using OSRM directly.
> The definition of that stretch of the road goes from node i (OSM-Ni) to
> node j (OSM-Nj). The street is two-way. "A" is an intermediate point of
> my route (client). "a" is the nearest point of A on the street. The
> vehicles driven on the right side of the street.
>                           A
> OSM-Ni + --------------- a --------------- + OSM-Nj
> If A is the left side of the street: 1 - find the point nearest the
> street (a); 2 - add the node OSM-Nj (before node "a") to the route.
> OSM-Ni + --------------- a --------------- + OSM-Nj
>                           A
> If A is the right side of the street: 1 - find the point nearest the
> street (a); 2 - add the node OSM-Ni (before node "a") to the route.
> [The first point of the route should be approached in a similar way but
> the subsequent node is added after "a" (in flow direction).]
> Is this a possible approach to solve the problem with OSRM ?. Thank you
> very much. Fernando.

I see two problems with this approach:

1) you have to check the "from" location because if it is already on 
edge i-j then you have to adjust your calculations to deal with that. 
Say you vehicle location is currently midway between "a" and OSM-Nj and 
you want to get to "a" then you would not want route 
"from"->"OSM-Nj"->"a" instead you would just want "from"->"a"

OSM-Ni + --------------- a -------from-------- + OSM-Nj

This would also need to be done in the example I posted below.

2) OSRM does not provide access to the edge geometries (except to return 
the final route geometry) through the API so it would require keeping a 
copy of the geometries elsewhere like PostGIS or digging into the OSRM 
source code and see if it is possible to add code to find the geometry 
and do the calculations.

@Dennis, Any thoughts on how easy/hard this might be to do in the C++ 
code? and where would one start looking?


> El 09/03/15 a las 16:34, Stephen Woodbridge escribió:
>> On 3/9/2015 1:54 PM, Fernando Pacheco wrote:
>>> Hi all.
>>> We are developing an application for routing solid waste collection
>>> trucks. We use OSRM to calculate distances between collecting points
>>> (intermediate points).
>>> Some customers are located in two-way streets (simple, no separators)
>>> ... How can I say to OSRM that must arrive to the collecting points at
>>> the adequate side of the street? That is, on the side where the client
>>> is, without crossing the opposite direction of the street to access the
>>> load.
>>> Is it possible?. Thanks in advance. Fernando.
>> Hi Fernando,
>> When the street is represented as a single street center line, a via
>> point is just located on the street segment and then the route is
>> computed to that point. I do not believe there is any way to say arrive
>> at this node from a given direction.
>> One idea for a work around to this problem is to take advantage of the
>> fact that OSRM does not make u-turns at via points so it might be
>> possible if you know the location is on the right side of a street (in
>> right side drive countries) and you can access the geometry to generate
>> an additional via point before or after the collecting point and then
>> include both points in order in the route.
>> so for a simple street:
>>          B                 A
>> -----------------------------------
>>       C                  D
>> with 4 collection points and you want to collect A and B only when
>> traversing the street from right to left and C and D only when
>> traversing the street from left to right. So if we add the lower case
>> points a,b,c,d as:
>>          B  b              A  a
>> -----------------------------------
>>    c  C               d  D
>> Then we can compute a route from say Z (not shown) to A we would compute
>> the route Z-a-A and this should force OSRM to arrive at A after point a
>> and this would put it in the correct direction.
>> Say you want to route A to C then presumably you should be able to route
>> a-A-c-C, this makes some presumptions that would need to be validated
>> but the idea is that a-A forces the direction along the street for the
>> start of the route, then it would have to exit the left end of the
>> street and either make a u-turn or drive around a block and re-enter the
>> street from the left to get to c then to C moving in the correct direction.
>> But as you can see this greatly complicates the problem by potentially
>> doubling the number of nodes and requiring a lot of pre-computation to
>> assess the side and direction.
>> -Steve W
>> _______________________________________________
>> OSRM-talk mailing list
>> OSRM-talk at openstreetmap.org
>> https://lists.openstreetmap.org/listinfo/osrm-talk

More information about the OSRM-talk mailing list