From 5289020d441f89a38436ca18eaca5352cb7e7436 Mon Sep 17 00:00:00 2001 From: glax Date: Sun, 9 Apr 2023 21:02:32 +0200 Subject: [PATCH] correct node for closest. --- Pathfinding/RegionManager.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Pathfinding/RegionManager.cs b/Pathfinding/RegionManager.cs index b318958..f82a633 100644 --- a/Pathfinding/RegionManager.cs +++ b/Pathfinding/RegionManager.cs @@ -95,14 +95,13 @@ namespace Pathfinding hasConnectionUsingVehicle = false; foreach (OsmEdge edge in node.edges) { - byte speed = GetSpeedForEdge(node, edge.wayId, vehicle); - if (speed != 0) + if (TestValidConnectionForType(node, edge, vehicle)) hasConnectionUsingVehicle = true; } } double nodeDistance = Utils.DistanceBetween(node, coordinates); - if (nodeDistance < distance && hasConnectionUsingVehicle) + if (hasConnectionUsingVehicle && nodeDistance < distance) { closest = node; distance = nodeDistance; @@ -121,7 +120,7 @@ namespace Pathfinding { case Tag.SpeedType.pedestrian: speed = Tag.defaultSpeedPedestrian[wayType]; - return speed is not 0 ? speed : (byte)0; + return speed; case Tag.SpeedType.car: byte? maxSpeed = (byte?)tags.GetTag(wayId, Tag.TagType.maxspeed); speed = Tag.defaultSpeedCar[wayType];