| | 1 | | using System.Collections.Generic; |
| | 2 | | using Itinero.Geo.Directions; |
| | 3 | | using Itinero.Snapping; |
| | 4 | |
|
| | 5 | | namespace Itinero.Routing; |
| | 6 | |
|
| | 7 | | /// <summary> |
| | 8 | | /// Has sources extensions. |
| | 9 | | /// </summary> |
| | 10 | | public static class IHasSourcesExtensions |
| | 11 | | { |
| | 12 | | /// <summary> |
| | 13 | | /// Configures the router to route to the given point. |
| | 14 | | /// </summary> |
| | 15 | | /// <param name="hasSources">The router with sources.</param> |
| | 16 | | /// <param name="target">The target.</param> |
| | 17 | | /// <returns>A configured router.</returns> |
| | 18 | | public static IRouterManyToOne To(this IHasSources hasSources, SnapPoint target) |
| 0 | 19 | | { |
| 0 | 20 | | return new Router(hasSources.Network, hasSources.Settings) |
| 0 | 21 | | { |
| 0 | 22 | | Sources = hasSources.Sources, |
| 0 | 23 | | Target = (target, null) |
| 0 | 24 | | }; |
| 0 | 25 | | } |
| | 26 | |
|
| | 27 | | /// <summary> |
| | 28 | | /// Configures the router to route to the given point. |
| | 29 | | /// </summary> |
| | 30 | | /// <param name="hasSources">The router with sources.</param> |
| | 31 | | /// <param name="target">The target.</param> |
| | 32 | | /// <returns>A configured router.</returns> |
| | 33 | | public static IRouterManyToOne To(this IHasSources hasSources, |
| | 34 | | (SnapPoint snapPoint, DirectionEnum? direction) target) |
| 0 | 35 | | { |
| 0 | 36 | | return new Router(hasSources.Network, hasSources.Settings) |
| 0 | 37 | | { |
| 0 | 38 | | Sources = hasSources.Sources, |
| 0 | 39 | | Target = target.ToDirected(hasSources.Network) |
| 0 | 40 | | }; |
| 0 | 41 | | } |
| | 42 | |
|
| | 43 | | /// <summary> |
| | 44 | | /// Configures the router to route to the given point. |
| | 45 | | /// </summary> |
| | 46 | | /// <param name="hasSources">The router with sources.</param> |
| | 47 | | /// <param name="target">The target.</param> |
| | 48 | | /// <returns>A configured router.</returns> |
| | 49 | | public static IRouterManyToOne To(this IHasSources hasSources, (SnapPoint snapPoint, bool? direction) target) |
| 0 | 50 | | { |
| 0 | 51 | | return new Router(hasSources.Network, hasSources.Settings) |
| 0 | 52 | | { |
| 0 | 53 | | Sources = hasSources.Sources, |
| 0 | 54 | | Target = target |
| 0 | 55 | | }; |
| 0 | 56 | | } |
| | 57 | |
|
| | 58 | | /// <summary> |
| | 59 | | /// Configures the router to route to the given point. |
| | 60 | | /// </summary> |
| | 61 | | /// <param name="hasSources">The router with sources.</param> |
| | 62 | | /// <param name="targets">The targets.</param> |
| | 63 | | /// <returns>A configured router.</returns> |
| | 64 | | public static IRouterManyToMany To(this IHasSources hasSources, IReadOnlyList<SnapPoint> targets) |
| 0 | 65 | | { |
| 0 | 66 | | return new Router(hasSources.Network, hasSources.Settings) |
| 0 | 67 | | { |
| 0 | 68 | | Sources = hasSources.Sources, |
| 0 | 69 | | Targets = targets.ToDirected() |
| 0 | 70 | | }; |
| 0 | 71 | | } |
| | 72 | |
|
| | 73 | | /// <summary> |
| | 74 | | /// Configures the router to route to the given point. |
| | 75 | | /// </summary> |
| | 76 | | /// <param name="hasSources">The router with sources.</param> |
| | 77 | | /// <param name="targets">The targets.</param> |
| | 78 | | /// <returns>A configured router.</returns> |
| | 79 | | public static IRouterManyToMany To(this IHasSources hasSources, |
| | 80 | | IReadOnlyList<(SnapPoint snapPoint, DirectionEnum? directed)> targets) |
| 0 | 81 | | { |
| 0 | 82 | | return new Router(hasSources.Network, hasSources.Settings) |
| 0 | 83 | | { |
| 0 | 84 | | Sources = hasSources.Sources, |
| 0 | 85 | | Targets = targets.ToDirected(hasSources.Network) |
| 0 | 86 | | }; |
| 0 | 87 | | } |
| | 88 | |
|
| | 89 | | /// <summary> |
| | 90 | | /// Configures the router to route to the given point. |
| | 91 | | /// </summary> |
| | 92 | | /// <param name="hasSources">The router with sources.</param> |
| | 93 | | /// <param name="targets">The targets.</param> |
| | 94 | | /// <returns>A configured router.</returns> |
| | 95 | | public static IRouterManyToMany To(this IHasSources hasSources, |
| | 96 | | IReadOnlyList<(SnapPoint snapPoint, bool? directed)> targets) |
| 0 | 97 | | { |
| 0 | 98 | | return new Router(hasSources.Network, hasSources.Settings) |
| 0 | 99 | | { |
| 0 | 100 | | Sources = hasSources.Sources, |
| 0 | 101 | | Targets = targets |
| 0 | 102 | | }; |
| 0 | 103 | | } |
| | 104 | | } |