From 6373874495ee41a7da4c4d895ff027c3322906c0 Mon Sep 17 00:00:00 2001 From: glax Date: Fri, 21 Apr 2023 14:44:50 +0200 Subject: [PATCH] Added function to render a base-area-image. --- Server/Server.cs | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/Server/Server.cs b/Server/Server.cs index 51ca258..7ab6653 100644 --- a/Server/Server.cs +++ b/Server/Server.cs @@ -26,28 +26,11 @@ public class Server Coordinates start = new (48.7933798f, 9.8275859f); Coordinates finish = new (48.795918f, 9.021618f); - TestVariables(workingDir, start, finish, 4); + TestVariables(workingDir, start, finish, 16); - +/* string parentFolder = new DirectoryInfo(workingDir).Parent!.FullName; - - /* - Console.WriteLine("Preparing BaseRender"); - RegionManager allRegions = new(workingDir); - for (float lat = 48.78f - Region.RegionSize / 2; lat < 48.87f + Region.RegionSize / 2; lat += Region.RegionSize / 2) - { - for (float lon = 9f - Region.RegionSize / 2; lon < 9.9f + Region.RegionSize / 2; lon += Region.RegionSize / 2) - { - allRegions.GetRegion(new Coordinates(lat, lon)); - } - } - Console.WriteLine("Regions Loaded. Rendering."); - ValueTuple baseRender = Renderer.DrawArea(allRegions); -*/ - - - /* Pathfinder result = new Pathfinder(workingDir).AStar(start, finish, Tag.SpeedType.car, 0.034, 0.012, 0, 0.18); @@ -66,13 +49,33 @@ public class Server #pragma warning restore CA1416*/ } + private static ValueTuple RenderAreaBaseImage(string workingDir, Coordinates c1, Coordinates c2) + { + float minLat = c1.latitude < c2.latitude ? c1.latitude : c2.latitude; + float minLon = c1.longitude < c2.longitude ? c1.longitude : c2.longitude; + float maxLat = c1.latitude > c2.latitude ? c1.latitude : c2.latitude; + float maxLon = c1.longitude > c2.longitude ? c1.longitude : c2.longitude; + + RegionManager allRegions = new(workingDir); + for (float lat = minLat - Region.RegionSize; lat < maxLat + Region.RegionSize; lat += Region.RegionSize / 2) + { + for (float lon = minLon - Region.RegionSize; lon < maxLon + Region.RegionSize; lon += Region.RegionSize / 2) + { + allRegions.GetRegion(new Coordinates(lat, lon)); + } + } + Console.WriteLine("Regions Loaded. Rendering."); + ValueTuple baseRender = Renderer.DrawArea(allRegions); + return baseRender; + } + private static void TestVariables(string workingDir, Coordinates start, Coordinates finish, int threads) { string parentFolder = new DirectoryInfo(workingDir).Parent!.FullName; Queue calcThreads = new(); - for (double sameRoadPriority = 0.002; sameRoadPriority < 0.4; sameRoadPriority += 0.02) + for (double sameRoadPriority = 0.02; sameRoadPriority < 0.4; sameRoadPriority += 0.02) { for (double roadLevelPriority = 0.4; roadLevelPriority > 0; roadLevelPriority -= 0.02) {