This commit is contained in:
C9Glax 2023-03-14 17:01:48 +01:00
parent d7469aa190
commit d2ab990bfe

View File

@ -1,28 +1,18 @@
using OSMDatastructure;
using OSMDatastructure.Graph;
using Pathfinding;
namespace Server;
public class Server
{
private static void WriteRegionsToFile(HashSet<Region> 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)
{
HashSet<OsmNode> nodes = XmlImporter.ImportXml("/home/glax/Downloads/germany-latest.osm");
HashSet<OsmNode> nodes = XmlImporter.ImportXml("D:/stuttgart-regbez-latest.osm/stuttgart-regbez-latest.osm");
HashSet<Region> regions = XmlImporter.SplitIntoRegions(nodes);
WriteRegionsToFile(regions, "/home/glax/Downloads/germany-latest");
WriteRegionsToFile(regions, "D:/stuttgart-regbez");
/*
Coordinates start = new Coordinates(48.243351f, 11.640417f);
@ -41,4 +31,17 @@ public class Server
}
Console.WriteLine();*/
}
private static void WriteRegionsToFile(HashSet<Region> 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();
}
}
}