2023-02-06 17:32:55 +01:00
|
|
|
namespace OSMDatastructure;
|
|
|
|
|
2023-02-07 23:52:23 +01:00
|
|
|
public class OsmNode
|
2023-02-06 17:32:55 +01:00
|
|
|
{
|
2023-02-07 23:52:23 +01:00
|
|
|
public HashSet<OsmEdge> edges { get; }
|
2023-02-06 17:32:55 +01:00
|
|
|
public Coordinates coordinates { get; }
|
|
|
|
|
2023-02-07 23:52:23 +01:00
|
|
|
public OsmNode? previousPathNode = null;
|
2023-02-06 17:32:55 +01:00
|
|
|
public double currentPathWeight = double.MaxValue;
|
2023-02-07 23:52:23 +01:00
|
|
|
public double directDistanceToGoal = double.MaxValue;
|
2023-02-06 17:32:55 +01:00
|
|
|
|
2023-02-07 23:52:23 +01:00
|
|
|
public OsmNode(float lat, float lon)
|
2023-02-06 17:32:55 +01:00
|
|
|
{
|
|
|
|
this.edges = new();
|
|
|
|
this.coordinates = new Coordinates(lat, lon);
|
|
|
|
}
|
|
|
|
|
2023-02-07 23:52:23 +01:00
|
|
|
public OsmNode(Coordinates coordinates)
|
2023-02-06 17:32:55 +01:00
|
|
|
{
|
|
|
|
this.edges = new();
|
2023-02-07 23:52:23 +01:00
|
|
|
this.coordinates = coordinates;
|
2023-02-06 17:32:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public OsmEdge? GetEdgeToNode(OsmNode n)
|
|
|
|
{
|
|
|
|
foreach (OsmEdge e in this.edges)
|
|
|
|
if (e.neighborCoordinates.Equals(n.coordinates))
|
|
|
|
return e;
|
|
|
|
return null;
|
|
|
|
}
|
2023-02-08 18:08:01 +01:00
|
|
|
|
|
|
|
public override bool Equals(object? obj)
|
|
|
|
{
|
|
|
|
return obj != null && obj.GetType() == this.GetType() && ((OsmNode)obj).coordinates.Equals(this.coordinates);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
{
|
|
|
|
return HashCode.Combine(coordinates);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
{
|
2023-02-08 18:49:47 +01:00
|
|
|
if(this.previousPathNode != null)
|
|
|
|
return string.Format(
|
|
|
|
"NODE {0} Edges-Count: {1} previousPathNode: {2} currentPathWeight: {3} directDistanceToGoal: {4}",
|
|
|
|
this.coordinates.ToString(), this.edges.Count, this.previousPathNode.coordinates.ToString(),
|
|
|
|
this.currentPathWeight, this.directDistanceToGoal);
|
|
|
|
else
|
|
|
|
return string.Format(
|
|
|
|
"NODE {0} Edges-Count: {1} previousPathNode: NO PREVIOUS NODE currentPathWeight: {2} directDistanceToGoal: {3}",
|
|
|
|
this.coordinates.ToString(), this.edges.Count,
|
|
|
|
this.currentPathWeight, this.directDistanceToGoal);
|
2023-02-08 18:08:01 +01:00
|
|
|
}
|
2023-02-06 17:32:55 +01:00
|
|
|
}
|