OSMServer/Pathfinding/PathResult.cs

27 lines
779 B
C#
Raw Permalink Normal View History

2023-04-21 18:35:02 +02:00
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Pathfinding;
public class PathResult
{
[JsonInclude]public double distance;
[JsonInclude]public double weight;
2023-04-22 17:49:27 +02:00
[JsonInclude]public TimeSpan calcTime;
[JsonInclude]public List<PathNode> pathNodes;
[JsonConstructor]
public PathResult(TimeSpan calcTime, List<PathNode> pathNodes, double distance, double weight)
{
this.calcTime = calcTime;
this.pathNodes = pathNodes;
this.distance = distance;
this.weight = weight;
}
2023-04-21 18:35:02 +02:00
public static PathResult PathresultFromFile(string filePath)
{
return JsonSerializer.Deserialize<PathResult>(new FileStream(filePath, FileMode.Open, FileAccess.Read,
FileShare.Read))!;
}
}