/// <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 Route Build(RouterDb db, Profile profile, RouterPoint source, RouterPoint target, List <uint> path) { return(CompleteRouteBuilder.Build(db, profile, source, target, path, CancellationToken.None)); }