| | 1 | | using System; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using Itinero.Network.Enumerators.Edges; |
| | 4 | | using Itinero.Routing.Costs; |
| | 5 | |
|
| | 6 | | namespace Itinero.Network.Search.Islands; |
| | 7 | |
|
| | 8 | | internal static class ICostFunctionExtensions |
| | 9 | | { |
| | 10 | | /// <summary> |
| | 11 | | /// Gets the cost of a turn from the previous edges sequence to the given edge in the enumerator in a forward direct |
| | 12 | | /// |
| | 13 | | /// This does NOT include the cost of the previous edges. |
| | 14 | | /// </summary> |
| | 15 | | /// <param name="costFunction">The cost function.</param> |
| | 16 | | /// <param name="enumerator">The edge to test.</param> |
| | 17 | | /// <param name="forward">Then true, calculate the cost including turn cost from (previousEdge ->) enumerator.tail - |
| | 18 | | /// <param name="previousEdges">A sequence of previously traversed edge, if any.</param> |
| | 19 | | /// <returns>True if the current edge is traversable and the turn cost allows the turn.</returns> |
| | 20 | | public static bool GetIslandBuilderCost(this ICostFunction costFunction, |
| | 21 | | RoutingNetworkEdgeEnumerator enumerator, bool forward = true, IEnumerable<(EdgeId edgeId, byte? turn)>? previous |
| 152 | 22 | | { |
| 152 | 23 | | var cost = costFunction.Get(enumerator, forward, previousEdges); |
| | 24 | |
|
| 152 | 25 | | return cost is { canAccess: true, turnCost: < double.MaxValue }; |
| 152 | 26 | | } |
| | 27 | | } |