< Summary

Class:Itinero.Routing.Costs.NonLocalCostFunction
Assembly:Itinero
File(s):/home/runner/work/routing2/routing2/src/Itinero/Routing/Costs/NonLocalCostFunction.cs
Covered lines:11
Uncovered lines:0
Coverable lines:11
Total lines:41
Line coverage:100% (11 of 11)
Covered branches:2
Total branches:2
Branch coverage:100% (2 of 2)
Tag:284_38118444584

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
.ctor(...)100%1100%
Get(...)100%2100%

File(s)

/home/runner/work/routing2/routing2/src/Itinero/Routing/Costs/NonLocalCostFunction.cs

#LineLine coverage
 1using System.Collections.Generic;
 2using Itinero.Network;
 3using Itinero.Network.Enumerators.Edges;
 4
 5using Itinero.Routing.Flavours.Dijkstra;
 6
 7namespace Itinero.Routing.Costs;
 8
 9/// <summary>
 10/// Decorator that masks off local-access edges. Wraps an inner cost function and
 11/// reports <c>canAccess = false</c> (and cost 0, turn cost <see cref="double.MaxValue"/>)
 12/// for any edge the inner cost function flagged as <c>localAccess = true</c>.
 13///
 14/// Used by the N-only island classification (<c>IslandKind.NonLocal</c>): feeding this
 15/// into <see cref="Itinero.Network.Search.Islands.IslandClassifier"/> produces a
 16/// reachability classification over the subgraph that excludes <c>access=destination</c>
 17/// edges, i.e. the "main routable network" used by the access-aware routing rule.
 18/// </summary>
 19internal sealed class NonLocalCostFunction : ICostFunction
 20{
 21    private readonly ICostFunction _inner;
 22
 114923    public NonLocalCostFunction(ICostFunction inner)
 114924    {
 114925        _inner = inner;
 114926    }
 27
 28    public (bool canAccess, bool canStop, bool localAccess, double cost, double turnCost) Get(
 29        IEdgeEnumerator<RoutingNetwork> edgeEnumerator, bool tailToHead = true,
 30        PreviousEdgeEnumerable previousEdges = default)
 2339131    {
 2339132        var inner = _inner.Get(edgeEnumerator, tailToHead, previousEdges);
 2339133        if (inner.localAccess)
 2634        {
 35            // Mask off: the island classifier checks `canAccess && turnCost < MaxValue`.
 36            // Returning either failing condition is enough; we set both for clarity.
 2637            return (false, false, true, 0.0, double.MaxValue);
 38        }
 2336539        return inner;
 2339140    }
 41}

Methods/Properties

.ctor(...)
Get(...)