Save Pathfinding result to file.

Load result for render.
This commit is contained in:
2023-04-13 19:18:25 +02:00
parent 08ebc9a26b
commit 055a751c9d
8 changed files with 123 additions and 50 deletions

View File

@ -16,23 +16,20 @@ var app = builder.Build();
app.MapGet("/getRoute", (float latStart, float lonStart, float latEnd, float lonEnd, Tag.SpeedType vehicle, double stayOnSameRoadPriority, double useHigherLevelRoadsPriority, double useRoadsWithLessJunctionsPriority) =>
{
DateTime startCalc = DateTime.Now;
List<PathNode> result = Pathfinder.AStar("D:/stuttgart-regbez-latest", new Coordinates(latStart, lonStart),
PathResult result = Pathfinder.AStar("D:/stuttgart-regbez-latest", new Coordinates(latStart, lonStart),
new Coordinates(latEnd, lonEnd), vehicle, useHigherLevelRoadsPriority, stayOnSameRoadPriority,
useRoadsWithLessJunctionsPriority);
PathResult pathResult = new PathResult(DateTime.Now - startCalc, result);
return pathResult;
return result;
}
);
app.MapGet("/getShortestRoute", (float latStart, float lonStart, float latEnd, float lonEnd) =>
{
DateTime startCalc = DateTime.Now;
List<PathNode> result = Pathfinder.AStar("D:/stuttgart-regbez-latest", new Coordinates(latStart, lonStart),
PathResult result = Pathfinder.AStar("D:/stuttgart-regbez-latest", new Coordinates(latStart, lonStart),
new Coordinates(latEnd, lonEnd), Tag.SpeedType.any, 0, 0,
0);
PathResult pathResult = new PathResult(DateTime.Now - startCalc, result);
return pathResult;
return result;
}
);
@ -57,14 +54,3 @@ app.MapControllers();
app.Run();
internal class PathResult
{
[JsonInclude]public TimeSpan calcTime;
[JsonInclude]public List<PathNode> pathNodes;
public PathResult(TimeSpan calcTime, List<PathNode> pathNodes)
{
this.calcTime = calcTime;
this.pathNodes = pathNodes;
}
}