OSM_Graph/Graph/Node.cs

16 lines
648 B
C#

namespace Graph;
public class Node(float lat, float lon, Dictionary<ulong, ulong>? neighbors = null)
{
public readonly Dictionary<ulong, ulong> Neighbors = neighbors??new(); //nodeId, wayId
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}";
}
}