< 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:3
Uncovered lines:25
Coverable lines:28
Total lines:50
Line coverage:10.7% (3 of 28)
Covered branches:0
Total branches:6
Branch coverage:0% (0 of 6)
Tag:251_23667616543

Metrics

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

File(s)

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

#LineLine coverage
 1using System;
 2using Itinero.Network.Tiles.Standalone.Global;
 3using OsmSharp;
 4
 5namespace Itinero.IO.Osm.Tiles;
 6
 7internal static class GlobalEdgeIdExtensions
 8{
 9    public static (Guid guid, bool forward) GenerateGlobalEdgeIdAndDirection(this Way way, int node1Idx, int node2Idx)
 010    {
 011        var forward = node1Idx < node2Idx;
 012        return forward ? (way.GenerateGlobalEdgeId(node1Idx, node2Idx), true) : (way.GenerateGlobalEdgeId(node2Idx, node
 013    }
 14
 15    public static (Guid guid, bool forward) GenerateGlobalEdgeIdAndDirection(long wayId, int node1Idx, int node2Idx)
 016    {
 017        var forward = node1Idx < node2Idx;
 018        return forward ? (GenerateGlobalEdgeId(wayId, node1Idx, node2Idx), true) : (GenerateGlobalEdgeId(wayId, node2Idx
 019    }
 20
 21    public static Guid GenerateGlobalEdgeId(this Way way, int node1Idx, int node2Idx)
 022    {
 023        return GenerateGlobalEdgeId(way.Id.Value, node1Idx, node2Idx);
 024    }
 25
 26    public static GlobalEdgeId CreateGlobalEdgeId(this Way way, int node1Idx, int node2Idx)
 596527    {
 596528        return GlobalEdgeId.Create(way.Id!.Value, node1Idx, node2Idx);
 596529    }
 30
 31    public static Guid GenerateGlobalEdgeId(long wayId, int node1Idx, int node2Idx)
 032    {
 033        if (node1Idx >= node2Idx) throw new ArgumentException("edge is not given in forward direction");
 34
 035        var data = new byte[16];
 036        BitConverter.GetBytes(wayId).CopyTo(data.AsSpan());
 037        BitConverter.GetBytes(node1Idx).CopyTo(data.AsSpan(8));
 038        BitConverter.GetBytes(node2Idx).CopyTo(data.AsSpan(12));
 39
 040        return new Guid(data);
 041    }
 42
 43    public static void ParseGlobalId(this Guid guid, out long wayId, out int node1Idx, out int node2Idx)
 044    {
 045        var bytes = guid.ToByteArray();
 046        wayId = BitConverter.ToInt64(bytes, 0);
 047        node1Idx = BitConverter.ToInt32(bytes, 8);
 048        node2Idx = BitConverter.ToInt32(bytes, 12);
 049    }
 50}