From 556b0736f12936896bb4b91d9aaa827131798c0c Mon Sep 17 00:00:00 2001 From: C9Glax <13404778+C9Glax@users.noreply.github.com> Date: Wed, 8 Feb 2023 19:09:54 +0100 Subject: [PATCH] Housekeeping --- Server/Server.cs | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/Server/Server.cs b/Server/Server.cs index ef05344..a4705c7 100644 --- a/Server/Server.cs +++ b/Server/Server.cs @@ -5,10 +5,39 @@ namespace Server; public class Server { + private static void WriteRegionsToFile(HashSet regions, string outputFolderPath) + { + Console.WriteLine(string.Format("[{0}] Writing files...", DateTime.Now.ToLocalTime())); + Directory.CreateDirectory(outputFolderPath); + foreach (Region region in regions) + { + FileStream regionFileStream = + new FileStream(Path.Combine(outputFolderPath, region.regionHash.ToString()), FileMode.Create); + regionFileStream.Write(ByteConverter.GetBytes(region)); + regionFileStream.Close(); + } + } + public static void Main(string[] args) { - //XmlImporter.Split("/home/glax/Downloads/oberbayern-latest.osm", "/home/glax/Downloads/oberbayern-latest"); - //Region r = LoadRegion("/home/glax/Downloads/bayern-latest", new Coordinates(47.890f,12.56f)); - Pathfinder.CustomAStar("/home/glax/Downloads/oberbayern-latest", new Coordinates(48.243351f, 11.640417f), new Coordinates(48.25239f, 11.53272f)); + //HashSet nodes = XmlImporter.ImportXml("/home/glax/Downloads/oberbayern-latest.osm"); + //HashSet regions = XmlImporter.SplitIntoRegions(nodes); + //WriteRegionsToFile(regions, "/home/glax/Downloads/oberbayern-latest"); + Coordinates start = new Coordinates(48.243351f, 11.640417f); + Coordinates finish = new Coordinates(48.25239f, 11.53272f); + + OsmNode[] path = Pathfinder.CustomAStar("/home/glax/Downloads/oberbayern-latest", start, finish, OsmEdge.speedType.car).ToArray(); + Console.WriteLine("{0}\n", path[0].ToString()); + for (int i = 0; i < path.Length - 1; i++) + { + OsmNode n1 = path[i]; + OsmNode n2 = path[i + 1]; + OsmEdge? e = n1.GetEdgeToNode(n2); + if(e != null) + Console.WriteLine("{0}\n{1}", e.ToString(), n2.ToString()); + else + Console.WriteLine("NO EDGE\n{0}", n2.ToString()); + } + Console.WriteLine(); } } \ No newline at end of file