OSMServer/OSMSplitter/RegionManager.cs

31 lines
868 B
C#
Raw Normal View History

using OSMDatastructure;
2023-02-02 22:30:43 +01:00
namespace OSMImporter
{
public class RegionManager
{
private readonly Dictionary<ulong, Region> _regions;
public RegionManager()
{
this._regions = new Dictionary<ulong, Region>();
}
public Region GetRegion(Coordinates coordinates)
{
if(this._regions.ContainsKey(coordinates.GetRegionHash(Importer.regionSize)))
return this._regions[coordinates.GetRegionHash(Importer.regionSize)];
2023-02-02 22:30:43 +01:00
else
{
Region newRegion = new Region(coordinates, Importer.regionSize);
2023-02-02 22:30:43 +01:00
this._regions.Add(newRegion.regionHash, value: newRegion);
return newRegion;
}
}
public Region[] GetAllRegions()
{
return this._regions.Values.ToArray();
}
}
}