OSMServer/Server/Server.cs

31 lines
979 B
C#
Raw Normal View History

2023-02-02 22:30:43 +01:00
using OSMImporter;
using OSMDatastructure;
2023-02-02 22:30:43 +01:00
namespace Server;
2023-02-02 19:03:00 +01:00
public class Server
{
2023-02-02 22:30:43 +01:00
public static Region LoadRegion(string folderPath, Coordinates coordinates)
{
2023-02-03 23:35:05 +01:00
string fullPath = Path.Combine(folderPath, coordinates.GetRegionHash().ToString());
Console.WriteLine(fullPath);
2023-02-03 23:35:05 +01:00
Region retRegion = new Region(coordinates);
if (!File.Exists(fullPath))
return retRegion;
FileStream fileStream = new FileStream(fullPath, FileMode.Open);
byte[] regionBytes = new byte[fileStream.Length];
fileStream.Read(regionBytes, 0, regionBytes.Length);
fileStream.Close();
return ByteConverter.ToRegion(regionBytes);
}
2023-02-02 22:30:43 +01:00
public static void Main(string[] args)
2023-02-02 19:03:00 +01:00
{
2023-02-03 00:02:04 +01:00
Importer.Split("/home/glax/Downloads/bayern-latest.osm", "/home/glax/Downloads/bayern-latest");
Region r = LoadRegion("/home/glax/Downloads/bayern-latest", new Coordinates(47.890f,12.56f));
2023-02-02 19:03:00 +01:00
}
}