better readability
This commit is contained in:
parent
f42e458048
commit
72b5511c26
@ -39,7 +39,7 @@ public static class Pathfinder
|
|||||||
{
|
{
|
||||||
double newPotentialWeight =
|
double newPotentialWeight =
|
||||||
closestNodeToGoal.currentPathWeight + EdgeWeight(closestNodeToGoal, neighbor, edge.wayId, vehicle, ref regionManager);
|
closestNodeToGoal.currentPathWeight + EdgeWeight(closestNodeToGoal, neighbor, edge.wayId, vehicle, ref regionManager);
|
||||||
if (neighbor.currentPathWeight > newPotentialWeight)
|
if (newPotentialWeight < neighbor.currentPathWeight)
|
||||||
{
|
{
|
||||||
neighbor.previousPathNode = closestNodeToGoal;
|
neighbor.previousPathNode = closestNodeToGoal;
|
||||||
neighbor.currentPathWeight = newPotentialWeight;
|
neighbor.currentPathWeight = newPotentialWeight;
|
||||||
@ -79,15 +79,15 @@ public static class Pathfinder
|
|||||||
double distance = double.MaxValue;
|
double distance = double.MaxValue;
|
||||||
foreach (OsmNode node in region.nodes)
|
foreach (OsmNode node in region.nodes)
|
||||||
{
|
{
|
||||||
bool hasConnection = false;
|
bool hasConnectionUsingVehicle = false;
|
||||||
foreach (OsmEdge edge in node.edges)
|
foreach (OsmEdge edge in node.edges)
|
||||||
{
|
{
|
||||||
double speed = GetSpeed(node, edge.wayId, vehicle, ref regionManager);
|
double speed = GetSpeed(node, edge.wayId, vehicle, ref regionManager);
|
||||||
if (speed != 0)
|
if (speed != 0)
|
||||||
hasConnection = true;
|
hasConnectionUsingVehicle = true;
|
||||||
}
|
}
|
||||||
double nodeDistance = Utils.DistanceBetween(node, coordinates);
|
double nodeDistance = Utils.DistanceBetween(node, coordinates);
|
||||||
if (nodeDistance < distance && hasConnection)
|
if (nodeDistance < distance && hasConnectionUsingVehicle)
|
||||||
{
|
{
|
||||||
closest = node;
|
closest = node;
|
||||||
distance = nodeDistance;
|
distance = nodeDistance;
|
||||||
@ -110,12 +110,12 @@ public static class Pathfinder
|
|||||||
return 0;
|
return 0;
|
||||||
case Tag.SpeedType.car:
|
case Tag.SpeedType.car:
|
||||||
case Tag.SpeedType.road:
|
case Tag.SpeedType.road:
|
||||||
byte? maxspeed = (byte?)tags.GetTag(wayId, Tag.TagType.maxspeed);
|
byte? maxSpeed = (byte?)tags.GetTag(wayId, Tag.TagType.maxspeed);
|
||||||
if (maxspeed is not null)
|
if (maxSpeed is not null)
|
||||||
return (double)maxspeed;
|
return (double)maxSpeed;
|
||||||
maxspeed = Tag.defaultSpeedCar[wayType];
|
maxSpeed = Tag.defaultSpeedCar[wayType];
|
||||||
if(maxspeed is not 0)
|
if(maxSpeed is not 0)
|
||||||
return (byte)maxspeed;
|
return (byte)maxSpeed;
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
@ -128,7 +128,6 @@ public static class Pathfinder
|
|||||||
double speed = GetSpeed(node1, wayId, vehicle, ref regionManager);
|
double speed = GetSpeed(node1, wayId, vehicle, ref regionManager);
|
||||||
if (speed is not 0)
|
if (speed is not 0)
|
||||||
return distance / speed;
|
return distance / speed;
|
||||||
else
|
|
||||||
return double.PositiveInfinity;
|
return double.PositiveInfinity;
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user