< Summary

Class:Itinero.IO.Osm.Streams.OsmGeoTagsPreprocessor
Assembly:Itinero.IO.Osm
File(s):/home/runner/work/routing2/routing2/src/Itinero.IO.Osm/Streams/OsmGeoTagsPreprocessor.cs
Covered lines:23
Uncovered lines:2
Coverable lines:25
Total lines:54
Line coverage:92% (23 of 25)
Covered branches:5
Total branches:6
Branch coverage:83.3% (5 of 6)
Tag:224_14471318300

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
.ctor(...)100%1100%
MoveNext(...)100%4100%
Current()50%266.66%
Reset()100%1100%
get_CanReset()100%1100%

File(s)

/home/runner/work/routing2/routing2/src/Itinero.IO.Osm/Streams/OsmGeoTagsPreprocessor.cs

#LineLine coverage
 1using System;
 2using OsmSharp;
 3using OsmSharp.Streams.Filters;
 4
 5namespace Itinero.IO.Osm.Streams;
 6
 7/// <summary>
 8/// An OSM tags preprocessor.
 9/// </summary>
 10internal class OsmGeoTagsPreprocessor : OsmStreamFilter
 11{
 12    private readonly Func<OsmGeo, bool> _action;
 13
 14    private OsmGeo? _current;
 15
 516    public OsmGeoTagsPreprocessor(Func<OsmGeo, bool> action)
 517    {
 518        _action = action;
 519    }
 20
 21    public override bool MoveNext(bool ignoreNodes, bool ignoreWays, bool ignoreRelations)
 4622    {
 4623        _current = null;
 24
 5025        while (true)
 5026        {
 6027            if (!this.Source.MoveNext(ignoreNodes, ignoreWays, ignoreRelations)) return false;
 28
 4029            var current = this.Source.Current();
 4430            if (!_action(current)) continue;
 31
 3632            _current = current;
 3633            break;
 34        }
 35
 3636        return true;
 4637    }
 38
 39    public override OsmGeo Current()
 3640    {
 3641        if (_current == null)
 042            throw new InvalidOperationException(
 043                $"Current is null, do {nameof(MoveNext)} first.");
 44
 3645        return _current;
 3646    }
 47
 48    public override void Reset()
 849    {
 850        this.Source.Reset();
 851    }
 52
 353    public override bool CanReset => this.Source.CanReset;
 54}