OSM_Graph/Graph/Node.cs

16 lines
697 B
C#
Raw Permalink Normal View History

namespace Graph;
2024-07-23 15:33:16 +02:00
public class Node(float lat, float lon, Dictionary<ulong, KeyValuePair<ulong, bool>>? neighbors = null)
{
2024-07-23 15:33:16 +02:00
public readonly Dictionary<ulong, KeyValuePair<ulong, bool>> Neighbors = neighbors??new(); //nodeId, wayId, forward
public readonly float Lat = lat, Lon = lon;
public double DistanceTo(Node n2) => Utils.NodeUtils.DistanceBetween(this, n2);
public double DistanceTo(float latitude, float longitude) => Utils.NodeUtils.DistanceBetween(this, latitude, longitude);
public bool HasEdgeTo(ulong neighbor) => this.Neighbors.ContainsKey(neighbor);
public override string ToString()
{
return $"Node {Lat:00.000000} {Lon:000.000000}";
}
}