glax
b87d8a0300
Pathfinder now finds the result and returns itself. Pathfinder includes PathResult for later usage.
41 lines
1.5 KiB
C#
41 lines
1.5 KiB
C#
using System.Drawing;
|
|
using System.Drawing.Imaging;
|
|
using OSMDatastructure;
|
|
using OSMDatastructure.Graph;
|
|
using Pathfinding;
|
|
using RenderPath;
|
|
|
|
namespace Server;
|
|
|
|
public class Server
|
|
{
|
|
|
|
public static void Main(string[] args)
|
|
{
|
|
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 (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);
|
|
|
|
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
|
|
}
|
|
} |