Changed Regionhashing and OsmDatastructure with OsmDatastructure.Graph

This commit is contained in:
2023-03-14 17:00:59 +01:00
parent 583fe3c18d
commit d7469aa190
9 changed files with 49 additions and 41 deletions

View File

@ -1,4 +1,5 @@
using OSMDatastructure;
using OSMDatastructure.Graph;
using OSMImporter;
namespace Pathfinding;

View File

@ -1,12 +1,12 @@
using OSMDatastructure;
using Pathfinding;
using OSMDatastructure.Graph;
namespace OSMImporter
{
public class RegionManager
{
private string workingDirectory { get; }
private readonly Dictionary<ulong, Region> _regions = new();
private readonly Dictionary<int, Region> _regions = new();
public RegionManager(string workingDirectory)
{
@ -21,12 +21,12 @@ namespace OSMImporter
/// <exception cref="FileNotFoundException">If the Regionfile can not be found.</exception>
public Region GetRegion(Coordinates coordinates)
{
if(this._regions.ContainsKey(coordinates.GetRegionHash()))
return this._regions[coordinates.GetRegionHash()];
if(_regions.ContainsKey(Coordinates.GetRegionHashCode(coordinates)))
return _regions[Coordinates.GetRegionHashCode(coordinates)];
else
{
Region loadedRegion = LoadRegion(coordinates);
this._regions.Add(loadedRegion.regionHash, value: loadedRegion);
_regions.Add(loadedRegion.regionHash, value: loadedRegion);
return loadedRegion;
}
}
@ -44,7 +44,7 @@ namespace OSMImporter
/// <exception cref="FileNotFoundException">If the Regionfile can not be found.</exception>
private Region LoadRegion(Coordinates coordinates)
{
string fullPath = Path.Combine(workingDirectory, coordinates.GetRegionHash().ToString());
string fullPath = Path.Combine(workingDirectory, Coordinates.GetRegionHashCode(coordinates).ToString());
DateTime startTime = DateTime.Now;
if (!File.Exists(fullPath))
{
@ -66,7 +66,7 @@ namespace OSMImporter
public OsmNode? GetNode(Coordinates coordinates)
{
Region regionWithNode = GetRegion(coordinates);
return regionWithNode.GetNode(coordinates);
return regionWithNode.GetNodeWithCoordinates(coordinates);
}
}
}