| | | 1 | | using System.Collections.Generic; |
| | | 2 | | using Itinero.Network; |
| | | 3 | | using Itinero.Routing.Flavours.Dijkstra; |
| | | 4 | | |
| | | 5 | | namespace Itinero.Routing.Costs; |
| | | 6 | | |
| | | 7 | | internal static class ICostFunctionExtensions |
| | | 8 | | { |
| | | 9 | | public static DijkstraWeightFunc GetDijkstraWeightFunc(this ICostFunction costFunction) |
| | 11293 | 10 | | { |
| | 11293 | 11 | | return (enumerator, previousEdges) => |
| | 942623 | 12 | | { |
| | 11293 | 13 | | // fast path: when there are no previous edges, pass null to avoid boxing. |
| | 942623 | 14 | | if (previousEdges.IsEmpty) |
| | 401570 | 15 | | { |
| | 401570 | 16 | | var (_, _, cost, _) = costFunction.Get(enumerator, true, null); |
| | 401570 | 17 | | return (cost, 0.0); |
| | 11293 | 18 | | } |
| | 11293 | 19 | | |
| | 11293 | 20 | | // box the struct for ICostFunction. |
| | 541053 | 21 | | var (_, _, cost2, turnCost) = costFunction.Get(enumerator, true, previousEdges); |
| | 541053 | 22 | | return (cost2, turnCost); |
| | 953916 | 23 | | }; |
| | 11293 | 24 | | } |
| | | 25 | | } |