2023-02-03 21:13:51 +01:00
|
|
|
using OSMDatastructure;
|
2023-02-06 17:32:55 +01:00
|
|
|
using Pathfinding;
|
2023-02-02 22:30:43 +01:00
|
|
|
|
|
|
|
namespace Server;
|
2023-02-02 19:03:00 +01:00
|
|
|
|
|
|
|
public class Server
|
|
|
|
{
|
2023-02-08 19:09:54 +01:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-02 22:30:43 +01:00
|
|
|
public static void Main(string[] args)
|
2023-02-02 19:03:00 +01:00
|
|
|
{
|
2023-02-08 19:09:54 +01:00
|
|
|
//HashSet<OsmNode> nodes = XmlImporter.ImportXml("/home/glax/Downloads/oberbayern-latest.osm");
|
|
|
|
//HashSet<Region> 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();
|
2023-02-02 19:03:00 +01:00
|
|
|
}
|
|
|
|
}
|