< Summary

Class:Itinero.IO.Osm.Tiles.GlobalEdgeIdExtensions
Assembly:Itinero.IO.Osm
File(s):/home/runner/work/routing2/routing2/src/Itinero.IO.Osm/Tiles/GlobalEdgeIdExtensions.cs
Covered lines:15
Uncovered lines:10
Coverable lines:25
Total lines:44
Line coverage:60% (15 of 25)
Covered branches:2
Total branches:6
Branch coverage:33.3% (2 of 6)
Tag:224_14471318300

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
GenerateGlobalEdgeIdAndDirection(...)0%20%
GenerateGlobalEdgeIdAndDirection(...)50%2100%
GenerateGlobalEdgeId(...)100%1100%
GenerateGlobalEdgeId(...)50%2100%
ParseGlobalId(...)100%10%

File(s)

/home/runner/work/routing2/routing2/src/Itinero.IO.Osm/Tiles/GlobalEdgeIdExtensions.cs

#LineLine coverage
 1using System;
 2using OsmSharp;
 3
 4namespace Itinero.IO.Osm.Tiles;
 5
 6internal static class GlobalEdgeIdExtensions
 7{
 8    public static (Guid guid, bool forward) GenerateGlobalEdgeIdAndDirection(this Way way, int node1Idx, int node2Idx)
 09    {
 010        var forward = node1Idx < node2Idx;
 011        return forward ? (way.GenerateGlobalEdgeId(node1Idx, node2Idx), true) : (way.GenerateGlobalEdgeId(node2Idx, node
 012    }
 13
 14    public static (Guid guid, bool forward) GenerateGlobalEdgeIdAndDirection(long wayId, int node1Idx, int node2Idx)
 215    {
 216        var forward = node1Idx < node2Idx;
 217        return forward ? (GenerateGlobalEdgeId(wayId, node1Idx, node2Idx), true) : (GenerateGlobalEdgeId(wayId, node2Idx
 218    }
 19
 20    public static Guid GenerateGlobalEdgeId(this Way way, int node1Idx, int node2Idx)
 721    {
 722        return GenerateGlobalEdgeId(way.Id.Value, node1Idx, node2Idx);
 723    }
 24
 25    public static Guid GenerateGlobalEdgeId(long wayId, int node1Idx, int node2Idx)
 926    {
 927        if (node1Idx >= node2Idx) throw new ArgumentException("edge is not given in forward direction");
 28
 929        var data = new byte[16];
 930        BitConverter.GetBytes(wayId).CopyTo(data.AsSpan());
 931        BitConverter.GetBytes(node1Idx).CopyTo(data.AsSpan(8));
 932        BitConverter.GetBytes(node2Idx).CopyTo(data.AsSpan(12));
 33
 934        return new Guid(data);
 935    }
 36
 37    public static void ParseGlobalId(this Guid guid, out long wayId, out int node1Idx, out int node2Idx)
 038    {
 039        var bytes = guid.ToByteArray();
 040        wayId = BitConverter.ToInt64(bytes, 0);
 041        node1Idx = BitConverter.ToInt32(bytes, 8);
 042        node2Idx = BitConverter.ToInt32(bytes, 12);
 043    }
 44}