C9Glax
3350d8e3b9
Added GetNode(ulong id) Instead of returning null in LoadRegion now throw an exception when file is not found. Added some Method descriptors
51 lines
1.3 KiB
C#
51 lines
1.3 KiB
C#
namespace OSMDatastructure
|
|
{
|
|
public class Region
|
|
{
|
|
public const float regionSize = 0.01f; //For Splitting
|
|
private readonly Dictionary<ulong, Node> _nodesInRegion = new();
|
|
public ulong regionHash { get; }
|
|
|
|
public Region(Coordinates regionCoordinates)
|
|
{
|
|
this.regionHash = regionCoordinates.GetRegionHash();
|
|
}
|
|
|
|
public Region(ulong nodeId, Node firstNode)
|
|
{
|
|
this.regionHash = firstNode.GetRegionHash();
|
|
this._nodesInRegion.Add(nodeId, value: firstNode);
|
|
}
|
|
|
|
public Region(ulong regionHash)
|
|
{
|
|
this.regionHash = regionHash;
|
|
}
|
|
|
|
public void AddNode(ulong nodeId, Node node)
|
|
{
|
|
this._nodesInRegion.Add(nodeId, value: node);
|
|
}
|
|
|
|
public Dictionary<ulong, Node> GetNodes()
|
|
{
|
|
return this._nodesInRegion;
|
|
}
|
|
|
|
public Node? GetNode(ulong id)
|
|
{
|
|
return this._nodesInRegion.ContainsKey(id) ? this._nodesInRegion[id] : null;
|
|
}
|
|
|
|
public Node? GetNode(Coordinates coordinates)
|
|
{
|
|
foreach (Node node in this._nodesInRegion.Values)
|
|
{
|
|
if (node.Equals(coordinates))
|
|
return node;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
} |