31 lines
868 B
C#
31 lines
868 B
C#
using OSMDatastructure;
|
|
|
|
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)];
|
|
else
|
|
{
|
|
Region newRegion = new Region(coordinates, Importer.regionSize);
|
|
this._regions.Add(newRegion.regionHash, value: newRegion);
|
|
return newRegion;
|
|
}
|
|
}
|
|
|
|
public Region[] GetAllRegions()
|
|
{
|
|
return this._regions.Values.ToArray();
|
|
}
|
|
}
|
|
} |