OSMServer/OSMDatastructure/Region.cs

33 lines
852 B
C#
Raw Normal View History

using OSMDatastructure.Graph;
2023-02-06 17:32:55 +01:00
namespace OSMDatastructure;
2023-02-02 22:30:43 +01:00
[Serializable]
2023-02-06 17:32:55 +01:00
public class Region
{
2023-03-31 21:54:32 +02:00
[NonSerialized]public const float RegionSize = 0.1f;
2023-02-06 17:32:55 +01:00
public readonly HashSet<OsmNode> nodes = new();
public readonly HashSet<OsmEdge> ways = new();
public ulong regionHash { get; }
public TagManager tagManager { get; }
public Region(ulong regionHash)
2023-02-06 17:32:55 +01:00
{
this.regionHash = regionHash;
tagManager = new TagManager();
2023-02-06 17:32:55 +01:00
}
public Region(Coordinates coordinates)
2023-02-06 17:32:55 +01:00
{
regionHash = Coordinates.GetRegionHashCode(coordinates);
tagManager = new TagManager();
2023-02-06 17:32:55 +01:00
}
public OsmNode? GetNodeWithCoordinates(Coordinates coordinates)
2023-02-06 17:32:55 +01:00
{
foreach(OsmNode node in this.nodes)
if (node.coordinates.Equals(coordinates))
return node;
return null;
2023-02-02 22:30:43 +01:00
}
}