| | 1 | | using System.Collections.Generic; |
| | 2 | | using Itinero.Geo.Directions; |
| | 3 | | using Itinero.Snapping; |
| | 4 | |
|
| | 5 | | namespace Itinero.Routing; |
| | 6 | |
|
| | 7 | | /// <summary> |
| | 8 | | /// Has source extensions. |
| | 9 | | /// </summary> |
| | 10 | | public 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) |
| 7 | 19 | | { |
| 7 | 20 | | return new Router(hasSource.Network, hasSource.Settings) |
| 7 | 21 | | { |
| 7 | 22 | | Source = hasSource.Source, |
| 7 | 23 | | Target = (target, null) |
| 7 | 24 | | }; |
| 7 | 25 | | } |
| | 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) |
| 0 | 35 | | { |
| 0 | 36 | | return new Router(hasSource.Network, hasSource.Settings) |
| 0 | 37 | | { |
| 0 | 38 | | Source = hasSource.Source, |
| 0 | 39 | | Target = target.ToDirected(hasSource.Network) |
| 0 | 40 | | }; |
| 0 | 41 | | } |
| | 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) |
| 0 | 50 | | { |
| 0 | 51 | | return new Router(hasSource.Network, hasSource.Settings) |
| 0 | 52 | | { |
| 0 | 53 | | Source = hasSource.Source, |
| 0 | 54 | | Target = target |
| 0 | 55 | | }; |
| 0 | 56 | | } |
| | 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) |
| 0 | 65 | | { |
| 0 | 66 | | return hasSource.To(targets.ToDirected()); |
| 0 | 67 | | } |
| | 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) |
| 0 | 77 | | { |
| 0 | 78 | | return hasSource.To(directedSnapPoints.ToDirected(hasSource.Network)); |
| 0 | 79 | | } |
| | 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) |
| 0 | 89 | | { |
| 0 | 90 | | return new Router(hasSource.Network, hasSource.Settings) |
| 0 | 91 | | { |
| 0 | 92 | | Source = hasSource.Source, |
| 0 | 93 | | Targets = targets |
| 0 | 94 | | }; |
| 0 | 95 | | } |
| | 96 | | } |