Add AccessType() AccessPermitted() to Way
This commit is contained in:
parent
13ccec9245
commit
a365c155b2
11
OSM_Graph/AccessEnum.cs
Normal file
11
OSM_Graph/AccessEnum.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
namespace OSM_Graph;
|
||||||
|
|
||||||
|
public enum AccessEnum
|
||||||
|
{
|
||||||
|
Yes,
|
||||||
|
No,
|
||||||
|
Private,
|
||||||
|
Permissive,
|
||||||
|
Agricultural,
|
||||||
|
Forestry
|
||||||
|
}
|
@ -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))
|
||||||
|
Loading…
Reference in New Issue
Block a user