diff --git a/API/API.csproj b/API/API.csproj
index d283d1f..bd07d6b 100644
--- a/API/API.csproj
+++ b/API/API.csproj
@@ -17,6 +17,7 @@
+
diff --git a/OSMServer.sln b/OSMServer.sln
index 4de78b3..185cd1f 100644
--- a/OSMServer.sln
+++ b/OSMServer.sln
@@ -8,6 +8,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pathfinding", "Pathfinding\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "API", "API\API.csproj", "{1D364F40-1681-4D36-A625-83B324F6AC89}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RenderPath", "RenderPath\RenderPath.csproj", "{54CAC127-4EB6-4E06-A5C8-35343C5FF76A}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -30,5 +32,9 @@ Global
{1D364F40-1681-4D36-A625-83B324F6AC89}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1D364F40-1681-4D36-A625-83B324F6AC89}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1D364F40-1681-4D36-A625-83B324F6AC89}.Release|Any CPU.Build.0 = Release|Any CPU
+ {54CAC127-4EB6-4E06-A5C8-35343C5FF76A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {54CAC127-4EB6-4E06-A5C8-35343C5FF76A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {54CAC127-4EB6-4E06-A5C8-35343C5FF76A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {54CAC127-4EB6-4E06-A5C8-35343C5FF76A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
diff --git a/RenderPath/RenderPath.csproj b/RenderPath/RenderPath.csproj
new file mode 100644
index 0000000..2a4d985
--- /dev/null
+++ b/RenderPath/RenderPath.csproj
@@ -0,0 +1,17 @@
+
+
+
+ net7.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
diff --git a/RenderPath/Renderer.cs b/RenderPath/Renderer.cs
new file mode 100644
index 0000000..da9cdaf
--- /dev/null
+++ b/RenderPath/Renderer.cs
@@ -0,0 +1,46 @@
+using System.Diagnostics.CodeAnalysis;
+using Pathfinding;
+using System.Drawing;
+using System.Drawing.Imaging;
+using OSMDatastructure.Graph;
+
+namespace RenderPath;
+
+public class Renderer
+{
+ [SuppressMessage("Interoperability", "CA1416:Plattformkompatibilität überprüfen")]
+ public static Bitmap DrawFromPath(List nodes)
+ {
+ float minLat = nodes.Min(node => node.coordinates.latitude);
+ float minLon = nodes.Min(node => node.coordinates.longitude);
+ float maxLat = nodes.Max(node => node.coordinates.latitude);
+ float maxLon = nodes.Max(node => node.coordinates.longitude);
+
+ float latDiff = maxLat - minLat;
+ float lonDiff = maxLon - minLon;
+
+ const int imageMaxSize = 10000;
+ float scaleFactor = latDiff > lonDiff ? imageMaxSize / latDiff : imageMaxSize / lonDiff;
+
+ int pixelsX = (int)(lonDiff * scaleFactor);
+ int pixelsY = (int)(latDiff * scaleFactor);
+
+ Bitmap ret = new Bitmap(pixelsX, pixelsY, PixelFormat.Format32bppRgb);
+
+ Graphics g = Graphics.FromImage(ret);
+ Pen p = new Pen(Color.Black, 2);
+ g.Clear(Color.White);
+
+ for (int i = 0; i < nodes.Count - 1; i++)
+ {
+ Coordinates c1 = nodes[i].coordinates;
+ Coordinates c2 = nodes[i+1].coordinates;
+ Point p1 = new(Convert.ToInt32((c1.longitude - minLon) * scaleFactor), Convert.ToInt32((maxLat - c1.latitude) * scaleFactor));
+ Point p2 = new(Convert.ToInt32((c2.longitude - minLon) * scaleFactor), Convert.ToInt32((maxLat - c2.latitude) * scaleFactor));
+ g.DrawLine(p, p1, p2);
+ }
+
+ ret.Save(@"D:\render.png", ImageFormat.Bmp);
+ return ret;
+ }
+}
\ No newline at end of file
diff --git a/Server/Server.cs b/Server/Server.cs
index 19de963..4ecbda9 100644
--- a/Server/Server.cs
+++ b/Server/Server.cs
@@ -13,21 +13,15 @@ public class Server
Console.SetOut(newConsole);
Console.SetError(newConsole);
- RegionConverter.ConvertXMLToRegions("D:/stuttgart-regbez-latest.osm", "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.794567f, 9.820625f);
- Coordinates finish = new Coordinates(48.79593f, 9.824013f);
- DateTime startTime = DateTime.Now;
- OsmNode[] path = Pathfinder.CustomAStar("D:/map", start, finish, Tag.SpeedType.car).ToArray();
- TimeSpan duration = DateTime.Now - startTime;
- Console.WriteLine($"Took {duration.TotalMilliseconds}ms ({duration:g})");
- for (int i = 0; i < path.Length - 1; i++)
- {
- Console.WriteLine(path[i]);
- }
- Console.WriteLine();*/
+
+ Coordinates start = new Coordinates( 48.7933798f, 9.8275859f);
+ Coordinates finish = new Coordinates( 48.8407632f, 10.0676979f);
+ List result = Pathfinder.AStar("D:/stuttgart-regbez-latest", start,
+ finish, Tag.SpeedType.car, 20, 2,
+ 0);
+ RenderPath.Renderer.DrawFromPath(result);
}
}
\ No newline at end of file
diff --git a/Server/Server.csproj b/Server/Server.csproj
index 9022c04..1fa3be0 100644
--- a/Server/Server.csproj
+++ b/Server/Server.csproj
@@ -9,6 +9,7 @@
+