| | | 1 | | using Itinero.Network; |
| | | 2 | | using Itinero.Network.Enumerators.Edges; |
| | | 3 | | using Itinero.Routing.Costs; |
| | | 4 | | |
| | | 5 | | namespace Itinero.Routing.Flavours.Dijkstra; |
| | | 6 | | |
| | | 7 | | /// <summary> |
| | | 8 | | /// Thin wrapper that pairs an edge enumerator with a cost function. Used by |
| | | 9 | | /// <see cref="SnapPointExtensions.TrySingleHop"/> to compute per-direction costs on a |
| | | 10 | | /// single edge without re-positioning the enumerator twice. |
| | | 11 | | /// </summary> |
| | | 12 | | internal class CostEdgeEnumerator |
| | | 13 | | { |
| | | 14 | | private readonly RoutingNetworkEdgeEnumerator _edgeEnumerator; |
| | | 15 | | private readonly ICostFunction _costFunction; |
| | | 16 | | |
| | 53 | 17 | | internal CostEdgeEnumerator(RoutingNetworkEdgeEnumerator edgeEnumerator, ICostFunction costFunction) |
| | 53 | 18 | | { |
| | 53 | 19 | | _edgeEnumerator = edgeEnumerator; |
| | 53 | 20 | | _costFunction = costFunction; |
| | 53 | 21 | | } |
| | | 22 | | |
| | | 23 | | public bool MoveTo(EdgeId edgeId, bool forward = true) |
| | 53 | 24 | | { |
| | 53 | 25 | | return _edgeEnumerator.MoveTo(edgeId, forward); |
| | 53 | 26 | | } |
| | | 27 | | |
| | | 28 | | public (double cost, double turnCost) GetCost(bool tailToHead) |
| | 106 | 29 | | { |
| | 106 | 30 | | var (_, _, _, cost, turnCost) = _costFunction.Get(_edgeEnumerator, tailToHead, null); |
| | 106 | 31 | | return (cost, turnCost); |
| | 106 | 32 | | } |
| | | 33 | | } |