< 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:22
Uncovered lines:3
Coverable lines:25
Total lines:54
Line coverage:88% (22 of 25)
Covered branches:5
Total branches:6
Branch coverage:83.3% (5 of 6)
Tag:251_23667616543

Metrics

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

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
 2116    public OsmGeoTagsPreprocessor(Func<OsmGeo, bool> action)
 2117    {
 2118        _action = action;
 2119    }
 20
 21    public override bool MoveNext(bool ignoreNodes, bool ignoreWays, bool ignoreRelations)
 58927722    {
 58927723        _current = null;
 24
 72869325        while (true)
 72869326        {
 72873527            if (!this.Source.MoveNext(ignoreNodes, ignoreWays, ignoreRelations)) return false;
 28
 72865129            var current = this.Source.Current();
 86806730            if (!_action(current)) continue;
 31
 58923532            _current = current;
 58923533            break;
 34        }
 35
 58923536        return true;
 58927737    }
 38
 39    public override OsmGeo Current()
 58923540    {
 58923541        if (_current == null)
 042            throw new InvalidOperationException(
 043                $"Current is null, do {nameof(MoveNext)} first.");
 44
 58923545        return _current;
 58923546    }
 47
 48    public override void Reset()
 2149    {
 2150        this.Source.Reset();
 2151    }
 52
 053    public override bool CanReset => this.Source.CanReset;
 54}