CustomAStar now returns ValueTuple with calctime and path as result
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using OSMDatastructure.Graph;
|
||||
using OSMImporter;
|
||||
using Pathfinding;
|
||||
@ -17,9 +18,10 @@ var app = builder.Build();
|
||||
|
||||
app.MapGet("/getRoute", (float latStart, float lonStart, float latEnd, float lonEnd) =>
|
||||
{
|
||||
List<PathNode> path = Pathfinder.CustomAStar("D:/stuttgart-regbez-latest", new Coordinates(latStart, lonStart), new Coordinates(latEnd, lonEnd),
|
||||
ValueTuple<TimeSpan, List<PathNode>> result = Pathfinder.CustomAStar("D:/stuttgart-regbez-latest", new Coordinates(latStart, lonStart), new Coordinates(latEnd, lonEnd),
|
||||
Tag.SpeedType.car);
|
||||
return path;
|
||||
PathResult pathResult = new PathResult(result.Item1, result.Item2);
|
||||
return pathResult;
|
||||
}
|
||||
);
|
||||
|
||||
@ -42,4 +44,20 @@ app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
app.Run();
|
||||
|
||||
internal class PathResult
|
||||
{
|
||||
[JsonInclude]public TimeSpan calcTime;
|
||||
[JsonInclude] public double pathWeight;
|
||||
[JsonInclude] public double pathTravelDistance;
|
||||
[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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user