2023-02-03 21:13:51 +01:00
|
|
|
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)
|
|
|
|
{
|
2023-02-03 21:13:51 +01:00
|
|
|
if(this._regions.ContainsKey(coordinates.GetRegionHash(Importer.regionSize)))
|
|
|
|
return this._regions[coordinates.GetRegionHash(Importer.regionSize)];
|
2023-02-02 22:30:43 +01:00
|
|
|
else
|
|
|
|
{
|
2023-02-03 21:13:51 +01:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|