PathResult now only includes Path and calcTime.

Other fields have been moved to Pathfinder
This commit is contained in:
glax 2023-04-20 19:37:34 +02:00
parent 619cad61ee
commit 5a1dce9883

View File

@ -1,5 +1,4 @@
using System.Text.Json.Serialization;
using OSMDatastructure.Graph;
namespace Pathfinding;
@ -7,41 +6,11 @@ public class PathResult
{
[JsonInclude]public TimeSpan calcTime;
[JsonInclude]public List<PathNode> pathNodes;
[JsonInclude]public Dictionary<ulong, double>? gScore;
[JsonInclude]public HashSet<OsmNode>? gScoreNodes;
[JsonIgnore] public RegionManager? regionManager { get; set; }
public string? name { get; set; }
[JsonConstructor]
public PathResult(TimeSpan calcTime, List<PathNode> pathNodes, Dictionary<ulong, double>? gScore, HashSet<OsmNode>? gScoreNodes)
{
this.calcTime = calcTime;
this.pathNodes = pathNodes;
this.gScore = gScore;
this.gScoreNodes = gScoreNodes;
}
[JsonConstructor]
public PathResult(TimeSpan calcTime, List<PathNode> pathNodes)
{
this.calcTime = calcTime;
this.pathNodes = pathNodes;
}
public PathResult(TimeSpan calcTime, List<PathNode> pathNodes, Dictionary<OsmNode, double> gScore)
{
this.calcTime = calcTime;
this.pathNodes = pathNodes;
AddGScores(gScore);
}
public void AddGScores(Dictionary<OsmNode, double> gScore)
{
this.gScore = new();
this.gScoreNodes = new();
foreach (KeyValuePair<OsmNode, double> kv in gScore)
{
this.gScore.Add(kv.Key.nodeId, kv.Value);
this.gScoreNodes.Add(kv.Key);
}
}
}