< 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:251_23667616543

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
 1711    public RoutingNetworkVertexEnumerator(RoutingNetwork routingNetwork)
 1712    {
 1713        _routingNetwork = routingNetwork;
 1714        _tileEnumerator = routingNetwork.GetTileEnumerator();
 15
 1716        this.Current = VertexId.Empty;
 1717    }
 18
 1719    private long _localId = -1;
 1720    private uint _tileId = uint.MaxValue;
 21    private NetworkTile? _tile;
 22
 23    private void MoveNexTile()
 3024    {
 86087625        while (true)
 86087626        {
 86087627            if (!_tileEnumerator.MoveNext())
 1428            {
 1429                return;
 30            }
 31
 32            // get tile for reading.
 86086233            _tileId = _tileEnumerator.Current;
 86086234            _tile = _routingNetwork.GetTileForRead(_tileId);
 35
 86086236            if (_tile != null)
 1637            {
 1638                return;
 39            }
 86084640        }
 3041    }
 42
 43    public bool MoveNext()
 4244    {
 5545        while (true)
 5546        {
 47            // when vertex is empty move to the first tile.
 5548            if (this.Current.IsEmpty())
 1749            {
 1750                this.MoveNexTile();
 1751            }
 52
 53            // no current tile here, no data.
 5554            if (_tile == null)
 1455            {
 1456                return false;
 57            }
 58
 59            // move to the next vertex.
 4160            _localId++;
 4161            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.
 4165            if (_tile.HasVertex(this.Current))
 2866            {
 2867                return true;
 68            }
 69
 70            // vertex doesn't exist, move to the next tile.
 1371            _localId = -1;
 1372            this.MoveNexTile();
 1373        }
 4274    }
 75
 17476    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}