< Summary

Class:Itinero.Instructions.Types.Generators.RoundaboutInstructionGenerator
Assembly:Itinero.Instructions
File(s):/home/runner/work/routing2/routing2/src/Itinero.Instructions/Types/Generators/RoundaboutInstructionGenerator.cs
Covered lines:32
Uncovered lines:0
Coverable lines:32
Total lines:53
Line coverage:100% (32 of 32)
Covered branches:10
Total branches:10
Branch coverage:100% (10 of 10)
Tag:224_14471318300

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
get_Name()100%1100%
Generate(...)100%10100%

File(s)

/home/runner/work/routing2/routing2/src/Itinero.Instructions/Types/Generators/RoundaboutInstructionGenerator.cs

#LineLine coverage
 1namespace Itinero.Instructions.Types.Generators;
 2
 3internal class RoundaboutInstructionGenerator : IInstructionGenerator
 4{
 115    public string Name { get; } = "roundabout";
 6
 7    public BaseInstruction? Generate(IndexedRoute route, int offset)
 128    {
 9        // The roundabout instruction starts when the next segment is on the roundabout ("Go on the roundabout...")
 10        // and ends when the person leaves the roundabout ("... and take the n'th exit")
 11
 1212        if (offset >= route.Last - 1)
 413        { // No next entries
 414            return null;
 15        }
 16
 817        var usedInstructions = 1;
 818        var exitCount = 0;
 1719        while (route.Meta[offset + usedInstructions].GetAttributeOrNull("junction") == "roundabout")
 920        {
 921            if (route.Branches.Count > offset + usedInstructions)
 922            {
 923                exitCount += route.Branches[offset + usedInstructions].Count;
 924            }
 25
 926            usedInstructions++;
 927        }
 28
 829        if (usedInstructions == 1)
 530        {
 31            // We didn't find a roundabout in the end
 532            return null;
 33        }
 34
 335        var inDegrees = route.ArrivingDirectionAt(offset); // Offset is still on the rampup
 336        var outDegrees = route.DepartingDirectionAt(offset + usedInstructions);
 37
 338        var shapeIndexEnd = offset + usedInstructions;
 339        if (shapeIndexEnd + 1 < route.Last)
 240        {
 41            // We add an extra index, as the first segment after the roundabout doesn't need an instruction for it;
 42            // This is always a right turn anyway
 243            shapeIndexEnd++;
 244        }
 45
 346        return new RoundaboutInstruction(route,
 347            offset,
 348             shapeIndexEnd,
 349            (inDegrees - outDegrees).NormalizeDegrees(),
 350            exitCount + 1
 351        );
 1252    }
 53}

Methods/Properties

get_Name()
Generate(...)