< Summary

Class:Itinero.Instructions.Types.Generators.IntersectionInstructionGenerator
Assembly:Itinero.Instructions
File(s):/home/runner/work/routing2/routing2/src/Itinero.Instructions/Types/Generators/IntersectionInstructionGenerator.cs
Covered lines:26
Uncovered lines:4
Coverable lines:30
Total lines:54
Line coverage:86.6% (26 of 30)
Covered branches:4
Total branches:6
Branch coverage:66.6% (4 of 6)
Tag:224_14471318300

Metrics

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

File(s)

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

#LineLine coverage
 1using System.Collections.Generic;
 2using System.Linq;
 3using Itinero.Geo;
 4
 5namespace Itinero.Instructions.Types.Generators;
 6
 7internal class IntersectionInstructionGenerator : IInstructionGenerator
 8{
 79    public string Name { get; } = "intersection";
 10
 11    public BaseInstruction? Generate(IndexedRoute route, int offset)
 412    {
 413        if (route.Last == offset + 1)
 014        {
 15            // The next maneuver is 'arrive', no need to emit a complicated intersection-instruction
 016            return null;
 17        }
 18
 419        var branches = route.Branches[offset];
 420        if (branches.Count == 0)
 021        {
 022            return null;
 23        }
 24
 425        var incomingStreets = new List<(int relativeDegrees, IEnumerable<(string, string)> tags)>();
 26
 27
 428        var incomingDirection = route.ArrivingDirectionAt(offset);
 2629        foreach (var branch in branches)
 730        {
 731            var branchAbsDirection = branch.Coordinate.AngleWithMeridian(route.Shape[offset]);
 732            var branchRelDirection = incomingDirection - branchAbsDirection;
 733            incomingStreets.Add((branchRelDirection.NormalizeDegrees(), branch.Attributes));
 734        }
 35
 436        var directionChange = route.DirectionChangeAt(offset);
 437        var nextStep = (directionChange, route.Meta[offset].Attributes);
 438        incomingStreets.Add(nextStep);
 39
 1540        incomingStreets = incomingStreets.OrderByDescending(br => br.relativeDegrees).ToList();
 41
 442        var actualIndex = incomingStreets.IndexOf(nextStep);
 43
 44
 445        var instruction = new IntersectionInstruction(route,
 446            offset,
 447            offset + 1,
 448            directionChange,
 449            incomingStreets,
 450            (uint)actualIndex);
 51
 452        return instruction;
 453    }
 54}

Methods/Properties

get_Name()
Generate(...)