< Summary

Class:Itinero.Routing.IHasSourceExtensions
Assembly:Itinero
File(s):/home/runner/work/routing2/routing2/src/Itinero/Routing/IHasSourceExtensions.cs
Covered lines:7
Uncovered lines:27
Coverable lines:34
Total lines:96
Line coverage:20.5% (7 of 34)
Covered branches:0
Total branches:0
Tag:230_15134869466

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
To(...)100%1100%
To(...)100%10%
To(...)100%10%
To(...)100%10%
To(...)100%10%
To(...)100%10%

File(s)

/home/runner/work/routing2/routing2/src/Itinero/Routing/IHasSourceExtensions.cs

#LineLine coverage
 1using System.Collections.Generic;
 2using Itinero.Geo.Directions;
 3using Itinero.Snapping;
 4
 5namespace Itinero.Routing;
 6
 7/// <summary>
 8/// Has source extensions.
 9/// </summary>
 10public static class IHasSourceExtensions
 11{
 12    /// <summary>
 13    /// Configures the router to route to the given point.
 14    /// </summary>
 15    /// <param name="hasSource">The hasSource.</param>
 16    /// <param name="target">The target.</param>
 17    /// <returns>A configured router.</returns>
 18    public static IRouterOneToOne To(this IHasSource hasSource, SnapPoint target)
 719    {
 720        return new Router(hasSource.Network, hasSource.Settings)
 721        {
 722            Source = hasSource.Source,
 723            Target = (target, null)
 724        };
 725    }
 26
 27    /// <summary>
 28    /// Configures the router to route to the given point.
 29    /// </summary>
 30    /// <param name="hasSource">The hasSource.</param>
 31    /// <param name="target">The target.</param>
 32    /// <returns>A configured router.</returns>
 33    public static IRouterOneToOne To(this IHasSource hasSource,
 34        (SnapPoint snapPoint, DirectionEnum? direction) target)
 035    {
 036        return new Router(hasSource.Network, hasSource.Settings)
 037        {
 038            Source = hasSource.Source,
 039            Target = target.ToDirected(hasSource.Network)
 040        };
 041    }
 42
 43    /// <summary>
 44    /// Configures the router to route to the given point.
 45    /// </summary>
 46    /// <param name="hasSource">The hasSource.</param>
 47    /// <param name="target">The target.</param>
 48    /// <returns>A configured router.</returns>
 49    public static IRouterOneToOne To(this IHasSource hasSource, (SnapPoint snapPoint, bool? direction) target)
 050    {
 051        return new Router(hasSource.Network, hasSource.Settings)
 052        {
 053            Source = hasSource.Source,
 054            Target = target
 055        };
 056    }
 57
 58    /// <summary>
 59    /// Configures the router to route to the given points.
 60    /// </summary>
 61    /// <param name="hasSource">The hasSource.</param>
 62    /// <param name="targets">The targets.</param>
 63    /// <returns>A configured router.</returns>
 64    public static IRouterOneToMany To(this IHasSource hasSource, IReadOnlyList<SnapPoint> targets)
 065    {
 066        return hasSource.To(targets.ToDirected());
 067    }
 68
 69    /// <summary>
 70    /// Configures the router to route from the given point.
 71    /// </summary>
 72    /// <param name="hasSource">The hasSource.</param>
 73    /// <param name="directedSnapPoints">The points to route from.</param>
 74    /// <returns>A configured router.</returns>
 75    public static IRouterOneToMany To(this IHasSource hasSource,
 76        IReadOnlyList<(SnapPoint snapPoint, DirectionEnum? direction)> directedSnapPoints)
 077    {
 078        return hasSource.To(directedSnapPoints.ToDirected(hasSource.Network));
 079    }
 80
 81    /// <summary>
 82    /// Configures the router to route to the given points.
 83    /// </summary>
 84    /// <param name="hasSource">The hasSource.</param>
 85    /// <param name="targets">The targets.</param>
 86    /// <returns>A configured router.</returns>
 87    public static IRouterOneToMany To(this IHasSource hasSource,
 88        IReadOnlyList<(SnapPoint snapPoint, bool? direction)> targets)
 089    {
 090        return new Router(hasSource.Network, hasSource.Settings)
 091        {
 092            Source = hasSource.Source,
 093            Targets = targets
 094        };
 095    }
 96}