Changed calls to new backend.
Pathfinder now finds the result and returns itself. Pathfinder includes PathResult for later usage.
This commit is contained in:
parent
23429c8a00
commit
b87d8a0300
@ -16,20 +16,19 @@ var app = builder.Build();
|
||||
|
||||
app.MapGet("/getRoute", (float latStart, float lonStart, float latEnd, float lonEnd, Tag.SpeedType vehicle, double stayOnSameRoadPriority, double useHigherLevelRoadsPriority, double useRoadsWithLessJunctionsPriority) =>
|
||||
{
|
||||
|
||||
PathResult result = Pathfinder.AStar("D:/stuttgart-regbez-latest", new Coordinates(latStart, lonStart),
|
||||
Pathfinder result = new Pathfinder("D:/stuttgart-regbez-latest").AStar(new Coordinates(latStart, lonStart),
|
||||
new Coordinates(latEnd, lonEnd), vehicle, useHigherLevelRoadsPriority, stayOnSameRoadPriority,
|
||||
useRoadsWithLessJunctionsPriority);
|
||||
return result;
|
||||
return result.pathResult;
|
||||
}
|
||||
);
|
||||
|
||||
app.MapGet("/getShortestRoute", (float latStart, float lonStart, float latEnd, float lonEnd) =>
|
||||
{
|
||||
PathResult result = Pathfinder.AStar("D:/stuttgart-regbez-latest", new Coordinates(latStart, lonStart),
|
||||
Pathfinder result = new Pathfinder("D:/stuttgart-regbez-latest").AStar(new Coordinates(latStart, lonStart),
|
||||
new Coordinates(latEnd, lonEnd), Tag.SpeedType.any, 0, 0,
|
||||
0);
|
||||
return result;
|
||||
return result.pathResult;
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using OSMDatastructure;
|
||||
using OSMDatastructure.Graph;
|
||||
using Pathfinding;
|
||||
@ -11,25 +12,30 @@ public class Server
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
ConsoleWriter newConsole = new ConsoleWriter();
|
||||
ConsoleWriter newConsole = new();
|
||||
Console.SetOut(newConsole);
|
||||
Console.SetError(newConsole);
|
||||
|
||||
string workingDir = "D:/stuttgart-regbez-latest";
|
||||
|
||||
//RegionConverter.ConvertXMLToRegions("D:/stuttgart-regbez-latest.osm", "D:/stuttgart-regbez-latest");
|
||||
//RegionConverter.ConvertXMLToRegions("D:/map.osm", "D:/map");
|
||||
//RegionConverter.ConvertXMLToRegions("D:/germany-latest.osm", "D:/germany-latest");
|
||||
|
||||
|
||||
Coordinates start = new Coordinates(48.7933798f, 9.8275859f);
|
||||
Coordinates finish = new Coordinates(48.795918f, 9.021618f);
|
||||
PathResult result = Pathfinder.AStar("D:/stuttgart-regbez-latest", start,
|
||||
Coordinates start = new (48.7933798f, 9.8275859f);
|
||||
Coordinates finish = new (48.795918f, 9.021618f);
|
||||
Pathfinder result = new Pathfinder(workingDir).AStar(start,
|
||||
finish, Tag.SpeedType.car, 0.01, 0.0001,
|
||||
0);
|
||||
|
||||
Console.WriteLine("Drawing area");
|
||||
ValueTuple<Image, Renderer.Bounds> area = Renderer.DrawArea(result.regionManager);
|
||||
|
||||
Console.WriteLine("Drawing route");
|
||||
Renderer.DrawGraph(result.name, area.Item1, area.Item2);
|
||||
string parentFolder = new DirectoryInfo(workingDir).Parent!.FullName;
|
||||
string resultFileName = $"{new DirectoryInfo(workingDir).Name}-{DateTime.Now.ToFileTime()}.result";
|
||||
result.SaveResult(Path.Join(parentFolder, resultFileName));
|
||||
|
||||
string renderFileName = $"{new DirectoryInfo(workingDir).Name}-{DateTime.Now.ToFileTime()}.render.png";
|
||||
Image render = Renderer.DrawPathfinder(result);
|
||||
#pragma warning disable CA1416
|
||||
render.Save(Path.Join(parentFolder, renderFileName), ImageFormat.Png);
|
||||
#pragma warning restore CA1416
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user