[OSRM-talk] Forward and backward classes

Gábor Boskovits boskovits at gmail.com
Fri Sep 29 10:39:13 UTC 2017


Hello OSRM!

I'm glad to use this software, because it is so good, however I have a
question.

I would like to use forward and backward classes to determine which way an
osm way was traveled in a map matching.

Relevant part of my profile is:
result.forward_classes["forward"] = true
result.backward_classes["backward"] = true

I run osrm-routed on an extract of Hungary.

One of my queries that reproduce my problem is:
server/match/v1/truck/19.852143,47.721576;19.853562,47.
724074;19.854981,47.726622;19.857347,47.72879;19.859666,47.730988?steps=true

Result is:
{"code":"Ok","matchings":[{"confidence":0.984583,"
geometry":"{rgbH{jdxBoDqCaIiC}H_C_E{CqLyMwLoM","legs":[{"summary":"191127946,
191127948","weight":16.5,"duration":16.5,"steps":[{"
intersections":[{"classes":["backward"],"out":0,"entry":[
true],"bearings":[34],"location":[19.852143,47.721576]}],"geometry":"{rgbH{
jdxBaAcA","mode":"driving","maneuver":{"bearing_after":34,
"bearing_before":0,"location":[19.852143,47.721576],"type":"
depart"},"ref":"3","weight":2.5,"duration":2.5,"name":"
481358101","distance":45.1},{"intersections":[{"classes":["
backward"],"lanes":[{"valid":true,"indications":["straight"
]},{"valid":false,"indications":["right"]}],"out"
:0,"in":2,"entry":[true,true,false],"bearings":[30,60,210],
"location":[19.852477,47.721914]},{"classes":["backward"],"out":0,"in":2,"
entry":[true,false,false],"bearings":[15,90,210],"
location":[19.85277,47.722278]},{"classes":["backward"],"
out":0,"in":1,"entry":[true,false],"bearings":[15,195],"
location":[19.852874,47.72246]}],"geometry":"}tgbH_mdxBOKy at m@c at SoAk
@","mode":"driving","maneuver":{"bearing_after":28,
"bearing_before":32,"location":[19.852477,47.721914],"
modifier":"straight","type":"new name"},"ref":"3","weight":6.3,
"duration":6.3,"name":"439889154","distance":115.4},{
"intersections":[{"classes":["backward"],"out":0,"in":1,"
entry":[true,false],"bearings":[15,195],"location":[19.
853089,47.722863]},{"classes":["backward"],"out":0,"in":1,"
entry":[true,false],"bearings":[15,195],"location":[19.
853458,47.723777]}],"geometry":"{zgbHypdxBw at Wo@Sm at Qa@Ky at S","
mode":"driving","maneuver":{"bearing_after":16,"bearing_
before":19,"location":[19.853089,47.722863],"modifier":"straight","type":"new
name"},"ref":"3","weight":7.7,"duration":7.7,"name":"
191127948","distance":139.3},{"intersections":[{"in":0,"
entry":[true],"bearings":[193],"location":[19.853562,47.
724074]}],"geometry":"mbhbHwsdxB","mode":"driving","
maneuver":{"bearing_after":0,"bearing_before":13,"location":
[19.853562,47.724074],"type":"arrive"},"ref":"3","weight":0,
"duration":0,"name":"191127947","distance":0}],"
distance":299.8},{"summary":"191127947, 411473365","weight":17.1,"
duration":17.1,"steps":[{"intersections":[{"classes":["
backward"],"out":0,"entry":[true],"bearings":[13],"location":[19.853562,47.
724074]}],"geometry":"mbhbHwsdxBiAY","mode":"driving","maneuver":{"bearing_
after":13,"bearing_before":0,"location":[19.853562,47.
724074],"type":"depart"},"ref":"3","weight":2.4,"duration":
2.4,"name":"191127947","distance":41.6},{"intersections":[{"classes":["
backward"],"out":0,"in":1,"entry":[true,false],"bearings"
:[15,195],"location":[19.85369,47.724438]}],"geometry":"wdhbHqtdxByBg at e@O_@
QYMYMUKMGQKQMOKSQWUSS[WKM","mode":"driving","maneuver":{"
bearing_after":11,"bearing_before":12,"location":[19.
85369,47.724438],"modifier":"straight","type":"new
name"},"ref":"3","weight":14.7,"duration":14.7,"name":"
411473365","distance":263.8},{"intersections":[{"in":0,"
entry":[true],"bearings":[215],"location":[19.854981,47.
726622]}],"geometry":"krhbHs|dxB","mode":"driving","
maneuver":{"bearing_after":0,"bearing_before":35,"location":
[19.854981,47.726622],"type":"arrive"},"ref":"3","weight":0,
"duration":0,"name":"411473365","distance":0}],"
distance":305.4},{"summary":"481358093, 195817621","weight":16.1,"
duration":16.1,"steps":[{"intersections":[{"classes":["
backward"],"out":0,"entry":[true],"bearings":[35],"location":[19.854981,47.
726622]},{"classes":["backward"],"out":0,"in":1,"
entry":[true,false],"bearings":[30,210],"location":[19.
855085,47.726722]}],"geometry":"krhbHs|dxBSUmBqB","mode":"
driving","maneuver":{"bearing_after":35,"bearing_before":0,"
location":[19.854981,47.726622],"type":"depart"},"ref"
:"3","weight":4.9,"duration":4.9,"name":"411473365","distance":88.4},{"
intersections":[{"classes":["backward"],"lanes":[{"valid":
false,"indications":["left"]},{"valid":true,"indications":["
straight"]}],"out":0,"in":2,"entry":[true,false,false,true]
,"bearings":[30,90,210,315],"location":[19.855664,47.72727]
},{"classes":["forward"],"out":0,"in":2,"entry":[false,true,
false],"bearings":[30,45,210],"location":[19.856632,47.
728166]},{"classes":["forward"],"out":0,"in":1,"entry":[
true,false,false],"bearings":[30,210,225],"location":[19.
857225,47.728672]}],"geometry":"mvhbH{`exBiAoAiBqBcBwBWW","
mode":"driving","maneuver":{"bearing_after":35,"bearing_
before":35,"location":[19.855664,47.72727],"modifier":"straight","type":"new
name"},"ref":"3","weight":11.2,"duration":11.2,"name":"
195817621","distance":210.8},{"intersections":[{"in":0,"
entry":[true],"bearings":[215],"location":[19.857347,47.
72879]}],"geometry":"}_ibHmkexB","mode":"driving","
maneuver":{"bearing_after":0,"bearing_before":35,"location":
[19.857347,47.72879],"type":"arrive"},"ref":"3","weight":0,
"duration":0,"name":"481358057","distance":0}],"
distance":299.2},{"summary":"481358057","weight":15,"
duration":15,"steps":[{"intersections":[{"classes":["
forward"],"out":0,"entry":[true],"bearings":[35],"
location":[19.857347,47.72879]}],"geometry":"}_ibHmkexBaEgEuFgG","mode":"
driving","maneuver":{"bearing_after":35,"bearing_before":0,"
location":[19.857347,47.72879],"type":"depart"},"ref":"3","
weight":15,"duration":15,"name":"481358057","distance":
299.7},{"intersections":[{"in":0,"entry":[true],"bearings":[
216],"location":[19.859665,47.730988]}],"geometry":"umibH}
yexB","mode":"driving","maneuver":{"bearing_after":0,"
bearing_before":36,"location":[19.859665,47.730988],"type":"
arrive"},"ref":"3","weight":0,"duration":0,"name":"
481358057","distance":0}],"distance":299.7}],"weight_
name":"routability","weight":64.7,"duration":64.7,"distance":1204.1}],"
tracepoints":[{"alternatives_count":0,"waypoint_index":0,"
matchings_index":0,"hint":"cRcKgHQXCgAEAAAAGQAAAA0AAAAAAA
AABAAAABkAAAANAAAAAAAAADIBAABv6y4BaCzYAm_rLgFoLNgCAQAfArt6ix4=","name":
"481358101","location":[19.852143,47.721576]},{"alternatives_count":0,"
waypoint_index":1,"matchings_index":0,"hint":"dM8AgHcXCgASAAAAGAAAAAAAAAAAAA
AAEgAAABgAAAAAAAAAAAAAADIBAAD68C4BKjbYAvrwLgEqNtgCAADfALt6ix
4=","name":"191127947","location":[19.853562,47.
724074]},{"alternatives_count":0,"waypoint_index":2,"
matchings_index":0,"hint":"eBcKgCqAEAAEAAAACAAAAI8AAAAAAA
AABAAAAAgAAACPAAAAAAAAADIBAACF9i4BHkDYAoX2LgEeQNgCDgA_
Art6ix4=","name":"411473365","location":[19.854981,47.
726622]},{"alternatives_count":0,"waypoint_index":3,"
matchings_index":0,"hint":"5o0AgP___38IAAAASgAAAAAAAABrAQAACAAAAEo
AAAAAAAAAawEAADIBAADD_y4BlkjYAsP_LgGWSNgCAAAvArt6ix4=","name":"
481358057","location":[19.857347,47.72879]},{"alternatives_count":2,"
waypoint_index":4,"matchings_index":0,"hint":"5o0AgP___
39UAAAAwQAAAEoAAACqAAAAVAAAAMEAAABKAAAAqgAAADIBAADRCC8BLFHYA
tIILwEsUdgCAQA_Art6ix4=","name":"481358057","location":[
19.859665,47.730988]}]}

