< Summary

Class:Itinero.Network.Enumerators.Vertices.RoutingNetworkVertexEnumerator
Assembly:Itinero
File(s):/home/runner/work/routing2/routing2/src/Itinero/Network/Enumerators/Vertices/RoutingNetworkVertexEnumerator.cs
Covered lines:41
Uncovered lines:6
Coverable lines:47
Total lines:86
Line coverage:87.2% (41 of 47)
Covered branches:10
Total branches:10
Branch coverage:100% (10 of 10)
Tag:284_38118444584

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
.ctor(...)100%1100%
MoveNexTile()100%4100%
MoveNext()100%6100%
get_Current()100%1100%
Reset()100%10%

File(s)

/home/runner/work/routing2/routing2/src/Itinero/Network/Enumerators/Vertices/RoutingNetworkVertexEnumerator.cs

#LineLine coverage
 1using System.Collections.Generic;
 2using Itinero.Network.Tiles;
 3
 4namespace Itinero.Network.Enumerators.Vertices;
 5
 6internal class RoutingNetworkVertexEnumerator
 7{
 8    private readonly RoutingNetwork _routingNetwork;
 9    private readonly IEnumerator<uint> _tileEnumerator;
 10
 9411    public RoutingNetworkVertexEnumerator(RoutingNetwork routingNetwork)
 9412    {
 9413        _routingNetwork = routingNetwork;
 9414        _tileEnumerator = routingNetwork.GetTileEnumerator();
 15
 9416        this.Current = VertexId.Empty;
 9417    }
 18
 9419    private long _localId = -1;
 9420    private uint _tileId = uint.MaxValue;
 21    private NetworkTile? _tile;
 22
 23    private void MoveNexTile()
 193624    {
 488880725        while (true)
 488880726        {
 488880727            if (!_tileEnumerator.MoveNext())
 6628            {
 6629                return;
 30            }
 31
 32            // get tile for reading.
 488874133            _tileId = _tileEnumerator.Current;
 488874134            _tile = _routingNetwork.GetTileForRead(_tileId);
 35
 488874136            if (_tile != null)
 187037            {
 187038                return;
 39            }
 488687140        }
 193641    }
 42
 43    public bool MoveNext()
 545844    {
 730045        while (true)
 730046        {
 47            // when vertex is empty move to the first tile.
 730048            if (this.Current.IsEmpty())
 9449            {
 9450                this.MoveNexTile();
 9451            }
 52
 53            // no current tile here, no data.
 730054            if (_tile == null)
 6655            {
 6656                return false;
 57            }
 58
 59            // move to the next vertex.
 723460            _localId++;
 723461            this.Current = new VertexId(_tileId, (uint)_localId);
 62
 63            // get vertex, if it exists, return true.
 64            // TODO: this check can be done faster without reading coordinates.
 723465            if (_tile.HasVertex(this.Current))
 539266            {
 539267                return true;
 68            }
 69
 70            // vertex doesn't exist, move to the next tile.
 184271            _localId = -1;
 184272            this.MoveNexTile();
 184273        }
 545874    }
 75
 2724676    public VertexId Current { get; private set; }
 77
 78    public void Reset()
 079    {
 080        this.Current = VertexId.Empty;
 081        _localId = -1;
 082        _tileId = uint.MaxValue;
 83
 084        _tileEnumerator.Reset();
 085    }
 86}