Moved RegionManager inside of Importer as RegionStruct,

Moved Regionsize var to Region
This commit is contained in:
2023-02-03 23:34:51 +01:00
parent 7d3d46c505
commit 27cce159a4
4 changed files with 40 additions and 44 deletions

View File

@ -24,10 +24,10 @@ namespace OSMDatastructure
return latHash * offset + lonHash;
}
public ulong GetRegionHash(float regionSize)
public ulong GetRegionHash()
{
float latRegion = this.lat - this.lat % regionSize;
float lonRegion = this.lon - this.lon % regionSize;
float latRegion = this.lat - this.lat % Region.regionSize;
float lonRegion = this.lon - this.lon % Region.regionSize;
ulong latHash = Convert.ToUInt64((latRegion + 90) * decimalCoordsSave);
ulong lonHash = Convert.ToUInt64((lonRegion + 180) * decimalCoordsSave);
return latHash * offset + lonHash;

View File

@ -2,17 +2,18 @@ namespace OSMDatastructure
{
public class Region
{
public const float regionSize = 0.01f;
private readonly Dictionary<ulong, Node> _nodesInRegion = new();
public ulong regionHash { get; }
public Region(Coordinates regionCoordinates, float regionSize)
public Region(Coordinates regionCoordinates)
{
this.regionHash = regionCoordinates.GetRegionHash(regionSize);
this.regionHash = regionCoordinates.GetRegionHash();
}
public Region(ulong nodeId, Node firstNode, float regionSize)
public Region(ulong nodeId, Node firstNode)
{
this.regionHash = firstNode.GetRegionHash(regionSize);
this.regionHash = firstNode.GetRegionHash();
this._nodesInRegion.Add(nodeId, value: firstNode);
}
@ -31,5 +32,10 @@ namespace OSMDatastructure
return this._nodesInRegion;
}
public Node? GetNode(ulong id)
{
return this._nodesInRegion.ContainsKey(id) ? this._nodesInRegion[id] : null;
}
}
}