Add AccessType() AccessPermitted() to Way

This commit is contained in:
glax 2024-07-24 01:21:54 +02:00
parent 13ccec9245
commit a365c155b2
2 changed files with 24 additions and 0 deletions

11
OSM_Graph/AccessEnum.cs Normal file
View File

@ -0,0 +1,11 @@
namespace OSM_Graph;
public enum AccessEnum
{
Yes,
No,
Private,
Permissive,
Agricultural,
Forestry
}

View File

@ -9,6 +9,19 @@ public class Way(ulong id, Dictionary<string, string> tags, List<ulong> nodeIds)
public readonly ulong ID = id; public readonly ulong ID = id;
public readonly List<ulong> NodeIds = nodeIds; public readonly List<ulong> NodeIds = nodeIds;
public AccessEnum AccessType()
{
if (Tags.TryGetValue("access", out string? accessValue) && Enum.TryParse(accessValue, out AccessEnum access))
return access;
return AccessEnum.Yes;
}
public bool AccessPermitted()
{
AccessEnum[] permittedTypes = [AccessEnum.Yes, AccessEnum.Permissive];
return permittedTypes.Contains(AccessType());
}
public WayDirection GetDirection() public WayDirection GetDirection()
{ {
if (Tags.TryGetValue("oneway", out string? onewayStr)) if (Tags.TryGetValue("oneway", out string? onewayStr))