From 7b88616373c6139fa7188d14e2786d5a7b228920 Mon Sep 17 00:00:00 2001 From: glax Date: Sun, 23 Apr 2023 15:26:29 +0200 Subject: [PATCH] Preload Regions --- Server/Server.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Server/Server.cs b/Server/Server.cs index b49bd08..88ba172 100644 --- a/Server/Server.cs +++ b/Server/Server.cs @@ -30,7 +30,7 @@ public class Server GetShortestRoute("D:"); /* - ValueTuple area = RenderAreaBaseImage(workingDir, start, finish); + ValueTuple area = Renderer.DrawArea(LoadRegions(workingDir, start, finish)); area.Item1.Save(@"D:\Base.png", ImageFormat.Png); ValueTuple areaDistance = Renderer.DrawPath( @@ -90,7 +90,7 @@ public class Server Console.WriteLine($"Shortest: {shortest.Key.distance} {shortest.Value}\nFastest: {shortest.Key.weight} {fastest.Value}\nCalcTime: {calcTime.Key.calcTime} {calcTime.Value}"); } - private static ValueTuple RenderAreaBaseImage(string workingDir, Coordinates c1, Coordinates c2) + private static RegionManager LoadRegions(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; @@ -105,16 +105,15 @@ public class Server allRegions.GetRegion(new Coordinates(lat, lon)); } } - Console.WriteLine("Regions Loaded. Rendering."); - ValueTuple baseRender = Renderer.DrawArea(allRegions); - return baseRender; + Console.WriteLine("Loaded needed Regions"); + return allRegions; } private static void TestVariables(string workingDir, Coordinates start, Coordinates finish, int threads) { string parentFolder = new DirectoryInfo(workingDir).Parent!.FullName; - RegionManager rm = new (workingDir); + RegionManager rm = LoadRegions(workingDir, start, finish); Queue calcThreads = new();