< Summary

Class:Itinero.Network.Tiles.Standalone.Global.NetworkRestriction
Assembly:Itinero
File(s):/home/runner/work/routing2/routing2/src/Itinero/Network/Tiles/Standalone/Global/NetworkRestriction.cs
Covered lines:12
Uncovered lines:6
Coverable lines:18
Total lines:63
Line coverage:66.6% (12 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_Count()100%1100%
get_Item(...)100%1100%
get_IsProhibitory()100%1100%
get_Attributes()100%1100%
GetEnumerator()100%10%
System.Collections.IEnumerable.GetEnumerator()100%10%

File(s)

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

#LineLine coverage
 1using System;
 2using System.Collections;
 3using System.Collections.Generic;
 4
 5namespace Itinero.Network.Tiles.Standalone.Global;
 6
 7/// <summary>
 8/// A restriction on the network.
 9/// </summary>
 10/// <remarks>
 11/// A sequence of restricted edges that can either be prohibitive or obligatory. This can be used to represent the class
 12/// </remarks>
 13public class NetworkRestriction : IEnumerable<(EdgeId edge, bool forward)>
 14{
 15    private readonly List<(EdgeId edge, bool forward)> _sequence;
 16
 17    /// <summary>
 18    /// Creates a new network turn restriction.
 19    /// </summary>
 20    /// <param name="sequence">The sequence that is either prohibited or mandatory.</param>
 21    /// <param name="isProhibitory">Flag to set the restriction to prohibited or mandatory.</param>
 22    /// <param name="attributes">The attributes.</param>
 103223    public NetworkRestriction(IEnumerable<(EdgeId edge, bool forward)> sequence, bool isProhibitory,
 103224        IEnumerable<(string key, string value)> attributes)
 103225    {
 103226        _sequence = new List<(EdgeId edge, bool forward)>(sequence);
 103227        if (_sequence.Count < 2) throw new ArgumentException("A restriction has to have at least 2 edges");
 28
 103229        this.IsProhibitory = isProhibitory;
 103230        this.Attributes = attributes;
 103231    }
 32
 33    /// <summary>
 34    /// Gets the number of edges.
 35    /// </summary>
 411536    public int Count => _sequence.Count;
 37
 38    /// <summary>
 39    /// Gets the edge at the given index.
 40    /// </summary>
 41    /// <param name="index">The index.</param>
 206442    public (EdgeId edge, bool forward) this[int index] => _sequence[index];
 43
 44    /// <summary>
 45    /// Returns true if the restriction is negative.
 46    /// </summary>
 103247    public bool IsProhibitory { get; }
 48
 49    /// <summary>
 50    /// The attributes associated with the restriction.
 51    /// </summary>
 101952    public IEnumerable<(string key, string value)> Attributes { get; }
 53
 54    public IEnumerator<(EdgeId edge, bool forward)> GetEnumerator()
 055    {
 056        return _sequence.GetEnumerator();
 057    }
 58
 59    IEnumerator IEnumerable.GetEnumerator()
 060    {
 061        return this.GetEnumerator();
 062    }
 63}