osmsharp :防止掉头

osmsharp : prevent u-turn

我需要使用 OsmSharp 实现自定义 GPS 路由引擎。我正在使用 Dykstra 路由引擎(在 WinForm 示例中)。该示例计算了最短的道路,但我想让掉头变得不可能(例如到达基地位置时)。

您将如何实现?我在代码中尝试了一些 "hacks" 但似乎没有任何效果。

[编辑]

我在这里找到了一些答案:https://github.com/OsmSharp/OsmSharp/issues/236

谢谢

视情况而定。

首先,OSM有turn restrictions which can be used for specifying that u-turns are forbidden (type=restriction + restriction=no_u_turn). Similarly they are used to allow only certain turns (restriction=only_right_turn and so on). Your routing engine will have to support relations以支持OSM的回合限制。

其次,您可以单独(或另外)尝试通过避免交叉路口的锐角来避免急转弯。理想情况下,这是通过添加惩罚来完成的,这样如果没有其他路由可用,路由器仍将采用该路由。