Relevant part of result extracted with jq .matchings[0].legs[2].steps[1] is:
{
  "intersections": [
    {
      "classes": [
        "backward"
      ],
      "lanes": [
        {
          "valid": false,
          "indications": [
            "left"
          ]
        },
        {
          "valid": true,
          "indications": [
            "straight"
          ]
        }
      ],
      "out": 0,
      "in": 2,
      "entry": [
        true,
        false,
        false,
        true
      ],
      "bearings": [
        30,
        90,
        210,
        315
      ],
      "location": [
        19.855664,
        47.72727
      ]
    },
    {
      "classes": [
        "forward"
      ],
      "out": 0,
      "in": 2,
      "entry": [
        false,
        true,
        false
      ],
      "bearings": [
        30,
        45,
        210
      ],
      "location": [
        19.856632,
        47.728166
      ]
    },
    {
      "classes": [
        "forward"
      ],
      "out": 0,
      "in": 1,
      "entry": [
        true,
        false,
        false
      ],
      "bearings": [
        30,
        210,
        225
      ],
      "location": [
        19.857225,
        47.728672
      ]
    }
  ],
  "geometry": "mvhbH{`exBiAoAiBqBcBwBWW",
  "mode": "driving",
  "maneuver": {
    "bearing_after": 35,
    "bearing_before": 35,
    "location": [
      19.855664,
      47.72727
    ],
    "modifier": "straight",
    "type": "new name"
  },
  "ref": "3",
  "weight": 11.2,
  "duration": 11.2,
  "name": "195817621",
  "distance": 210.8
}

My problem is, that in this step there is at first an intersection with
class backward, the two with forward. This mainfests in my logic as a
u-turn on this segment, but this segment is clearly traveled in one
direction.

My questions are:
1. is this behaviour expected?
2. is my approach to detecting direction correct?
3. is there any better way of detecting direction?

Thanks in advance, Gábor

Version information:
HEAD detached at 7702ebd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/osrm-talk/attachments/20170929/ede05415/attachment-0001.html>


More information about the OSRM-talk mailing list