appropriate names in PathResult for nodes gSCoreNodes

This commit is contained in:
glax 2023-04-19 22:02:15 +02:00
parent 055a751c9d
commit 9e0c4f65db
2 changed files with 6 additions and 6 deletions

View File

@ -8,16 +8,16 @@ public class PathResult
[JsonInclude]public TimeSpan calcTime; [JsonInclude]public TimeSpan calcTime;
[JsonInclude]public List<PathNode> pathNodes; [JsonInclude]public List<PathNode> pathNodes;
[JsonInclude]public Dictionary<ulong, double>? gScore; [JsonInclude]public Dictionary<ulong, double>? gScore;
[JsonInclude]public HashSet<OsmNode>? nodes; [JsonInclude]public HashSet<OsmNode>? gScoreNodes;
public string? name { get; set; } public string? name { get; set; }
[JsonConstructor] [JsonConstructor]
public PathResult(TimeSpan calcTime, List<PathNode> pathNodes, Dictionary<ulong, double>? gScore, HashSet<OsmNode>? nodes) public PathResult(TimeSpan calcTime, List<PathNode> pathNodes, Dictionary<ulong, double>? gScore, HashSet<OsmNode>? gScoreNodes)
{ {
this.calcTime = calcTime; this.calcTime = calcTime;
this.pathNodes = pathNodes; this.pathNodes = pathNodes;
this.gScore = gScore; this.gScore = gScore;
this.nodes = nodes; this.gScoreNodes = gScoreNodes;
} }
public PathResult(TimeSpan calcTime, List<PathNode> pathNodes) public PathResult(TimeSpan calcTime, List<PathNode> pathNodes)
@ -36,11 +36,11 @@ public class PathResult
public void AddGScores(Dictionary<OsmNode, double> gScore) public void AddGScores(Dictionary<OsmNode, double> gScore)
{ {
this.gScore = new(); this.gScore = new();
this.nodes = new(); this.gScoreNodes = new();
foreach (KeyValuePair<OsmNode, double> kv in gScore) foreach (KeyValuePair<OsmNode, double> kv in gScore)
{ {
this.gScore.Add(kv.Key.nodeId, kv.Value); this.gScore.Add(kv.Key.nodeId, kv.Value);
this.nodes.Add(kv.Key); this.gScoreNodes.Add(kv.Key);
} }
} }
} }

View File

@ -33,10 +33,10 @@ public static class Pathfinder
{ {
Console.WriteLine("Path found."); Console.WriteLine("Path found.");
PathResult path = GetPath(cameFromDict, goalNode, regionManager, DateTime.Now - startCalc); PathResult path = GetPath(cameFromDict, goalNode, regionManager, DateTime.Now - startCalc);
path.AddGScores(gScore);
string fileName = $"{new DirectoryInfo(workingDir).Name}-{DateTime.Now.ToFileTime()}.result"; string fileName = $"{new DirectoryInfo(workingDir).Name}-{DateTime.Now.ToFileTime()}.result";
string outputFilepath = Path.Join(Directory.GetParent(workingDir)!.FullName, fileName); string outputFilepath = Path.Join(Directory.GetParent(workingDir)!.FullName, fileName);
path.name = outputFilepath; path.name = outputFilepath;
path.AddGScores(gScore);
SaveGraph(path, outputFilepath); SaveGraph(path, outputFilepath);
return path; return path;
} }