< 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:263_26948838820

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
 4211    public RoutingNetworkVertexEnumerator(RoutingNetwork routingNetwork)
 4212    {
 4213        _routingNetwork = routingNetwork;
 4214        _tileEnumerator = routingNetwork.GetTileEnumerator();
 15
 4216        this.Current = VertexId.Empty;
 4217    }
 18
 4219    private long _localId = -1;
 4220    private uint _tileId = uint.MaxValue;
 21    private NetworkTile? _tile;
 22
 23    private void MoveNexTile()
 6424    {
 148088325        while (true)
 148088326        {
 148088327            if (!_tileEnumerator.MoveNext())
 1428            {
 1429                return;
 30            }
 31
 32            // get tile for reading.
 148086933            _tileId = _tileEnumerator.Current;
 148086934            _tile = _routingNetwork.GetTileForRead(_tileId);
 35
 148086936            if (_tile != null)
 5037            {
 5038                return;
 39            }
 148081940        }
 6441    }
 42
 43    public bool MoveNext()
 10244    {
 12445        while (true)
 12446        {
 47            // when vertex is empty move to the first tile.
 12448            if (this.Current.IsEmpty())
 4249            {
 4250                this.MoveNexTile();
 4251            }
 52
 53            // no current tile here, no data.
 12454            if (_tile == null)
 1455            {
 1456                return false;
 57            }
 58
 59            // move to the next vertex.
 11060            _localId++;
 11061            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.
 11065            if (_tile.HasVertex(this.Current))
 8866            {
 8867                return true;
 68            }
 69
 70            // vertex doesn't exist, move to the next tile.
 2271            _localId = -1;
 2272            this.MoveNexTile();
 2273        }
 10274    }
 75
 46676    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}