Preload Regions

This commit is contained in:
glax 2023-04-23 15:26:29 +02:00
parent 2799db162d
commit 7b88616373

View File

@ -30,7 +30,7 @@ public class Server
GetShortestRoute("D:");
/*
ValueTuple<Image, Renderer.Bounds> area = RenderAreaBaseImage(workingDir, start, finish);
ValueTuple<Image, Renderer.Bounds> area = Renderer.DrawArea(LoadRegions(workingDir, start, finish));
area.Item1.Save(@"D:\Base.png", ImageFormat.Png);
ValueTuple<Image, Renderer.Bounds> 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<Image, Renderer.Bounds> 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<Image, Renderer.Bounds> 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<Thread> calcThreads = new();