< 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:263_26948838820

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
 4816    public OsmGeoTagsPreprocessor(Func<OsmGeo, bool> action)
 4817    {
 4818        _action = action;
 4819    }
 20
 21    public override bool MoveNext(bool ignoreNodes, bool ignoreWays, bool ignoreRelations)
 58974122    {
 58974123        _current = null;
 24
 72915725        while (true)
 72915726        {
 72925327            if (!this.Source.MoveNext(ignoreNodes, ignoreWays, ignoreRelations)) return false;
 28
 72906129            var current = this.Source.Current();
 86847730            if (!_action(current)) continue;
 31
 58964532            _current = current;
 58964533            break;
 34        }
 35
 58964536        return true;
 58974137    }
 38
 39    public override OsmGeo Current()
 58964540    {
 58964541        if (_current == null)
 042            throw new InvalidOperationException(
 043                $"Current is null, do {nameof(MoveNext)} first.");
 44
 58964545        return _current;
 58964546    }
 47
 48    public override void Reset()
 7549    {
 7550        this.Source.Reset();
 7551    }
 52
 2753    public override bool CanReset => this.Source.CanReset;
 54}