< Summary

Class:Itinero.IO.Osm.Restrictions.OsmTurnRestriction
Assembly:Itinero.IO.Osm
File(s):/home/runner/work/routing2/routing2/src/Itinero.IO.Osm/Restrictions/Turns/OsmTurnRestriction.cs
Covered lines:30
Uncovered lines:0
Coverable lines:30
Total lines:91
Line coverage:100% (30 of 30)
Covered branches:4
Total branches:4
Branch coverage:100% (4 of 4)
Tag:224_14471318300

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
Create(...)100%2100%
Create(...)100%2100%
get_IsProbibitory()100%1100%
get_Attributes()100%1100%
get_From()100%1100%
get_Via()100%1100%
get_ViaNodeId()100%1100%
get_To()100%1100%

File(s)

/home/runner/work/routing2/routing2/src/Itinero.IO.Osm/Restrictions/Turns/OsmTurnRestriction.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using OsmSharp;
 4
 5namespace Itinero.IO.Osm.Restrictions;
 6
 7/// <summary>
 8/// The original OSM turn restriction.
 9/// </summary>
 10public class OsmTurnRestriction
 11{
 12    /// <summary>
 13    /// Creates a restriction with a via-node.
 14    /// </summary>
 15    /// <param name="froms">One or more from ways.</param>
 16    /// <param name="viaNodeId">The via node id.</param>
 17    /// <param name="tos">One or more to ways.</param>
 18    /// <param name="isProhibitory">The prohibitory flag.</param>
 19    /// <param name="attributes">The attributes.</param>
 20    /// <returns>An OSM turn restriction.</returns>
 21    public static OsmTurnRestriction Create(IEnumerable<Way> froms, long viaNodeId, IEnumerable<Way> tos, bool isProhibi
 22        IEnumerable<(string key, string value)>? attributes = null)
 523    {
 524        attributes ??= ArraySegment<(string key, string value)>.Empty;
 25
 526        return new OsmTurnRestriction()
 527        {
 528            IsProbibitory = isProhibitory,
 529            From = froms,
 530            ViaNodeId = viaNodeId,
 531            Via = ArraySegment<Way>.Empty,
 532            To = tos,
 533            Attributes = attributes
 534        };
 535    }
 36
 37    /// <summary>
 38    /// Creates a restriction with a via-node.
 39    /// </summary>
 40    /// <param name="froms">One or more from ways.</param>
 41    /// <param name="vias">One or more via ways.</param>
 42    /// <param name="tos">One or more to ways.</param>
 43    /// <param name="isProhibitory">The prohibitory flag.</param>
 44    /// <param name="attributes">The attributes.</param>
 45    /// <returns>An OSM turn restriction.</returns>
 46    public static OsmTurnRestriction Create(IEnumerable<Way> froms, IEnumerable<Way> vias, IEnumerable<Way> tos, bool is
 47        IEnumerable<(string key, string value)>? attributes = null)
 548    {
 549        attributes ??= ArraySegment<(string key, string value)>.Empty;
 50
 551        return new OsmTurnRestriction()
 552        {
 553            IsProbibitory = isProhibitory,
 554            From = froms,
 555            ViaNodeId = null,
 556            Via = vias,
 557            To = tos,
 558            Attributes = attributes
 559        };
 560    }
 61
 62    /// <summary>
 63    /// A flag set to true when this restriction is prohibitory, false when mandatory.
 64    /// </summary>
 1365    public bool IsProbibitory { get; private set; }
 66
 67    /// <summary>
 68    /// The attributes associated with the turn.
 69    /// </summary>
 1170    public IEnumerable<(string key, string value)> Attributes { get; private set; }
 71
 72    /// <summary>
 73    /// The from way(s).
 74    /// </summary>
 1775    public IEnumerable<Way> From { get; private set; }
 76
 77    /// <summary>
 78    /// The via way(s), if any.
 79    /// </summary>
 1680    public IEnumerable<Way> Via { get; private set; }
 81
 82    /// <summary>
 83    /// The via node id, if any.
 84    /// </summary>
 2385    public long? ViaNodeId { get; private set; }
 86
 87    /// <summary>
 88    /// The to way(s).
 89    /// </summary>
 1590    public IEnumerable<Way> To { get; private set; }
 91}