OSMServer/Pathfinding/PathNode.cs
2023-02-03 23:44:15 +01:00

27 lines
770 B
C#

using OSMDatastructure;
namespace Pathfinding;
public class PathNode : OSMDatastructure.Node
{
PathNode? previousNode = null;
private Dictionary<Connection, double> distanceDictionary = new();
double currentWeight = double.MaxValue;
public PathNode(float lat, float lon) : base(lat, lon)
{
}
public double? DistanceTo(Connection connection)
{
if (!this.GetConnections().Contains(connection))
return null; //TODO exception is not actually connected
if (!this.distanceDictionary.ContainsKey(connection))
this.distanceDictionary.Add(connection, Utils.DistanceBetween(this, connection.endNodeCoordinates));
return this.distanceDictionary[connection];
}
}