/// <summary> /// Calculates all routes between all sources and all targets. /// </summary> public static Result <Route[][]> TryCalculate(this RouterBase router, Profile profile, RouterPoint[] sources, RouterPoint[] targets) { var invalidSources = new HashSet <int>(); var invalidTargets = new HashSet <int>(); var result = router.TryCalculate(profile, sources, targets, invalidSources, invalidTargets).Value; if (invalidSources.Count > 0) { return(new Result <Route[][]>("Some sources could not be routed from. Most likely there are islands in the loaded network.", (s) => { throw new Exceptions.RouteNotFoundException(s); })); } if (invalidTargets.Count > 0) { return(new Result <Route[][]>("Some targets could not be routed to. Most likely there are islands in the loaded network.", (s) => { throw new Exceptions.RouteNotFoundException(s); })); } var routes = new Route[result.Length][]; for (var i = 0; i < result.Length; i++) { routes[i] = new Route[result[i].Length]; for (var j = 0; j < result[i].Length; j++) { routes[i][j] = result[i][j]; } } return(new Result <Route[][]>(routes)); }
/// <summary> /// Calculates a route along the given locations. /// </summary> public static Result <Route> TryCalculate(this RouterBase router, IProfileInstance profile, RouterPoint[] locations) { if (locations.Length < 2) { throw new ArgumentOutOfRangeException("Cannot calculate a routing along less than two locations."); } var route = router.TryCalculate(profile, locations[0], locations[1]); if (route.IsError) { return(route); } for (var i = 2; i < locations.Length; i++) { var nextRoute = router.TryCalculate(profile, locations[i - 1], locations[i]); if (nextRoute.IsError) { return(nextRoute); } route = new Result <Route>(route.Value.Concatenate(nextRoute.Value)); } return(route); }
/// <summary> /// Calculates a route along the given locations. /// </summary> public static Result <Route> TryCalculate(this RouterBase router, Profile profile, Coordinate[] locations) { if (locations.Length < 2) { throw new ArgumentOutOfRangeException("Cannot calculate a routing along less than two locations."); } var resolved = router.TryResolve(profile, locations); var route = router.TryCalculate(profile, resolved[0].Value, resolved[1].Value); if (route.IsError) { return(route); } for (var i = 2; i < resolved.Length; i++) { var nextRoute = router.TryCalculate(profile, resolved[i - 1].Value, resolved[i].Value); if (nextRoute.IsError) { return(nextRoute); } route = new Result <Route>(route.Value.Concatenate(nextRoute.Value)); } return(route); }
/// <summary> /// Calculates all routes between all sources and all targets. /// </summary> public static Result <Route[]> TryCalculate(this RouterBase router, IProfileInstance profile, RouterPoint source, RouterPoint[] targets) { var result = router.TryCalculate(profile, new RouterPoint[] { source }, targets); if (result.IsError) { return(result.ConvertError <Route[]>()); } var routes = new Route[result.Value.Length]; for (var j = 0; j < result.Value.Length; j++) { routes[j] = result.Value[0][j]; } return(new Result <Route[]>(routes)); }
/// <summary> /// Calculates a route between the two locations. /// </summary> public static Result <Route> TryCalculate(this RouterBase router, IProfileInstance profile, float sourceLatitude, float sourceLongitude, float targetLatitude, float targetLongitude) { var profiles = new IProfileInstance[] { profile }; var sourcePoint = router.TryResolve(profiles, sourceLatitude, sourceLongitude); var targetPoint = router.TryResolve(profiles, targetLatitude, targetLongitude); if (sourcePoint.IsError) { return(sourcePoint.ConvertError <Route>()); } if (targetPoint.IsError) { return(targetPoint.ConvertError <Route>()); } return(router.TryCalculate(profile, sourcePoint.Value, targetPoint.Value)); }
/// <summary> /// Calculates a route between the two locations. /// </summary> public static Result <Route> TryCalculate(this RouterBase router, IProfileInstance profile, Coordinate source, Coordinate target) { return(router.TryCalculate(profile, source.Latitude, source.Longitude, target.Latitude, target.Longitude)); }
/// <summary> /// Calculates a route along the given locations. /// </summary> public static Route Calculate(this RouterBase router, IProfileInstance profile, Coordinate[] locations) { return(router.TryCalculate(profile, locations).Value); }
/// <summary> /// Calculates a route between the two locations. /// </summary> public static Route Calculate(this RouterBase router, IProfileInstance profile, Coordinate source, Coordinate target) { return(router.TryCalculate(profile, source, target).Value); }
/// <summary> /// Calculates all routes between all sources and all targets. /// </summary> public static Route[][] Calculate(this RouterBase router, IProfileInstance profile, RouterPoint[] sources, RouterPoint[] targets) { return(router.TryCalculate(profile, sources, targets).Value); }
/// <summary> /// Calculates a route between the two locations. /// </summary> public static Route Calculate(this RouterBase router, IProfileInstance profile, float sourceLatitude, float sourceLongitude, float targetLatitude, float targetLongitude) { return(router.TryCalculate(profile, sourceLatitude, sourceLongitude, targetLatitude, targetLongitude).Value); }
/// <summary> /// Calculates all routes between all sources and all targets. /// </summary> public static Route[][] Calculate(this RouterBase router, Profile profile, RouterPoint[] sources, RouterPoint[] targets, ISet <int> invalidSources, ISet <int> invalidTargets) { return(router.TryCalculate(profile, sources, targets, invalidSources, invalidTargets).Value); }
/// <summary> /// Calculates all routes between all sources and all targets. /// </summary> public static Route[] Calculate(this RouterBase router, Profile profile, RouterPoint source, RouterPoint[] targets) { return(router.TryCalculate(profile, source, targets).Value); }
/// <summary> /// Calculates a route along the given locations. /// </summary> public static Route Calculate(this RouterBase router, Profile profile, RouterPoint[] locations) { return(router.TryCalculate(profile, locations).Value); }