| | 1 | | using System; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using OsmSharp; |
| | 4 | |
|
| | 5 | | namespace Itinero.IO.Osm.Restrictions; |
| | 6 | |
|
| | 7 | | /// <summary> |
| | 8 | | /// The original OSM turn restriction. |
| | 9 | | /// </summary> |
| | 10 | | public class OsmTurnRestriction |
| | 11 | | { |
| | 12 | | /// <summary> |
| | 13 | | /// Creates a restriction with a via-node. |
| | 14 | | /// </summary> |
| | 15 | | /// <param name="froms">One or more from ways.</param> |
| | 16 | | /// <param name="viaNodeId">The via node id.</param> |
| | 17 | | /// <param name="tos">One or more to ways.</param> |
| | 18 | | /// <param name="isProhibitory">The prohibitory flag.</param> |
| | 19 | | /// <param name="attributes">The attributes.</param> |
| | 20 | | /// <returns>An OSM turn restriction.</returns> |
| | 21 | | public static OsmTurnRestriction Create(IEnumerable<Way> froms, long viaNodeId, IEnumerable<Way> tos, bool isProhibi |
| | 22 | | IEnumerable<(string key, string value)>? attributes = null) |
| 5 | 23 | | { |
| 5 | 24 | | attributes ??= ArraySegment<(string key, string value)>.Empty; |
| | 25 | |
|
| 5 | 26 | | return new OsmTurnRestriction() |
| 5 | 27 | | { |
| 5 | 28 | | IsProbibitory = isProhibitory, |
| 5 | 29 | | From = froms, |
| 5 | 30 | | ViaNodeId = viaNodeId, |
| 5 | 31 | | Via = ArraySegment<Way>.Empty, |
| 5 | 32 | | To = tos, |
| 5 | 33 | | Attributes = attributes |
| 5 | 34 | | }; |
| 5 | 35 | | } |
| | 36 | |
|
| | 37 | | /// <summary> |
| | 38 | | /// Creates a restriction with a via-node. |
| | 39 | | /// </summary> |
| | 40 | | /// <param name="froms">One or more from ways.</param> |
| | 41 | | /// <param name="vias">One or more via ways.</param> |
| | 42 | | /// <param name="tos">One or more to ways.</param> |
| | 43 | | /// <param name="isProhibitory">The prohibitory flag.</param> |
| | 44 | | /// <param name="attributes">The attributes.</param> |
| | 45 | | /// <returns>An OSM turn restriction.</returns> |
| | 46 | | public static OsmTurnRestriction Create(IEnumerable<Way> froms, IEnumerable<Way> vias, IEnumerable<Way> tos, bool is |
| | 47 | | IEnumerable<(string key, string value)>? attributes = null) |
| 5 | 48 | | { |
| 5 | 49 | | attributes ??= ArraySegment<(string key, string value)>.Empty; |
| | 50 | |
|
| 5 | 51 | | return new OsmTurnRestriction() |
| 5 | 52 | | { |
| 5 | 53 | | IsProbibitory = isProhibitory, |
| 5 | 54 | | From = froms, |
| 5 | 55 | | ViaNodeId = null, |
| 5 | 56 | | Via = vias, |
| 5 | 57 | | To = tos, |
| 5 | 58 | | Attributes = attributes |
| 5 | 59 | | }; |
| 5 | 60 | | } |
| | 61 | |
|
| | 62 | | /// <summary> |
| | 63 | | /// A flag set to true when this restriction is prohibitory, false when mandatory. |
| | 64 | | /// </summary> |
| 13 | 65 | | public bool IsProbibitory { get; private set; } |
| | 66 | |
|
| | 67 | | /// <summary> |
| | 68 | | /// The attributes associated with the turn. |
| | 69 | | /// </summary> |
| 11 | 70 | | public IEnumerable<(string key, string value)> Attributes { get; private set; } |
| | 71 | |
|
| | 72 | | /// <summary> |
| | 73 | | /// The from way(s). |
| | 74 | | /// </summary> |
| 17 | 75 | | public IEnumerable<Way> From { get; private set; } |
| | 76 | |
|
| | 77 | | /// <summary> |
| | 78 | | /// The via way(s), if any. |
| | 79 | | /// </summary> |
| 16 | 80 | | public IEnumerable<Way> Via { get; private set; } |
| | 81 | |
|
| | 82 | | /// <summary> |
| | 83 | | /// The via node id, if any. |
| | 84 | | /// </summary> |
| 23 | 85 | | public long? ViaNodeId { get; private set; } |
| | 86 | |
|
| | 87 | | /// <summary> |
| | 88 | | /// The to way(s). |
| | 89 | | /// </summary> |
| 15 | 90 | | public IEnumerable<Way> To { get; private set; } |
| | 91 | | } |