From 9e72d50448bcd567d419e1687d1c89225c264120 Mon Sep 17 00:00:00 2001 From: glax Date: Sun, 9 Apr 2023 21:02:01 +0200 Subject: [PATCH] Fixed valid start and end nodes (for type) --- Pathfinding/Pathfinder.cs | 6 +++--- Pathfinding/Pathfinder_Distance.cs | 2 +- Pathfinding/Pathfinder_Time.cs | 4 +--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Pathfinding/Pathfinder.cs b/Pathfinding/Pathfinder.cs index e6a3f3a..ed11327 100644 --- a/Pathfinding/Pathfinder.cs +++ b/Pathfinding/Pathfinder.cs @@ -7,11 +7,11 @@ namespace Pathfinding; public static partial class Pathfinder { - private static ValueTuple SetupNodes(Coordinates startCoordinates, Coordinates goalCoordinates, RegionManager regionManager ) + private static ValueTuple SetupNodes(Coordinates startCoordinates, Coordinates goalCoordinates, RegionManager regionManager, Tag.SpeedType vehicle) { ValueTuple retTuple = new(); - retTuple.Item1 = regionManager.ClosestNodeToCoordinates(startCoordinates, Tag.SpeedType.any); - retTuple.Item2 = regionManager.ClosestNodeToCoordinates(goalCoordinates, Tag.SpeedType.any); + retTuple.Item1 = regionManager.ClosestNodeToCoordinates(startCoordinates, vehicle); + retTuple.Item2 = regionManager.ClosestNodeToCoordinates(goalCoordinates, vehicle); if (retTuple.Item1 is null || retTuple.Item2 is null) return retTuple; retTuple.Item1.currentPathWeight = 0; diff --git a/Pathfinding/Pathfinder_Distance.cs b/Pathfinding/Pathfinder_Distance.cs index c024751..8be74e7 100644 --- a/Pathfinding/Pathfinder_Distance.cs +++ b/Pathfinding/Pathfinder_Distance.cs @@ -9,7 +9,7 @@ public static partial class Pathfinder Coordinates goal) { RegionManager regionManager = new (workingDir); - ValueTuple startAndEndNode = SetupNodes(start, goal, regionManager); + ValueTuple startAndEndNode = SetupNodes(start, goal, regionManager, Tag.SpeedType.any); if (startAndEndNode.Item1 is null || startAndEndNode.Item2 is null) return new List(); OsmNode goalNode = startAndEndNode.Item2!; diff --git a/Pathfinding/Pathfinder_Time.cs b/Pathfinding/Pathfinder_Time.cs index 8b50d4a..65a4d7b 100644 --- a/Pathfinding/Pathfinder_Time.cs +++ b/Pathfinding/Pathfinder_Time.cs @@ -10,14 +10,13 @@ public static partial class Pathfinder Coordinates goal, Tag.SpeedType vehicle) { RegionManager regionManager = new (workingDir); - ValueTuple startAndEndNode = SetupNodes(start, goal, regionManager); + ValueTuple startAndEndNode = SetupNodes(start, goal, regionManager, vehicle); if (startAndEndNode.Item1 is null || startAndEndNode.Item2 is null) return new List(); OsmNode goalNode = startAndEndNode.Item2!; PriorityQueue toVisit = new(); toVisit.Enqueue(startAndEndNode.Item1, 0); - bool stop = false; while (toVisit.Count > 0) { @@ -53,7 +52,6 @@ public static partial class Pathfinder return GetRouteFromCalc(goalNode, regionManager); } - //stop = true; if (!toVisit.UnorderedItems.Any(item => item.Element.Equals(neighbor))) toVisit.Enqueue(neighbor, GetPriority(currentNode, currentNode.previousPathNode, edge, vehicle, regionManager)); }