Datastructure rewrite
This commit is contained in:
@ -1,51 +1,26 @@
|
||||
namespace OSMDatastructure
|
||||
namespace OSMDatastructure;
|
||||
|
||||
public class Region
|
||||
{
|
||||
public class Region
|
||||
public const float regionSize = 0.01f;
|
||||
public readonly HashSet<OsmNode> nodes = new();
|
||||
public ulong regionHash { get; }
|
||||
|
||||
public Region(ulong regionHash)
|
||||
{
|
||||
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();
|
||||
}
|
||||
this.regionHash = regionHash;
|
||||
}
|
||||
|
||||
public Region(ulong nodeId, Node firstNode)
|
||||
{
|
||||
this.regionHash = firstNode.GetRegionHash();
|
||||
this._nodesInRegion.Add(nodeId, value: firstNode);
|
||||
}
|
||||
public Region(Coordinates regionCoordinates)
|
||||
{
|
||||
this.regionHash = regionCoordinates.GetRegionHash();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
public OsmNode? GetNode(Coordinates coordinates)
|
||||
{
|
||||
foreach(OsmNode node in this.nodes)
|
||||
if (node.coordinates.Equals(coordinates))
|
||||
return node;
|
||||
return null;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user