Adjusted to new Region Format
This commit is contained in:
@@ -12,21 +12,21 @@ namespace OSMImporter
|
||||
{
|
||||
this.workingDirectory = workingDirectory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks wether the Region is already loaded and returns the Region, or tries to load the Region from file in workingDirectory
|
||||
/// </summary>
|
||||
/// <param name="coordinates">Coordinates of the Region (or within the Region) to load</param>
|
||||
/// <returns>The Region at the specified Coordinates containing Nodes and Connections</returns>
|
||||
/// <exception cref="FileNotFoundException">If the Regionfile can not be found.</exception>
|
||||
public Region GetRegion(Coordinates coordinates)
|
||||
|
||||
public Region? GetRegion(Coordinates coordinates)
|
||||
{
|
||||
if(_regions.ContainsKey(Coordinates.GetRegionHashCode(coordinates)))
|
||||
return _regions[Coordinates.GetRegionHashCode(coordinates)];
|
||||
return GetRegion(Coordinates.GetRegionHashCode(coordinates));
|
||||
}
|
||||
|
||||
public Region? GetRegion(ulong id)
|
||||
{
|
||||
if(_regions.TryGetValue(id, out Region? value))
|
||||
return value;
|
||||
else
|
||||
{
|
||||
Region loadedRegion = LoadRegion(coordinates);
|
||||
_regions.Add(loadedRegion.regionHash, value: loadedRegion);
|
||||
Region? loadedRegion = LoadRegion(id);
|
||||
if(loadedRegion is not null)
|
||||
_regions.Add(loadedRegion!.regionHash, value: loadedRegion);
|
||||
return loadedRegion;
|
||||
}
|
||||
}
|
||||
@@ -35,22 +35,29 @@ namespace OSMImporter
|
||||
{
|
||||
return this._regions.Values.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="coordinates">Coordinates of the Region (or within the Region) to load</param>
|
||||
/// <returns>The Region at the specified Coordinates containing Nodes and Connections</returns>
|
||||
/// <exception cref="FileNotFoundException">If the Regionfile can not be found.</exception>
|
||||
private Region LoadRegion(Coordinates coordinates)
|
||||
|
||||
private Region? LoadRegion(Coordinates coordinates)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return LoadRegion(Coordinates.GetRegionHashCode(coordinates));
|
||||
}
|
||||
|
||||
private Region? LoadRegion(ulong id)
|
||||
{
|
||||
return Region.FromId(workingDirectory, id);
|
||||
}
|
||||
|
||||
public OsmNode? GetNode(Coordinates coordinates)
|
||||
{
|
||||
Region regionWithNode = GetRegion(coordinates);
|
||||
return regionWithNode.GetNode(coordinates);
|
||||
Region? regionWithNode = GetRegion(coordinates);
|
||||
if (regionWithNode is not null)
|
||||
return regionWithNode.GetNode(coordinates);
|
||||
else return null;
|
||||
}
|
||||
|
||||
public OsmNode? GetNode(ulong nodeId, ulong regionId)
|
||||
{
|
||||
Region? r = GetRegion(regionId);
|
||||
return r?.GetNode(nodeId);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user