<div dir="ltr"><div style="font-size:12.8px"><div>Hello OSRM!</div><div><br></div><div>I'm glad to use this software, because it is so good, however I have a question.</div><div><br></div><div>I would like to use forward and backward classes to determine which way an osm way was traveled in a map matching.</div><div><br></div><div>Relevant part of my profile is:</div><div>result.forward_classes["<wbr>forward"] = true</div><div>result.backward_classes["<wbr>backward"] = true</div><div><br></div><div>I run osrm-routed on an extract of Hungary.</div><div><br></div><div>One of my queries that reproduce my problem is:</div><div>server/match/v1/truck/19.<wbr>852143,47.721576;19.853562,47.<wbr>724074;19.854981,47.726622;19.<wbr>857347,47.72879;19.859666,47.<wbr>730988?steps=true</div><div><br></div><div>Result is:</div><div>{"code":"Ok","matchings":[{"<wbr>confidence":0.984583,"<wbr>geometry":"{rgbH{jdxBoDqCaIiC}<wbr>H_C_E{CqLyMwLoM","legs":[{"<wbr>summary":"191127946, 191127948","weight":16.5,"<wbr>duration":16.5,"steps":[{"<wbr>intersections":[{"classes":["<wbr>backward"],"out":0,"entry":[<wbr>true],"bearings":[34],"<wbr>location":[19.852143,47.<wbr>721576]}],"geometry":"{rgbH{<wbr>jdxBaAcA","mode":"driving","<wbr>maneuver":{"bearing_after":34,<wbr>"bearing_before":0,"location":<wbr>[19.852143,47.721576],"type":"<wbr>depart"},"ref":"3","weight":2.<wbr>5,"duration":2.5,"name":"<wbr>481358101","distance":45.1},{"<wbr>intersections":[{"classes":["<wbr>backward"],"lanes":[{"valid":<wbr>true,"indications":["straight"<wbr>]},{"valid":false,"<wbr>indications":["right"]}],"out"<wbr>:0,"in":2,"entry":[true,true,<wbr>false],"bearings":[30,60,210],<wbr>"location":[19.852477,47.<wbr>721914]},{"classes":["<wbr>backward"],"out":0,"in":2,"<wbr>entry":[true,false,false],"<wbr>bearings":[15,90,210],"<wbr>location":[19.85277,47.722278]<wbr>},{"classes":["backward"],"<wbr>out":0,"in":1,"entry":[true,<wbr>false],"bearings":[15,195],"<wbr>location":[19.852874,47.72246]<wbr>}],"geometry":"}tgbH_mdxBOKy@m<wbr>@c@SoAk@","mode":"driving","<wbr>maneuver":{"bearing_after":28,<wbr>"bearing_before":32,"location"<wbr>:[19.852477,47.721914],"<wbr>modifier":"straight","type":"<wbr>new name"},"ref":"3","weight":6.3,<wbr>"duration":6.3,"name":"<wbr>439889154","distance":115.4},{<wbr>"intersections":[{"classes":["<wbr>backward"],"out":0,"in":1,"<wbr>entry":[true,false],"bearings"<wbr>:[15,195],"location":[19.<wbr>853089,47.722863]},{"classes":<wbr>["backward"],"out":0,"in":1,"<wbr>entry":[true,false],"bearings"<wbr>:[15,195],"location":[19.<wbr>853458,47.723777]}],"geometry"<wbr>:"{zgbHypdxBw@Wo@Sm@Qa@Ky@S","<wbr>mode":"driving","maneuver":{"<wbr>bearing_after":16,"bearing_<wbr>before":19,"location":[19.<wbr>853089,47.722863],"modifier":"<wbr>straight","type":"new name"},"ref":"3","weight":7.7,<wbr>"duration":7.7,"name":"<wbr>191127948","distance":139.3},{<wbr>"intersections":[{"in":0,"<wbr>entry":[true],"bearings":[193]<wbr>,"location":[19.853562,47.<wbr>724074]}],"geometry":"<wbr>mbhbHwsdxB","mode":"driving","<wbr>maneuver":{"bearing_after":0,"<wbr>bearing_before":13,"location":<wbr>[19.853562,47.724074],"type":"<wbr>arrive"},"ref":"3","weight":0,<wbr>"duration":0,"name":"<wbr>191127947","distance":0}],"<wbr>distance":299.8},{"summary":"<wbr>191127947, 411473365","weight":17.1,"<wbr>duration":17.1,"steps":[{"<wbr>intersections":[{"classes":["<wbr>backward"],"out":0,"entry":[<wbr>true],"bearings":[13],"<wbr>location":[19.853562,47.<wbr>724074]}],"geometry":"<wbr>mbhbHwsdxBiAY","mode":"<wbr>driving","maneuver":{"bearing_<wbr>after":13,"bearing_before":0,"<wbr>location":[19.853562,47.<wbr>724074],"type":"depart"},"ref"<wbr>:"3","weight":2.4,"duration":<wbr>2.4,"name":"191127947","<wbr>distance":41.6},{"<wbr>intersections":[{"classes":["<wbr>backward"],"out":0,"in":1,"<wbr>entry":[true,false],"bearings"<wbr>:[15,195],"location":[19.<wbr>85369,47.724438]}],"geometry":<wbr>"wdhbHqtdxByBg@e@O_@<wbr>QYMYMUKMGQKQMOKSQWUSS[WKM","<wbr>mode":"driving","maneuver":{"<wbr>bearing_after":11,"bearing_<wbr>before":12,"location":[19.<wbr>85369,47.724438],"modifier":"<wbr>straight","type":"new name"},"ref":"3","weight":14.<wbr>7,"duration":14.7,"name":"<wbr>411473365","distance":263.8},{<wbr>"intersections":[{"in":0,"<wbr>entry":[true],"bearings":[215]<wbr>,"location":[19.854981,47.<wbr>726622]}],"geometry":"krhbHs|<wbr>dxB","mode":"driving","<wbr>maneuver":{"bearing_after":0,"<wbr>bearing_before":35,"location":<wbr>[19.854981,47.726622],"type":"<wbr>arrive"},"ref":"3","weight":0,<wbr>"duration":0,"name":"<wbr>411473365","distance":0}],"<wbr>distance":305.4},{"summary":"<wbr>481358093, 195817621","weight":16.1,"<wbr>duration":16.1,"steps":[{"<wbr>intersections":[{"classes":["<wbr>backward"],"out":0,"entry":[<wbr>true],"bearings":[35],"<wbr>location":[19.854981,47.<wbr>726622]},{"classes":["<wbr>backward"],"out":0,"in":1,"<wbr>entry":[true,false],"bearings"<wbr>:[30,210],"location":[19.<wbr>855085,47.726722]}],"geometry"<wbr>:"krhbHs|dxBSUmBqB","mode":"<wbr>driving","maneuver":{"bearing_<wbr>after":35,"bearing_before":0,"<wbr>location":[19.854981,47.<wbr>726622],"type":"depart"},"ref"<wbr>:"3","weight":4.9,"duration":<wbr>4.9,"name":"411473365","<wbr>distance":88.4},{"<wbr>intersections":[{"classes":["<wbr>backward"],"lanes":[{"valid":<wbr>false,"indications":["left"]},<wbr>{"valid":true,"indications":["<wbr>straight"]}],"out":0,"in":2,"<wbr>entry":[true,false,false,true]<wbr>,"bearings":[30,90,210,315],"<wbr>location":[19.855664,47.72727]<wbr>},{"classes":["forward"],"out"<wbr>:0,"in":2,"entry":[false,true,<wbr>false],"bearings":[30,45,210],<wbr>"location":[19.856632,47.<wbr>728166]},{"classes":["forward"<wbr>],"out":0,"in":1,"entry":[<wbr>true,false,false],"bearings":[<wbr>30,210,225],"location":[19.<wbr>857225,47.728672]}],"geometry"<wbr>:"mvhbH{`exBiAoAiBqBcBwBWW","<wbr>mode":"driving","maneuver":{"<wbr>bearing_after":35,"bearing_<wbr>before":35,"location":[19.<wbr>855664,47.72727],"modifier":"<wbr>straight","type":"new name"},"ref":"3","weight":11.<wbr>2,"duration":11.2,"name":"<wbr>195817621","distance":210.8},{<wbr>"intersections":[{"in":0,"<wbr>entry":[true],"bearings":[215]<wbr>,"location":[19.857347,47.<wbr>72879]}],"geometry":"}_<wbr>ibHmkexB","mode":"driving","<wbr>maneuver":{"bearing_after":0,"<wbr>bearing_before":35,"location":<wbr>[19.857347,47.72879],"type":"<wbr>arrive"},"ref":"3","weight":0,<wbr>"duration":0,"name":"<wbr>481358057","distance":0}],"<wbr>distance":299.2},{"summary":"<wbr>481358057","weight":15,"<wbr>duration":15,"steps":[{"<wbr>intersections":[{"classes":["<wbr>forward"],"out":0,"entry":[<wbr>true],"bearings":[35],"<wbr>location":[19.857347,47.72879]<wbr>}],"geometry":"}_<wbr>ibHmkexBaEgEuFgG","mode":"<wbr>driving","maneuver":{"bearing_<wbr>after":35,"bearing_before":0,"<wbr>location":[19.857347,47.72879]<wbr>,"type":"depart"},"ref":"3","<wbr>weight":15,"duration":15,"<wbr>name":"481358057","distance":<wbr>299.7},{"intersections":[{"in"<wbr>:0,"entry":[true],"bearings":[<wbr>216],"location":[19.859665,47.<wbr>730988]}],"geometry":"umibH}<wbr>yexB","mode":"driving","<wbr>maneuver":{"bearing_after":0,"<wbr>bearing_before":36,"location":<wbr>[19.859665,47.730988],"type":"<wbr>arrive"},"ref":"3","weight":0,<wbr>"duration":0,"name":"<wbr>481358057","distance":0}],"<wbr>distance":299.7}],"weight_<wbr>name":"routability","weight":<wbr>64.7,"duration":64.7,"<wbr>distance":1204.1}],"<wbr>tracepoints":[{"alternatives_<wbr>count":0,"waypoint_index":0,"<wbr>matchings_index":0,"hint":"<wbr>cRcKgHQXCgAEAAAAGQAAAA0AAAAAAA<wbr>AABAAAABkAAAANAAAAAAAAADIBAABv<wbr>6y4BaCzYAm_<wbr>rLgFoLNgCAQAfArt6ix4=","name":<wbr>"481358101","location":[19.<wbr>852143,47.721576]},{"<wbr>alternatives_count":0,"<wbr>waypoint_index":1,"matchings_<wbr>index":0,"hint":"<wbr>dM8AgHcXCgASAAAAGAAAAAAAAAAAAA<wbr>AAEgAAABgAAAAAAAAAAAAAADIBAAD6<wbr>8C4BKjbYAvrwLgEqNtgCAADfALt6ix<wbr>4=","name":"191127947","<wbr>location":[19.853562,47.<wbr>724074]},{"alternatives_count"<wbr>:0,"waypoint_index":2,"<wbr>matchings_index":0,"hint":"<wbr>eBcKgCqAEAAEAAAACAAAAI8AAAAAAA<wbr>AABAAAAAgAAACPAAAAAAAAADIBAACF<wbr>9i4BHkDYAoX2LgEeQNgCDgA_<wbr>Art6ix4=","name":"411473365","<wbr>location":[19.854981,47.<wbr>726622]},{"alternatives_count"<wbr>:0,"waypoint_index":3,"<wbr>matchings_index":0,"hint":"<wbr>5o0AgP___<wbr>38IAAAASgAAAAAAAABrAQAACAAAAEo<wbr>AAAAAAAAAawEAADIBAADD_<wbr>y4BlkjYAsP_<wbr>LgGWSNgCAAAvArt6ix4=","name":"<wbr>481358057","location":[19.<wbr>857347,47.72879]},{"<wbr>alternatives_count":2,"<wbr>waypoint_index":4,"matchings_<wbr>index":0,"hint":"5o0AgP___<wbr>39UAAAAwQAAAEoAAACqAAAAVAAAAME<wbr>AAABKAAAAqgAAADIBAADRCC8BLFHYA<wbr>tIILwEsUdgCAQA_Art6ix4=","<wbr>name":"481358057","location":[<wbr>19.859665,47.730988]}]}</div><div><br></div><div>Relevant part of result extracted with jq .matchings[0].legs[2].steps[1] is:</div><div>{</div><div>  "intersections": [</div><div>    {</div><div>      "classes": [</div><div>        "backward"</div><div>      ],</div><div>      "lanes": [</div><div>        {</div><div>          "valid": false,</div><div>          "indications": [</div><div>            "left"</div><div>          ]</div><div>        },</div><div>        {</div><div>          "valid": true,</div><div>          "indications": [</div><div>            "straight"</div><div>          ]</div><div>        }</div><div>      ],</div><div>      "out": 0,</div><div>      "in": 2,</div><div>      "entry": [</div><div>        true,</div><div>        false,</div><div>        false,</div><div>        true</div><div>      ],</div><div>      "bearings": [</div><div>        30,</div><div>        90,</div><div>        210,</div><div>        315</div><div>      ],</div><div>      "location": [</div><div>        19.855664,</div><div>        47.72727</div><div>      ]</div><div>    },</div><div>    {</div><div>      "classes": [</div><div>        "forward"</div><div>      ],</div><div>      "out": 0,</div><div>      "in": 2,</div><div>      "entry": [</div><div>        false,</div><div>        true,</div><div>        false</div><div>      ],</div><div>      "bearings": [</div><div>        30,</div><div>        45,</div><div>        210</div><div>      ],</div><div>      "location": [</div><div>        19.856632,</div><div>        47.728166</div><div>      ]</div><div>    },</div><div>    {</div><div>      "classes": [</div><div>        "forward"</div><div>      ],</div><div>      "out": 0,</div><div>      "in": 1,</div><div>      "entry": [</div><div>        true,</div><div>        false,</div><div>        false</div><div>      ],</div><div>      "bearings": [</div><div>        30,</div><div>        210,</div><div>        225</div><div>      ],</div><div>      "location": [</div><div>        19.857225,</div><div>        47.728672</div><div>      ]</div><div>    }</div><div>  ],</div><div>  "geometry": "mvhbH{`exBiAoAiBqBcBwBWW",</div><div>  "mode": "driving",</div><div>  "maneuver": {</div><div>    "bearing_after": 35,</div><div>    "bearing_before": 35,</div><div>    "location": [</div><div>      19.855664,</div><div>      47.72727</div><div>    ],</div><div>    "modifier": "straight",</div><div>    "type": "new name"</div><div>  },</div><div>  "ref": "3",</div><div>  "weight": 11.2,</div><div>  "duration": 11.2,</div><div>  "name": "195817621",</div><div>  "distance": 210.8</div><div>}</div><div><br></div><div>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.</div><div><br></div><div>My questions are:</div><div>1. is this behaviour expected?</div><div>2. is my approach to detecting direction correct?</div><div>3. is there any better way of detecting direction?</div><div><br></div><div>Thanks in advance, Gábor</div><div><br></div><div>Version information: </div></div><span style="font-size:12.8px">HEAD detached at 7702ebd</span><br></div>