Fixed result to correct time and no path error handling
This commit is contained in:
parent
bf08f38a1e
commit
585a9213ce
@ -19,7 +19,7 @@ app.MapGet("/getRoute", (float latStart, float lonStart, float latEnd, float lon
|
||||
{
|
||||
DateTime startCalc = DateTime.Now;
|
||||
List<PathNode> result = Pathfinder.AStarDistance("D:/stuttgart-regbez-latest", new Coordinates(latStart, lonStart), new Coordinates(latEnd, lonEnd));
|
||||
PathResult pathResult = new PathResult(startCalc - DateTime.Now, result);
|
||||
PathResult pathResult = new PathResult(DateTime.Now - startCalc, result);
|
||||
return pathResult;
|
||||
}
|
||||
);
|
||||
@ -48,15 +48,18 @@ app.Run();
|
||||
internal class PathResult
|
||||
{
|
||||
[JsonInclude]public TimeSpan calcTime;
|
||||
[JsonInclude] public double pathWeight;
|
||||
[JsonInclude] public double pathTravelDistance;
|
||||
[JsonInclude] public double pathWeight = double.PositiveInfinity;
|
||||
[JsonInclude] public double pathTravelDistance = double.PositiveInfinity;
|
||||
[JsonInclude]public List<PathNode> pathNodes;
|
||||
|
||||
public PathResult(TimeSpan calcTime, List<PathNode> pathNodes)
|
||||
{
|
||||
this.calcTime = calcTime;
|
||||
this.pathNodes = pathNodes;
|
||||
this.pathWeight = pathNodes.Last().currentPathWeight;
|
||||
this.pathTravelDistance = pathNodes.Last().currentPathLength;
|
||||
if (pathNodes.Count > 0)
|
||||
{
|
||||
this.pathWeight = pathNodes.Last().currentPathWeight;
|
||||
this.pathTravelDistance = pathNodes.Last().currentPathLength;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user