< 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:39
Line coverage:100% (11 of 11)
Covered branches:2
Total branches:2
Branch coverage:100% (2 of 2)
Tag:263_26948838820

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
 5namespace Itinero.Routing.Costs;
 6
 7/// <summary>
 8/// Decorator that masks off local-access edges. Wraps an inner cost function and
 9/// reports <c>canAccess = false</c> (and cost 0, turn cost <see cref="double.MaxValue"/>)
 10/// for any edge the inner cost function flagged as <c>localAccess = true</c>.
 11///
 12/// Used by the N-only island classification (<c>IslandKind.NonLocal</c>): feeding this
 13/// into <see cref="Itinero.Network.Search.Islands.IslandClassifier"/> produces a
 14/// reachability classification over the subgraph that excludes <c>access=destination</c>
 15/// edges, i.e. the "main routable network" used by the access-aware routing rule.
 16/// </summary>
 17internal sealed class NonLocalCostFunction : ICostFunction
 18{
 19    private readonly ICostFunction _inner;
 20
 104921    public NonLocalCostFunction(ICostFunction inner)
 104922    {
 104923        _inner = inner;
 104924    }
 25
 26    public (bool canAccess, bool canStop, bool localAccess, double cost, double turnCost) Get(
 27        IEdgeEnumerator<RoutingNetwork> edgeEnumerator, bool tailToHead = true,
 28        IEnumerable<(EdgeId edgeId, byte? turn)>? previousEdges = null)
 2309129    {
 2309130        var inner = _inner.Get(edgeEnumerator, tailToHead, previousEdges);
 2309131        if (inner.localAccess)
 2632        {
 33            // Mask off: the island classifier checks `canAccess && turnCost < MaxValue`.
 34            // Returning either failing condition is enough; we set both for clarity.
 2635            return (false, false, true, 0.0, double.MaxValue);
 36        }
 2306537        return inner;
 2309138    }
 39}

Methods/Properties

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