< 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:284_38118444584

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
 195316    public OsmGeoTagsPreprocessor(Func<OsmGeo, bool> action)
 195317    {
 195318        _action = action;
 195319    }
 20
 21    public override bool MoveNext(bool ignoreNodes, bool ignoreWays, bool ignoreRelations)
 174036122    {
 174036123        _current = null;
 24
 187977725        while (true)
 187977726        {
 188368327            if (!this.Source.MoveNext(ignoreNodes, ignoreWays, ignoreRelations)) return false;
 28
 187587129            var current = this.Source.Current();
 201528730            if (!_action(current)) continue;
 31
 173645532            _current = current;
 173645533            break;
 34        }
 35
 173645536        return true;
 174036137    }
 38
 39    public override OsmGeo Current()
 173645540    {
 173645541        if (_current == null)
 042            throw new InvalidOperationException(
 043                $"Current is null, do {nameof(MoveNext)} first.");
 44
 173645545        return _current;
 173645546    }
 47
 48    public override void Reset()
 388549    {
 388550        this.Source.Reset();
 388551    }
 52
 193253    public override bool CanReset => this.Source.CanReset;
 54}