|   |  | 1 |  | using System.Collections.Generic; | 
|   |  | 2 |  | using Itinero.Network; | 
|   |  | 3 |  | using Itinero.Network.Enumerators.Edges; | 
|   |  | 4 |  |  | 
|   |  | 5 |  | namespace Itinero.Network.Search; | 
|   |  | 6 |  |  | 
|   |  | 7 |  | internal class VertexEdgeEnumerator : IEdgeEnumerator<RoutingNetwork> | 
|   |  | 8 |  | { | 
|   |  | 9 |  |     private readonly IEnumerator<VertexId> _vertexEnumerator; | 
|   |  | 10 |  |  | 
|   | 29 | 11 |  |     public VertexEdgeEnumerator(RoutingNetwork graph, IEnumerable<VertexId> vertices) | 
|   | 29 | 12 |  |     { | 
|   | 29 | 13 |  |         this.Network = graph; | 
|   | 29 | 14 |  |         _vertexEnumerator = vertices.GetEnumerator(); | 
|   | 29 | 15 |  |         this.RoutingNetworkEdgeEnumerator = graph.GetEdgeEnumerator(); | 
|   | 29 | 16 |  |     } | 
|   |  | 17 |  |  | 
|   | 29 | 18 |  |     private bool _firstEdge = false; | 
|   |  | 19 |  |  | 
|   |  | 20 |  |     public void Reset() | 
|   | 0 | 21 |  |     { | 
|   | 0 | 22 |  |         _firstEdge = false; | 
|   | 0 | 23 |  |         this.RoutingNetworkEdgeEnumerator.Reset(); | 
|   | 0 | 24 |  |         _vertexEnumerator.Reset(); | 
|   | 0 | 25 |  |     } | 
|   |  | 26 |  |  | 
|   |  | 27 |  |     public bool MoveNext() | 
|   | 72 | 28 |  |     { | 
|   | 72 | 29 |  |         if (!_firstEdge) | 
|   | 29 | 30 |  |         { | 
|   | 30 | 31 |  |             while (_vertexEnumerator.MoveNext()) | 
|   | 29 | 32 |  |             { | 
|   | 29 | 33 |  |                 while (this.RoutingNetworkEdgeEnumerator.MoveTo(_vertexEnumerator.Current)) | 
|   | 29 | 34 |  |                 { | 
|   | 29 | 35 |  |                     if (!this.RoutingNetworkEdgeEnumerator.MoveNext()) | 
|   | 1 | 36 |  |                     { | 
|   | 1 | 37 |  |                         break; | 
|   |  | 38 |  |                     } | 
|   |  | 39 |  |  | 
|   | 28 | 40 |  |                     _firstEdge = true; | 
|   | 28 | 41 |  |                     return true; | 
|   |  | 42 |  |                 } | 
|   | 1 | 43 |  |             } | 
|   |  | 44 |  |  | 
|   | 1 | 45 |  |             return false; | 
|   |  | 46 |  |         } | 
|   |  | 47 |  |  | 
|   | 43 | 48 |  |         while (true) | 
|   | 43 | 49 |  |         { | 
|   | 43 | 50 |  |             if (this.RoutingNetworkEdgeEnumerator.MoveNext()) | 
|   | 2 | 51 |  |             { | 
|   | 2 | 52 |  |                 return true; | 
|   |  | 53 |  |             } | 
|   |  | 54 |  |  | 
|   | 41 | 55 |  |             if (!_vertexEnumerator.MoveNext()) | 
|   | 8 | 56 |  |             { | 
|   | 8 | 57 |  |                 return false; | 
|   |  | 58 |  |             } | 
|   |  | 59 |  |  | 
|   | 33 | 60 |  |             while (this.RoutingNetworkEdgeEnumerator.MoveTo(_vertexEnumerator.Current)) | 
|   | 33 | 61 |  |             { | 
|   | 33 | 62 |  |                 if (this.RoutingNetworkEdgeEnumerator.MoveNext()) | 
|   | 33 | 63 |  |                 { | 
|   | 33 | 64 |  |                     return true; | 
|   |  | 65 |  |                 } | 
|   |  | 66 |  |  | 
|   | 0 | 67 |  |                 if (!_vertexEnumerator.MoveNext()) | 
|   | 0 | 68 |  |                 { | 
|   | 0 | 69 |  |                     return false; | 
|   |  | 70 |  |                 } | 
|   | 0 | 71 |  |             } | 
|   | 0 | 72 |  |         } | 
|   | 72 | 73 |  |     } | 
|   |  | 74 |  |  | 
|   | 389 | 75 |  |     internal RoutingNetworkEdgeEnumerator RoutingNetworkEdgeEnumerator { get; } | 
|   |  | 76 |  |  | 
|   | 0 | 77 |  |     public void Dispose() { } | 
|   |  | 78 |  |  | 
|   | 0 | 79 |  |     public RoutingNetwork Network { get; } | 
|   |  | 80 |  |  | 
|   | 35 | 81 |  |     public bool Forward => this.RoutingNetworkEdgeEnumerator.Forward; | 
|   | 0 | 82 |  |     public VertexId Tail => this.RoutingNetworkEdgeEnumerator.Tail; | 
|   | 36 | 83 |  |     public (double longitude, double latitude, float? e) TailLocation => this.RoutingNetworkEdgeEnumerator.TailLocation; | 
|   | 0 | 84 |  |     public VertexId Head => this.RoutingNetworkEdgeEnumerator.Head; | 
|   | 36 | 85 |  |     public (double longitude, double latitude, float? e) HeadLocation => this.RoutingNetworkEdgeEnumerator.HeadLocation; | 
|   | 79 | 86 |  |     public EdgeId EdgeId => this.RoutingNetworkEdgeEnumerator.EdgeId; | 
|   | 36 | 87 |  |     public IEnumerable<(double longitude, double latitude, float? e)> Shape => this.RoutingNetworkEdgeEnumerator.Shape; | 
|   | 0 | 88 |  |     public IEnumerable<(string key, string value)> Attributes => this.RoutingNetworkEdgeEnumerator.Attributes; | 
|   | 0 | 89 |  |     public uint? EdgeTypeId => this.RoutingNetworkEdgeEnumerator.EdgeTypeId; | 
|   | 0 | 90 |  |     public uint? Length => this.RoutingNetworkEdgeEnumerator.Length; | 
|   | 0 | 91 |  |     public byte? HeadOrder => this.RoutingNetworkEdgeEnumerator.HeadOrder; | 
|   | 0 | 92 |  |     public byte? TailOrder => this.RoutingNetworkEdgeEnumerator.TailOrder; | 
|   |  | 93 |  |  | 
|   |  | 94 |  |     /// <summary> | 
|   |  | 95 |  |     /// Gets the turn cost at the tail turn (source -> [tail -> head]). | 
|   |  | 96 |  |     /// </summary> | 
|   |  | 97 |  |     /// <param name="sourceOrder">The order of the source edge.</param> | 
|   |  | 98 |  |     /// <returns>The turn costs if any.</returns> | 
|   |  | 99 |  |     public IEnumerable<(uint turnCostType, IEnumerable<(string key, string value)> attributes, uint cost, IEnumerable<Ed | 
|   |  | 100 |  |         byte sourceOrder) | 
|   | 0 | 101 |  |     { | 
|   | 0 | 102 |  |         return this.RoutingNetworkEdgeEnumerator.GetTurnCostToTail(sourceOrder); | 
|   | 0 | 103 |  |     } | 
|   |  | 104 |  |  | 
|   |  | 105 |  |     /// <summary> | 
|   |  | 106 |  |     /// Gets the turn cost at the tail turn ([head -> tail] -> target). | 
|   |  | 107 |  |     /// </summary> | 
|   |  | 108 |  |     /// <param name="targetOrder">The order of the target edge.</param> | 
|   |  | 109 |  |     /// <returns>The turn costs if any.</returns> | 
|   |  | 110 |  |     public IEnumerable<(uint turnCostType, IEnumerable<(string key, string value)> attributes, uint cost, IEnumerable<Ed | 
|   |  | 111 |  |         byte targetOrder) | 
|   | 0 | 112 |  |     { | 
|   | 0 | 113 |  |         return this.RoutingNetworkEdgeEnumerator.GetTurnCostFromTail(targetOrder); | 
|   | 0 | 114 |  |     } | 
|   |  | 115 |  |  | 
|   |  | 116 |  |     /// <summary> | 
|   |  | 117 |  |     /// Gets the turn cost at the tail turn (source -> [head -> tail]). | 
|   |  | 118 |  |     /// </summary> | 
|   |  | 119 |  |     /// <param name="sourceOrder">The order of the source edge.</param> | 
|   |  | 120 |  |     /// <returns>The turn costs if any.</returns> | 
|   |  | 121 |  |     public IEnumerable<(uint turnCostType, IEnumerable<(string key, string value)> attributes, uint cost, IEnumerable<Ed | 
|   |  | 122 |  |         byte sourceOrder) | 
|   | 0 | 123 |  |     { | 
|   | 0 | 124 |  |         return this.RoutingNetworkEdgeEnumerator.GetTurnCostToHead(sourceOrder); | 
|   | 0 | 125 |  |     } | 
|   |  | 126 |  |  | 
|   |  | 127 |  |     /// <summary> | 
|   |  | 128 |  |     /// Gets the turn cost at the tail turn ([tail -> head] -> target). | 
|   |  | 129 |  |     /// </summary> | 
|   |  | 130 |  |     /// <param name="targetOrder">The order of the target edge.</param> | 
|   |  | 131 |  |     /// <returns>The turn costs if any.</returns> | 
|   |  | 132 |  |     public IEnumerable<(uint turnCostType, IEnumerable<(string key, string value)> attributes, uint cost, IEnumerable<Ed | 
|   |  | 133 |  |         byte targetOrder) | 
|   | 0 | 134 |  |     { | 
|   | 0 | 135 |  |         return this.RoutingNetworkEdgeEnumerator.GetTurnCostFromHead(targetOrder); | 
|   | 0 | 136 |  |     } | 
|   |  | 137 |  | } |