< Summary

Class:Itinero.IO.Osm.Restrictions.Barriers.OsmBarrierParser
Assembly:Itinero.IO.Osm
File(s):/home/runner/work/routing2/routing2/src/Itinero.IO.Osm/Restrictions/Barriers/OsmBarrierParser.cs
Covered lines:10
Uncovered lines:0
Coverable lines:10
Total lines:43
Line coverage:100% (10 of 10)
Covered branches:4
Total branches:6
Branch coverage:66.6% (4 of 6)
Tag:251_23667616543

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
IsBarrier(...)100%2100%
TryParse(...)50%4100%

File(s)

/home/runner/work/routing2/routing2/src/Itinero.IO.Osm/Restrictions/Barriers/OsmBarrierParser.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Diagnostics.CodeAnalysis;
 4using System.Linq;
 5using OsmSharp;
 6
 7namespace Itinero.IO.Osm.Restrictions.Barriers;
 8
 9/// <summary>
 10/// Parses OSM barriers.
 11/// </summary>
 12public class OsmBarrierParser
 13{
 14    /// <summary>
 15    /// Returns true if the node is a barrier.
 16    /// </summary>
 17    /// <param name="node">The node.</param>
 18    /// <returns>True if the node is a barrier, false otherwise.</returns>
 19    public bool IsBarrier(Node node)
 53742920    {
 53742921        return node.Tags != null && node.Tags.ContainsKey("barrier");
 53742922    }
 23
 24    /// <summary>
 25    /// Tries to parse a barrier.
 26    /// </summary>
 27    /// <param name="node">The node.</param>
 28    /// <param name="ways">The ways containing the node the barrier is on.</param>
 29    /// <param name="barrier">The barrier, if any.</param>
 30    /// <returns>True if parsing succeeded.</returns>
 31    public bool TryParse(Node node, IEnumerable<Way> ways, [NotNullWhen(returnValue: true)] out OsmBarrier? barrier)
 237832    {
 237833        if (node.Id == null) throw new ArgumentException("Node with id null cannot be a barrier");
 34
 237835        barrier = null;
 36
 237837        if (!this.IsBarrier(node)) return false;
 38
 237839        barrier = OsmBarrier.Create(node, ways);
 40
 237841        return true;
 237842    }
 43}

Methods/Properties

IsBarrier(...)
TryParse(...)