< Summary

Class:Itinero.Network.Tiles.Standalone.Global.GlobalRestriction
Assembly:Itinero
File(s):/home/runner/work/routing2/routing2/src/Itinero/Network/Tiles/Standalone/Global/GlobalRestriction.cs
Covered lines:15
Uncovered lines:3
Coverable lines:18
Total lines:67
Line coverage:83.3% (15 of 18)
Covered branches:1
Total branches:2
Branch coverage:50% (1 of 2)
Tag:251_23667616543

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
.ctor(...)50%2100%
get_IsProhibitory()100%1100%
get_Attributes()100%1100%
GetEnumerator()100%1100%
System.Collections.IEnumerable.GetEnumerator()100%10%
get_Count()100%1100%
get_Item(...)100%1100%

File(s)

/home/runner/work/routing2/routing2/src/Itinero/Network/Tiles/Standalone/Global/GlobalRestriction.cs

#LineLine coverage
 1using System;
 2using System.Collections;
 3using System.Collections.Generic;
 4using System.Linq;
 5
 6namespace Itinero.Network.Tiles.Standalone.Global;
 7
 8/// <summary>
 9/// A global restriction.
 10///
 11/// This contains:
 12/// - The sequence of edges that incurs the cost.
 13/// - A prohibitory flag:
 14///   - true : only this specific turn with the prefix edges is forbidden,
 15///   - false: only this turn is allowed, all other turns at the vertex are forbidden.
 16///
 17/// Assumptions:
 18/// - The restriction occurs at the vertex between the last two edges in the sequence.
 19/// </summary>
 20/// <remarks>
 21/// Why model restrictions like this:
 22/// We do not know the full structure of the network at the time this is defined only the part within the tile.
 23/// </remarks>
 24public class GlobalRestriction : IReadOnlyList<GlobalEdgeId>
 25{
 26    private readonly IReadOnlyList<GlobalEdgeId> _edges;
 27
 28    /// <summary>
 29    /// Creates a new network restriction.
 30    /// </summary>
 31    /// <param name="sequence">The sequence that is either prohibited or mandatory.</param>
 32    /// <param name="isProhibitory">Flag to set the restriction to prohibited or mandatory.</param>
 33    /// <param name="attributes">The attributes.</param>
 476334    public GlobalRestriction(IEnumerable<GlobalEdgeId> sequence, bool isProhibitory,
 476335        IEnumerable<(string key, string value)> attributes)
 476336    {
 476337        _edges = sequence.ToList();
 476338        if (_edges.Count < 2) throw new ArgumentException("A restriction has to have at least 2 edges");
 39
 476340        this.IsProhibitory = isProhibitory;
 476341        this.Attributes = attributes;
 476342    }
 43
 44    /// <summary>
 45    /// Returns true if the restriction is negative.
 46    /// </summary>
 103447    public bool IsProhibitory { get; }
 48
 49    /// <summary>
 50    /// The attributes associated with the restriction.
 51    /// </summary>
 103252    public IEnumerable<(string key, string value)> Attributes { get; }
 53
 54    public IEnumerator<GlobalEdgeId> GetEnumerator()
 475255    {
 475256        return _edges.GetEnumerator();
 475257    }
 58
 59    IEnumerator IEnumerable.GetEnumerator()
 060    {
 061        return ((IEnumerable)_edges).GetEnumerator();
 062    }
 63
 364    public int Count => _edges.Count;
 65
 2166    public GlobalEdgeId this[int index] => _edges[index];
 67}