From 13ccec924521e10837b801212dd20266827ecbd3 Mon Sep 17 00:00:00 2001 From: glax Date: Tue, 23 Jul 2024 17:08:21 +0200 Subject: [PATCH] Add direction-tag check to GetDirection --- OSM_Graph/Way.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OSM_Graph/Way.cs b/OSM_Graph/Way.cs index b54e0bf..300c740 100644 --- a/OSM_Graph/Way.cs +++ b/OSM_Graph/Way.cs @@ -20,9 +20,10 @@ public class Way(ulong id, Dictionary tags, List nodeIds) "-1" => WayDirection.Backwards, _ => WayDirection.Both }; - HighwayType[] impliedTypes = [HighwayType.motorway, HighwayType.motorway_link, HighwayType.primary, HighwayType.primary_link]; + bool direction = !Tags.TryGetValue("direction", out string? directionStr) || directionStr == "forwards"; + HighwayType[] impliedTypes = [HighwayType.motorway, HighwayType.motorway_link, HighwayType.primary_link]; if (impliedTypes.Contains(GetHighwayType())) - return WayDirection.Forwards; + return direction ? WayDirection.Forwards : WayDirection.Backwards; return WayDirection.Both; }