using OSMDatastructure; using OSMDatastructure.Graph; namespace OSMImporter { public class RegionManager { private string workingDirectory { get; } private readonly Dictionary _regions = new(); public RegionManager(string workingDirectory) { this.workingDirectory = workingDirectory; } /// /// Checks wether the Region is already loaded and returns the Region, or tries to load the Region from file in workingDirectory /// /// Coordinates of the Region (or within the Region) to load /// The Region at the specified Coordinates containing Nodes and Connections /// If the Regionfile can not be found. public Region GetRegion(Coordinates coordinates) { if(_regions.ContainsKey(Coordinates.GetRegionHashCode(coordinates))) return _regions[Coordinates.GetRegionHashCode(coordinates)]; else { Region loadedRegion = LoadRegion(coordinates); _regions.Add(loadedRegion.regionHash, value: loadedRegion); return loadedRegion; } } public Region[] GetAllRegions() { return this._regions.Values.ToArray(); } /// /// /// /// Coordinates of the Region (or within the Region) to load /// The Region at the specified Coordinates containing Nodes and Connections /// If the Regionfile can not be found. private Region LoadRegion(Coordinates coordinates) { throw new NotImplementedException(); } public OsmNode? GetNode(Coordinates coordinates) { Region regionWithNode = GetRegion(coordinates); return regionWithNode.GetNode(coordinates); } } }