< 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:224_14471318300

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
 1511    public RoutingNetworkVertexEnumerator(RoutingNetwork routingNetwork)
 1512    {
 1513        _routingNetwork = routingNetwork;
 1514        _tileEnumerator = routingNetwork.GetTileEnumerator();
 15
 1516        this.Current = VertexId.Empty;
 1517    }
 18
 1519    private long _localId = -1;
 1520    private uint _tileId = uint.MaxValue;
 21    private NetworkTile? _tile;
 22
 23    private void MoveNexTile()
 2624    {
 72980225        while (true)
 72980226        {
 72980227            if (!_tileEnumerator.MoveNext())
 1228            {
 1229                return;
 30            }
 31
 32            // get tile for reading.
 72979033            _tileId = _tileEnumerator.Current;
 72979034            _tile = _routingNetwork.GetTileForRead(_tileId);
 35
 72979036            if (_tile != null)
 1437            {
 1438                return;
 39            }
 72977640        }
 2641    }
 42
 43    public bool MoveNext()
 3544    {
 4645        while (true)
 4646        {
 47            // when vertex is empty move to the first tile.
 4648            if (this.Current.IsEmpty())
 1549            {
 1550                this.MoveNexTile();
 1551            }
 52
 53            // no current tile here, no data.
 4654            if (_tile == null)
 1255            {
 1256                return false;
 57            }
 58
 59            // move to the next vertex.
 3460            _localId++;
 3461            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.
 3465            if (_tile.HasVertex(this.Current))
 2366            {
 2367                return true;
 68            }
 69
 70            // vertex doesn't exist, move to the next tile.
 1171            _localId = -1;
 1172            this.MoveNexTile();
 1173        }
 3574    }
 75
 14876    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}