correct node for closest.

This commit is contained in:
glax 2023-04-09 21:02:32 +02:00
parent bb789e731d
commit 5289020d44

View File

@ -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];