/// <summary> /// Builds a route. /// </summary> public static Result <Route> TryBuild <T>(RouterDb db, Profile profile, RouterPoint source, RouterPoint target, EdgePath <T> path) { var pathList = new List <uint>(); path.AddToListAsVertices(pathList); return(CompleteRouteBuilder.TryBuild(db, profile, source, target, pathList)); }
/// <summary> /// Add shortcut if the current edge is one. /// </summary> private bool AddShorcut(RoutingEdge edge) { // when both are just regular vertices, this could be a shortcut. var edgeProfile = _routerDb.EdgeProfiles.Get(edge.Data.Profile); var shortcutName = string.Empty; if (edgeProfile.IsShortcut(out shortcutName)) { // ok profile is a shortcut, get the actual path, expand and build route. ShortcutsDb shortcutsDb; if (_routerDb.TryGetShortcuts(shortcutName, out shortcutsDb)) { var shortcutProfile = shortcutsDb.Profile; IAttributeCollection shortcutMeta; var shortcut = shortcutsDb.Get(edge.From, edge.To, out shortcutMeta); if (shortcut != null && shortcut.Length >= 2) { var route = CompleteRouteBuilder.Build(_routerDb, shortcutProfile, _routerDb.CreateRouterPointForVertex(shortcut[0], shortcutProfile, _profile), _routerDb.CreateRouterPointForVertex(shortcut[shortcut.Length - 1], shortcutProfile, _profile), new List <uint>(shortcut)); if (shortcutMeta == null) { shortcutMeta = new AttributeCollection(); } shortcutMeta.AddOrReplace(ShortcutExtensions.SHORTCUT_KEY, shortcutName); this.AppendRoute(route, shortcutMeta); return(true); } } } return(false); }
/// <summary> /// Builds a route. /// </summary> public static Result <Route> TryBuild(RouterDb db, Profile profile, RouterPoint source, RouterPoint target, List <uint> path) { var routeBuilder = new CompleteRouteBuilder(db, profile, source, target, path); routeBuilder.Run(); if (!routeBuilder.HasSucceeded) { return(new Result <Route>( string.Format("Failed to build route: {0}", routeBuilder.ErrorMessage))); } return(new Result <Route>(routeBuilder.Route)); }
/// <summary> /// Builds a route. /// </summary> public static Route Build(RouterDb db, Profile profile, RouterPoint source, RouterPoint target, List <uint> path) { return(CompleteRouteBuilder.TryBuild(db, profile, source, target, path).Value); }
/// <summary> /// Builds a route. /// </summary> public static Result <Route> TryBuild(RouterDb db, Profile profile, RouterPoint source, RouterPoint target, List <uint> path) { return(CompleteRouteBuilder.TryBuild(db, profile, source, target, path, CancellationToken.None)); }
/// <summary> /// Builds a route. /// </summary> public static Route Build(RouterDb db, Profile profile, RouterPoint source, RouterPoint target, EdgePath <float> path, CancellationToken cancellationToken) { return(CompleteRouteBuilder.TryBuild(db, profile, source, target, path, cancellationToken).Value); }
/// <summary> /// Builds a route. /// </summary> public static Route Build(RouterDb db, Profile profile, RouterPoint source, RouterPoint target, EdgePath <float> path) { return(CompleteRouteBuilder.Build(db, profile, source, target, path, CancellationToken.None)); }