< Summary

Class:Itinero.Profiles.EdgeFactor
Assembly:Itinero
File(s):/home/runner/work/routing2/routing2/src/Itinero/Profiles/EdgeFactor.cs
Covered lines:17
Uncovered lines:13
Coverable lines:30
Total lines:96
Line coverage:56.6% (17 of 30)
Covered branches:0
Total branches:4
Branch coverage:0% (0 of 4)
Tag:263_26948838820

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_IsLocalAccess()100%1100%
get_NoFactor()100%1100%
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    /// <param name="isLocalAccess">True if the edge is local-access only (e.g. <c>access=destination</c> for the profil
 17    public EdgeFactor(uint forwardFactor, uint backwardFactor,
 18        ushort forwardSpeed, ushort backwardSpeed, bool canStop = true, bool isLocalAccess = false)
 49929119    {
 49929120        this.ForwardFactor = forwardFactor;
 49929121        this.BackwardFactor = backwardFactor;
 49929122        this.ForwardSpeed = forwardSpeed;
 49929123        this.BackwardSpeed = backwardSpeed;
 49929124        this.CanStop = canStop;
 49929125        this.IsLocalAccess = isLocalAccess;
 49929126    }
 27
 28    /// <summary>
 29    /// Gets the forward factor, multiplied by an edge distance this is the weight.
 30    /// </summary>
 256990431    public uint ForwardFactor { get; }
 32
 33    /// <summary>
 34    /// Gets the backward factor, multiplied by an edge distance this is the weight.
 35    /// </summary>
 61586536    public uint BackwardFactor { get; }
 37
 38    /// <summary>
 39    /// Gets the backward speed in m/s multiplied by 100.
 40    /// </summary>
 49624141    public ushort BackwardSpeed { get; }
 42
 43    /// <summary>
 44    /// Gets the backward speed in m/s.
 45    /// </summary>
 046    public double BackwardSpeedMeterPerSecond => this.BackwardSpeed / 100.0;
 47
 48    /// <summary>
 49    /// Gets the forward speed in ms/s multiplied by 100.
 50    /// </summary>
 49686451    public ushort ForwardSpeed { get; }
 52
 53    /// <summary>
 54    /// Gets the backward speed in m/s.
 55    /// </summary>
 62356    public double ForwardSpeedMeterPerSecond => this.ForwardSpeed / 100.0;
 57
 58    /// <summary>
 59    /// Gets the can stop flag.
 60    /// </summary>
 159347561    public bool CanStop { get; }
 62
 63    /// <summary>
 64    /// True iff the edge is local-access only for the profile's mode. See <see cref="EdgeFactor(uint, uint, ushort, ush
 65    /// </summary>
 159347566    public bool IsLocalAccess { get; }
 67
 68    /// <summary>
 69    /// Gets a static no-factor.
 70    /// </summary>
 271    public static EdgeFactor NoFactor => new(0, 0, 0, 0);
 72
 73    /// <summary>
 74    /// Gets the exact reverse, switches backward and forward.
 75    /// </summary>
 49624176    public EdgeFactor Reverse => new(this.BackwardFactor, this.ForwardFactor, this.BackwardSpeed, this.ForwardSpeed, thi
 77
 78    /// <inheritdoc/>
 79    public override string ToString()
 080    {
 081        var forwardSpeed = this.ForwardSpeed / 100.0 * 3.6;
 082        if (this.ForwardFactor == this.BackwardFactor &&
 083            this.ForwardSpeed == this.BackwardSpeed)
 084        {
 085            return $"{this.ForwardFactor:F1}({forwardSpeed:F1}km/h)";
 86        }
 87
 088        var backwardSpeed = this.BackwardSpeed / 100.0 * 3.6;
 089        return $"F:{this.ForwardFactor:F1}({forwardSpeed:F1}km/h) B:{this.BackwardFactor:F1}({backwardSpeed:F1}km/h)";
 090    }
 91
 92    public override int GetHashCode()
 093    {
 094        return (int)(this.ForwardFactor ^ (this.ForwardSpeed << 8) ^ (this.BackwardFactor << 16) ^ (this.ForwardSpeed <<
 095    }
 96}