| | 1 | | using System; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using Itinero.Network; |
| | 4 | | using Itinero.Network.Enumerators.Edges; |
| | 5 | | using Itinero.Routing.Costs; |
| | 6 | |
|
| | 7 | | namespace Itinero.Routing.Flavours.Dijkstra.Bidirectional; |
| | 8 | |
|
| | 9 | | internal class CostEdgeEnumerator |
| | 10 | | { |
| | 11 | | private readonly RoutingNetworkEdgeEnumerator _edgeEnumerator; |
| | 12 | | private readonly ICostFunction _costFunction; |
| | 13 | |
|
| 30 | 14 | | internal CostEdgeEnumerator(RoutingNetworkEdgeEnumerator edgeEnumerator, ICostFunction costFunction) |
| 30 | 15 | | { |
| 30 | 16 | | _edgeEnumerator = edgeEnumerator; |
| 30 | 17 | | _costFunction = costFunction; |
| 30 | 18 | | } |
| | 19 | |
|
| | 20 | | public bool MoveTo(VertexId vertex) |
| 0 | 21 | | { |
| 0 | 22 | | return _edgeEnumerator.MoveTo(vertex); |
| 0 | 23 | | } |
| | 24 | |
|
| | 25 | | public bool MoveTo(EdgeId edgeId, bool forward = true) |
| 12 | 26 | | { |
| 12 | 27 | | return _edgeEnumerator.MoveTo(edgeId, forward); |
| 12 | 28 | | } |
| | 29 | |
|
| | 30 | | public (double cost, double turnCost) MoveToAndGetCost(EdgeId edgeId, bool forward, bool tailToHead, |
| | 31 | | IEnumerable<(EdgeId edgeId, byte? turn)>? previousEdges = null) |
| 36 | 32 | | { |
| 36 | 33 | | if (!_edgeEnumerator.MoveTo(edgeId, forward)) throw new Exception($"Edge not found!"); |
| | 34 | |
|
| 36 | 35 | | return this.GetCost(tailToHead, previousEdges); |
| 36 | 36 | | } |
| | 37 | |
|
| | 38 | | public (double cost, double turnCost) GetCost(bool tailToHead, |
| | 39 | | IEnumerable<(EdgeId edgeId, byte? turn)>? previousEdges = null) |
| 60 | 40 | | { |
| 60 | 41 | | return _costFunction.GetCost(_edgeEnumerator, tailToHead, previousEdges); |
| 60 | 42 | | } |
| | 43 | | } |