< Summary

Class:Itinero.Profiles.TurnCostFactor
Assembly:Itinero
File(s):/home/runner/work/routing2/routing2/src/Itinero/Profiles/TurnCostFactor.cs
Covered lines:7
Uncovered lines:2
Coverable lines:9
Total lines:51
Line coverage:77.7% (7 of 9)
Covered branches:0
Total branches:0
Tag:224_14471318300

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
.ctor(...)100%1100%
get_Factor()100%1100%
get_CostFactor()100%10%
get_IsEmpty()100%10%
get_IsBinary()100%1100%
.cctor()100%1100%

File(s)

/home/runner/work/routing2/routing2/src/Itinero/Profiles/TurnCostFactor.cs

#LineLine coverage
 1namespace Itinero.Profiles;
 2
 3/// <summary>
 4/// A turn cost factor used to customize turn cost handling per profile.
 5/// </summary>
 6/// <remarks>
 7/// There are few special values:
 8/// - 0: the turn costs are ignored.
 9/// - uint.maxvalue: the turn costs are binary, like in turn restrictions.
 10/// </remarks>
 11public readonly struct TurnCostFactor
 12{
 13    /// <summary>
 14    /// Creates a new turn cost factor.
 15    /// </summary>
 16    /// <param name="factor">The factor.</param>
 17    public TurnCostFactor(uint factor = 0)
 218    {
 219        this.Factor = factor;
 220    }
 21
 22    /// <summary>
 23    /// Gets the turn cost factor.
 24    /// </summary>
 425    public uint Factor { get; }
 26
 27    /// <summary>
 28    /// Gets the value to multiply the turn cost with to calculate the weight.
 29    /// </summary>
 030    public double CostFactor => this.Factor / 10.0;
 31
 32    /// <summary>
 33    /// Returns true if this factor is empty, causing the turn costs to be ignored.
 34    /// </summary>
 035    public bool IsEmpty => this.Factor == 0;
 36
 37    /// <summary>
 38    /// Returns true if the factor is binary, for example in the case of a turn-restriction cost.
 39    /// </summary>
 440    public bool IsBinary => this.Factor == uint.MaxValue;
 41
 42    /// <summary>
 43    /// Gets the default empty turn cost factor.
 44    /// </summary>
 145    public static TurnCostFactor Empty = new(0);
 46
 47    /// <summary>
 48    /// Gets the binary turn cost factor.
 49    /// </summary>
 150    public static TurnCostFactor Binary = new(uint.MaxValue);
 51}