< Summary

Class:Itinero.Profiles.EdgeFactor
Assembly:Itinero
File(s):/home/runner/work/routing2/routing2/src/Itinero/Profiles/EdgeFactor.cs
Covered lines:14
Uncovered lines:14
Coverable lines:28
Total lines:89
Line coverage:50% (14 of 28)
Covered branches:0
Total branches:4
Branch coverage:0% (0 of 4)
Tag:224_14471318300

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
.ctor(...)100%1100%
get_ForwardFactor()100%1100%
get_BackwardFactor()100%1100%
get_BackwardSpeed()100%1100%
get_BackwardSpeedMeterPerSecond()100%10%
get_ForwardSpeed()100%1100%
get_ForwardSpeedMeterPerSecond()100%1100%
get_CanStop()100%1100%
get_NoFactor()100%10%
get_Reverse()100%1100%
ToString()0%40%
GetHashCode()100%10%

File(s)

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

#LineLine coverage
 1namespace Itinero.Profiles;
 2
 3/// <summary>
 4/// An 'EdgeFactor' contains the essential information to perform route planning, such as speed and priority in forward 
 5/// </summary>
 6public readonly struct EdgeFactor
 7{
 8    /// <summary>
 9    /// Creates a new edge factor.
 10    /// </summary>
 11    /// <param name="forwardFactor">The forward factor.</param>
 12    /// <param name="backwardFactor">The backward factor.</param>
 13    /// <param name="forwardSpeed">The forward speed in ms/s multiplied by 100.</param>
 14    /// <param name="backwardSpeed">The backward speed in ms/s multiplied by 100.</param>
 15    /// <param name="canStop">The can stop.</param>
 16    public EdgeFactor(uint forwardFactor, uint backwardFactor,
 17        ushort forwardSpeed, ushort backwardSpeed, bool canStop = true)
 32018    {
 32019        this.ForwardFactor = forwardFactor;
 32020        this.BackwardFactor = backwardFactor;
 32021        this.ForwardSpeed = forwardSpeed;
 32022        this.BackwardSpeed = backwardSpeed;
 32023        this.CanStop = canStop;
 32024    }
 25
 26    /// <summary>
 27    /// Gets the forward factor, multiplied by an edge distance this is the weight.
 28    /// </summary>
 27829    public uint ForwardFactor { get; }
 30
 31    /// <summary>
 32    /// Gets the backward factor, multiplied by an edge distance this is the weight.
 33    /// </summary>
 13134    public uint BackwardFactor { get; }
 35
 36    /// <summary>
 37    /// Gets the backward speed in m/s multiplied by 100.
 38    /// </summary>
 10039    public ushort BackwardSpeed { get; }
 40
 41    /// <summary>
 42    /// Gets the backward speed in m/s.
 43    /// </summary>
 044    public double BackwardSpeedMeterPerSecond => this.BackwardSpeed / 100.0;
 45
 46    /// <summary>
 47    /// Gets the forward speed in ms/s multiplied by 100.
 48    /// </summary>
 13049    public ushort ForwardSpeed { get; }
 50
 51    /// <summary>
 52    /// Gets the backward speed in m/s.
 53    /// </summary>
 3054    public double ForwardSpeedMeterPerSecond => this.ForwardSpeed / 100.0;
 55
 56    /// <summary>
 57    /// Gets the can stop flag.
 58    /// </summary>
 29759    public bool CanStop { get; }
 60
 61    /// <summary>
 62    /// Gets a static no-factor.
 63    /// </summary>
 064    public static EdgeFactor NoFactor => new(0, 0, 0, 0);
 65
 66    /// <summary>
 67    /// Gets the exact reverse, switches backward and forward.
 68    /// </summary>
 10069    public EdgeFactor Reverse => new(this.BackwardFactor, this.ForwardFactor, this.BackwardSpeed, this.ForwardSpeed, thi
 70
 71    /// <inheritdoc/>
 72    public override string ToString()
 073    {
 074        var forwardSpeed = this.ForwardSpeed / 100.0 * 3.6;
 075        if (this.ForwardFactor == this.BackwardFactor &&
 076            this.ForwardSpeed == this.BackwardSpeed)
 077        {
 078            return $"{this.ForwardFactor:F1}({forwardSpeed:F1}km/h)";
 79        }
 80
 081        var backwardSpeed = this.BackwardSpeed / 100.0 * 3.6;
 082        return $"F:{this.ForwardFactor:F1}({forwardSpeed:F1}km/h) B:{this.BackwardFactor:F1}({backwardSpeed:F1}km/h)";
 083    }
 84
 85    public override int GetHashCode()
 086    {
 087        return (int)(this.ForwardFactor ^ (this.ForwardSpeed << 8) ^ (this.BackwardFactor << 16) ^ (this.ForwardSpeed <<
 088    }
 89}