OSMServer/OSMImporter/RegionManager.cs
2023-02-02 22:30:43 +01:00

29 lines
784 B
C#

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()))
return this._regions[coordinates.GetRegionHash()];
else
{
Region newRegion = new Region(coordinates);
this._regions.Add(newRegion.regionHash, value: newRegion);
return newRegion;
}
}
public Region[] GetAllRegions()
{
return this._regions.Values.ToArray();
}
}
}