Working. Weight calculation is still wonky, as well as heuristic needing tuning.

This commit is contained in:
2023-04-11 01:04:19 +02:00
parent 2131ac4afe
commit 308579279b
6 changed files with 124 additions and 264 deletions

View File

@ -1,4 +1,3 @@
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
namespace OSMDatastructure.Graph;
@ -8,21 +7,8 @@ public class OsmNode
{
public ulong nodeId { get; }
public HashSet<OsmEdge> edges { get; set; }
public Coordinates coordinates { get; }
[JsonIgnore][NonSerialized]public OsmNode? previousPathNode = null;
[JsonIgnore][NonSerialized]public double currentPathWeight = double.MaxValue;
[JsonIgnore][NonSerialized]public double currentPathLength = double.MaxValue;
[JsonIgnore][NonSerialized]public double directDistanceToGoal = double.MaxValue;
public Coordinates coordinates { get; }
[OnDeserialized]
internal void SetDefaultValues(StreamingContext context)
{
currentPathWeight = double.MaxValue;
currentPathLength = double.MaxValue;
directDistanceToGoal = double.MaxValue;
}
public OsmNode(ulong nodeId, float lat, float lon)
{
this.nodeId = nodeId;
@ -53,9 +39,6 @@ public class OsmNode
public override string ToString()
{
if(previousPathNode is not null)
return $"{nodeId} {coordinates} ec:{edges.Count} d:{directDistanceToGoal} w:{currentPathWeight} l:{currentPathLength} p:{previousPathNode.nodeId}";
return
$"{nodeId} {coordinates} ec:{edges.Count} d:{directDistanceToGoal} w:{currentPathWeight} l:{currentPathLength} null";
return $"{nodeId} {coordinates} ec:{edges.Count}";
}
}