public void RouteNode_ShouldSetInitialValuesOnSettingProperties_OnConstruction() { var applicationInfo = "Info"; var applicationName = "GDB_INTEGRATOR"; var coord = new byte[] { 1, 2, 3, 2, 2 }; var username = "******"; var mrid = Guid.NewGuid(); var workTaskMrId = Guid.NewGuid(); var markAsDeleted = false; var routeNode = new RouteNode { ApplicationInfo = applicationInfo, ApplicationName = applicationName, Coord = coord, Username = username, Mrid = mrid, WorkTaskMrid = workTaskMrId, MarkAsDeleted = markAsDeleted }; using (new AssertionScope()) { routeNode.ApplicationInfo.Should().Be(applicationInfo); routeNode.ApplicationName.Should().Be(applicationName); routeNode.Coord.Should().BeEquivalentTo(coord); routeNode.Username.Should().Be(username); routeNode.Mrid.Should().Be(mrid); routeNode.WorkTaskMrid.Should().Be(workTaskMrId); routeNode.MarkAsDeleted.Should().Be(markAsDeleted); } }
public void FirstTestName() { var route = new RouteNode<Uri>(new StubRoute<Uri>()); var joinNode = new JoinNode<Uri>(_id++, new ConstantNode<Uri>()); joinNode.Add(route); var alpha = new AlphaNode<Uri>(_id++); alpha.Add(joinNode); var equal = new EqualNode<Uri>(() => _id++); equal.Add("version", alpha); var segment = new SegmentNode<Uri>(1); segment.Add(equal); var engine = new MagnumRoutingEngine<Uri>(x => x); engine.Match<RootNode<Uri>>().Single().Add(segment); bool called = false; var uri = new Uri("http://localhost/version"); engine.Route(uri, x => { called = true; }); called.ShouldBeTrue(); }
public async Task <List <INotification> > CreateDigitizedEvent(RouteNode routeNode) { if (routeNode is null) { throw new ArgumentNullException($"Parameter {nameof(routeNode)} cannot be null"); } if (IsCreatedByApplication(routeNode)) { return new List <INotification> { new DoNothing($"{nameof(RouteNode)} with id: '{routeNode.Mrid}' was created by {routeNode.ApplicationName} therefore do nothing.") } } ; await _geoDatabase.InsertRouteNodeShadowTable(routeNode); var intersectingRouteSegments = await _geoDatabase.GetIntersectingRouteSegments(routeNode); var intersectingRouteNodes = await _geoDatabase.GetIntersectingRouteNodes(routeNode); if (intersectingRouteNodes.Count > 0) { return(new List <INotification> { new InvalidRouteNodeOperation { RouteNode = routeNode, Message = "RouteNode intersects with another RouteNode" } }); } if (intersectingRouteSegments.Count == 0) { return new List <INotification> { new NewRouteNodeDigitized { RouteNode = routeNode } } } ; if (intersectingRouteSegments.Count == 1) { var notifications = new List <INotification>(); notifications.Add(new ExistingRouteSegmentSplitted { RouteNode = routeNode, InsertNode = false, CreateNodeAddedEvent = true }); return(notifications); } return(new List <INotification> { new InvalidRouteNodeOperation { RouteNode = routeNode, Message = "Route node did not fit any condition in command factory." } }); }
public async Task Create_ShouldReturnLifeCycleInfoUpdated_OnUpdatedLifeCycleInfo() { var geoDatabase = A.Fake <IGeoDatabase>(); var before = new RouteNode(); var after = new RouteNode { LifeCycleInfo = new LifecycleInfo { InstallationDate = DateTime.UtcNow, DeploymentState = DeploymentStateEnum.NotYetInstalled, RemovalDate = DateTime.UtcNow } }; var factory = new RouteNodeInfoCommandFactory(geoDatabase); var result = await factory.Create(before, after); var lifecycleInfoUpdated = (RouteNodeLifecycleInfoUpdated)result.First(); using (var scope = new AssertionScope()) { result.Count().Should().Be(1); lifecycleInfoUpdated.RouteNode.Should().BeEquivalentTo(after); } }
/// <summary> /// Добавление маршрута в начало текущего (с автоповоротом добавляемого маршрута) /// </summary> /// <param name="route">Добавляемый маршрут</param> public void AddFirst(IRoute route) { // Определение необходимости разворота маршрута bool reverse; if (route.To == From) { reverse = false; } else if (route.From == From) { reverse = true; } else { throw new ArgumentOutOfRangeException(nameof(route)); } var newNode = new RouteNode { Route = route, IsReversed = reverse, Next = First, Prior = null }; First.Prior = newNode; First = newNode; OnAddRoute(route); }
public RURouteNode(WFTEditor wftEditor, RouteNode selectedRouteNode, string operateType) { this.mainWindow = wftEditor; this.currentRouteNode = selectedRouteNode; this.operate = operateType; this.associateLines = wftEditor.viewPanel.shapeData.FindAssociatedLine(selectedRouteNode); }
private async Task <RouteNodeAdded> InsertRouteNode(RouteNode routeNode) { await _geoDatabase.InsertRouteNode(routeNode); routeNode.ApplicationName = _applicationSettings.ApplicationName; return(_routeNodeEventFactory.CreateAdded(routeNode)); }
public void Create_ShouldReturnEnvelope_OnBeingPassedSingleRouteNodesAndSingleRouteSegments() { var routeSegment = new RouteSegment { Coord = Convert.FromBase64String("AQIAACDoZAAABgAAALx5ruNWRSFBsc8ScAykV0HZ6xJ8lEUhQYU+y98RpFdBILoYecJFIUEVfnDVB6RXQZH1zbVhRSFBTFhvegSkV0G/QerRbkUhQYWC7LEKpFdB/e8AFj1FIUG8d8O9BqRXQQ=="), }; var routeNode = new RouteNode { Coord = Convert.FromBase64String("AQEAAAC8ea7jVkUhQbHPEnAMpFdB") }; var routeNodes = new List <RouteNode> { routeNode }; var routeSegments = new List <RouteSegment> { routeSegment }; var envelopeFactory = new EnvelopeFactory(); var result = envelopeFactory.Create(routeNodes, routeSegments); using (var scope = new AssertionScope()) { result.MinX.Should().Be(565918.5429759022); result.MaxX.Should().Be(565985.2365167774); result.MinY.Should().Be(6197265.913045954); result.MaxY.Should().Be(6197319.496780043); } }
private List<RouteInstance> completeDelivery(RouteNode goal) { List<RouteInstance> path = new List<RouteInstance>(); RouteNode nextNode = goal; RouteInstance nextInstance; //int totalCost = 0; //int totalPrice = 0; do { nextInstance = originPath[nextNode]; path.Add(nextInstance); nextNode = nextInstance.Route.Origin; /* totalCost += nextInstance.Route.CostPerCm3 * delivery.VolumeInCm3; totalCost += nextInstance.Route.CostPerGram * delivery.WeightInGrams; totalPrice += nextInstance.Route.PricePerCm3 * delivery.VolumeInCm3; totalPrice += nextInstance.Route.PricePerGram * delivery.WeightInGrams; */ } while (originPath[nextNode].Route != null); /* delivery.TotalCost = totalCost; delivery.TotalPrice = totalPrice; delivery.TimeOfDelivery = originPath[delivery.Destination].ArrivalTime; */ path.Reverse(0, path.Count); return path; }
private Route ExtractRoute(RouteFindingData FindRouteData, int startIndex, int endIndex) { var route = new Route(); var wptData = FindRouteData.WaypointData; var edge = wptData[endIndex].FromEdge; while (true) { int from = edge.FromNodeIndex; int to = edge.ToNodeIndex; var wptFrom = wptList[from]; if (to == endIndex) { var node = new RouteNode(wptList[to], null); route.Nodes.AddFirst(node); } var n = new RouteNode(wptFrom, edge.RecomputeDistance(wptList)); route.Nodes.AddFirst(n); if (from == startIndex) { return(route); } edge = wptData[from].FromEdge; } }
public void CreateRouteNodeInfoModified_ShouldReturnEvent_OnBeingPassedValidRouteNode() { var modifiedEventFactory = new ModifiedEventFactory(); var routeNodeId = Guid.NewGuid(); var routeNode = new RouteNode { Mrid = routeNodeId, ApplicationName = "GDB-integrator", RouteNodeInfo = new RouteNodeInfo { Function = RouteNodeFunctionEnum.FlexPoint, Kind = RouteNodeKindEnum.BuildingAccessPoint, }, ApplicationInfo = "Application info", }; var result = modifiedEventFactory.CreateRouteNodeInfoModified(routeNode); using (var scope = new AssertionScope()) { result.EventType.Should().Be("RouteNodeInfoModified"); result.EventId.Should().NotBeEmpty(); result.NodeId.Should().Be(routeNodeId); result.ApplicationName.Should().Be(routeNode.ApplicationName); result.ApplicationInfo.Should().Be(routeNode.ApplicationInfo); result.EventTimestamp.Should().NotBe(new DateTime()); result.RouteNodeInfo.Should().BeEquivalentTo(routeNode.RouteNodeInfo); } }
private void button2_Click(object sender, EventArgs e) { int Number = Convert.ToInt32(this.numberTrain.Text); Train entTrn = Train.Search(Number); string Time1Arr = timeArrInit.Text; string Time1Dep = timeDepInit.Text; string Time2Arr = timeArrTerm.Text; string Time2Dep = timeDepTerm.Text; Station Stn1 = Station.SearchByName(Convert.ToString(initialStation.Text)); Station Stn2 = Station.SearchByName(Convert.ToString(terminalStation.Text)); if (entTrn == null) { Train Trn = new Train(Number); RouteNode RN1 = new RouteNode(Stn1, Time1Arr, Time1Dep, Trn); RouteNode RN2 = new RouteNode(Stn2, Time2Arr, Time2Dep, Trn); Trn.AddRouteNode(RN1); Trn.AddRouteNode(RN2); } else { Station Stn = Station.SearchByName(Convert.ToString(wayStation.Text)); string timeArr = timeArrWayS.Text; string timeDep = timeDepWays.Text; RouteNode RN = new RouteNode(Stn, timeArr, timeDep, entTrn); entTrn.AddRouteNode(RN); } FormEditTrains_Activated(sender, e); //textBox1_TextChanged(sender, e); textBox1_TextChanged(sender, e); add.Enabled = ConditionForEdit(); }
public Result <List <IRouteNetworkElement> > GetRouteElements(RouteNetworkElementIdList routeNetworkElementIds, bool createSubstitudesForMissingRouteNetworkElements = false) { var routeNetworkElementFetched = new List <IRouteNetworkElement>(); foreach (var routeElementId in routeNetworkElementIds) { var routeNetworkElement = _routeNetworkState.GetRouteNetworkElement(routeElementId); if (routeNetworkElement == null) { if (createSubstitudesForMissingRouteNetworkElements) { routeNetworkElement = new RouteNode(routeElementId, "[559000,6210000]") { NamingInfo = new NamingInfo() { Name = "#NA" } }; } else { return(Result.Fail <List <IRouteNetworkElement> >($"Cannot find any route network element with id: {routeElementId}")); } } routeNetworkElementFetched.Add(routeNetworkElement as IRouteNetworkElement); } return(Result.Ok <List <IRouteNetworkElement> >(routeNetworkElementFetched)); }
public RouteNodeTool(RouteNode node, ScriptComponent parent, ScriptComponent undoRedoRecordObject, Func <RouteNode> getSelected, Action <RouteNode> setSelected, Predicate <RouteNode> hasNode, Func <float> radius, Func <RouteNode, Color> color) { Node = node; Parent = parent; AddChild(new FrameTool(node) { OnChangeDirtyTarget = Parent, TransformHandleActive = false, UndoRedoRecordObject = undoRedoRecordObject }); m_getSelected = getSelected; m_setSelected = setSelected; m_hasNode = hasNode; m_radius = radius ?? new Func <float>(() => { return(0.05f); }); m_color = color; Visual.Color = m_color(Node); Visual.MouseOverColor = new Color(0.1f, 0.96f, 0.15f, 1.0f); Visual.OnMouseClick += OnClick; }
public async Task <IActionResult> Edit(Guid id, [Bind("Id,RouteId,Name,OfficialCode,DestinationStationCode,OriginStationCode,DestinationStationName,OriginStationName,Km,DepartureTime,ArrivalTime,Standing")] RouteNode routeNode) { if (id != routeNode.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(routeNode); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RouteNodeExists(routeNode.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(routeNode)); }
/// <summary> /// Create a RouteNode. /// </summary> /// <param name="data">Parameters of the RouteNode to construct.</param> /// <param name="getEventInstance">Function to get an existing RouteEvent instance.</param> /// <param name="registerEventInstance">Function to register a RouteEvent instance.</param> /// <param name="createEvent">Function to create a RouteEvent.</param> /// <returns>Function to create a RouteNode.</returns> private static FoxLib.Tpp.RouteSet.RouteNode Create(RouteNode data, TryGetEventInstanceDelegate getEventInstance, RegisterEventInstanceDelegate registerEventInstance, CreateEventDelegate createEvent) { FoxLib.Tpp.RouteSet.RouteEvent edgeEvent; if (!getEventInstance(data.EdgeEvent, out edgeEvent)) { edgeEvent = createEvent(data.EdgeEvent); registerEventInstance(data.EdgeEvent, edgeEvent); } List <FoxLib.Tpp.RouteSet.RouteEvent> eventInstances = new List <FoxLib.Tpp.RouteSet.RouteEvent>(); foreach (var @event in data.Events) { FoxLib.Tpp.RouteSet.RouteEvent eventInstance; if (!getEventInstance(@event, out eventInstance)) { var newInstance = createEvent(@event); registerEventInstance(@event, newInstance); eventInstances.Add(newInstance); continue; } eventInstances.Add(eventInstance); } return(new FoxLib.Tpp.RouteSet.RouteNode( FoxUtils.UnityToFox(data.transform.position), edgeEvent, eventInstances.ToArray() )); }
private NearestRouteNodeTraceResult ShortestPath(RouteNode fromNode, Guid toNodeId, GraphHolder graphHolder) { // HH 10 if (fromNode.Id == Guid.Parse("d0e5ce6a-0d90-4355-a1ff-60db24e5b153")) { } var pathFinder = new PathFinder(); var graphFromNode = graphHolder.Nodes[fromNode.Id]; var graphToNode = graphHolder.Nodes[toNodeId]; var maxAgentSpeed = Velocity.FromKilometersPerHour(1); var path = pathFinder.FindPath(graphFromNode, graphToNode, maximumVelocity: maxAgentSpeed); List <Guid> segmentIds = new(); List <string> segmentGeometries = new(); double distance = 0; if (path != null) { foreach (var edge in path.Edges) { var segment = graphHolder.EdgeToSegment[edge]; segmentIds.Add(segment.Id); segmentGeometries.Add(segment.Coordinates); distance += graphHolder.EdgeLengths[segment]; } } return(new NearestRouteNodeTraceResult(fromNode.Id, fromNode?.NamingInfo?.Name, distance, segmentIds.ToArray(), segmentGeometries.ToArray())); }
private static IEnumerable <NodeCandidateHolder> GetAllNodeCandidates(RouteNode sourceRouteNode, HashSet <RouteNodeKindEnum> interestHash, IEnumerable <IGraphObject> traceResult) { var sourceRouteNodePoint = GetPoint(sourceRouteNode.Coordinates); List <NodeCandidateHolder> nodeCandidates = new(); foreach (var graphObj in traceResult) { if (graphObj is RouteNode) { var routeNode = graphObj as RouteNode; var pnt = GetPoint(routeNode.Coordinates); nodeCandidates.Add( new NodeCandidateHolder() { Node = routeNode, BirdDistanceToSource = pnt.Distance(sourceRouteNodePoint), X = (float)pnt.X, Y = (float)pnt.Y } ); } } return(nodeCandidates); }
public MappingInfoModified CreateMappingInfoModified(RouteNode routeNode) { if (routeNode is null) { throw new ArgumentNullException($"{nameof(RouteNode)} cannot be passsed in as null."); } return(new MappingInfoModified( nameof(MappingInfoModified), Guid.NewGuid(), DateTime.UtcNow, routeNode.ApplicationName, routeNode.ApplicationInfo, routeNode.Mrid, ROUTE_NODE, new MappingInfo { HorizontalAccuracy = routeNode.MappingInfo?.HorizontalAccuracy, Method = routeNode.MappingInfo?.Method, SourceInfo = string.IsNullOrEmpty(routeNode.MappingInfo?.SourceInfo) ? null : routeNode.MappingInfo.SourceInfo, SurveyDate = routeNode.MappingInfo?.SurveyDate, VerticalAccuracy = String.IsNullOrEmpty(routeNode.MappingInfo?.VerticalAccuracy) ? null : routeNode.MappingInfo.VerticalAccuracy } )); }
private void OnItemRemoving(object sender, ItemRemovingEventArgs args) { var route = this.target as Route; RouteNode item = route.Nodes[args.ItemIndex]; DestroyImmediate(item.gameObject); }
private async Task <RouteNodeMarkedForDeletion> MarkDeleteRouteNode(RouteNode routeNode) { await _geoDatabase.MarkDeleteRouteNode(routeNode.Mrid); routeNode.ApplicationName = _applicationSettings.ApplicationName; return(_routeNodeEventFactory.CreateMarkedForDeletion(routeNode)); }
public static void ConstructRoute(List <int> route, RouteNode node) { if (route.Count == 0) { return; } else { int FirstValue = route[0]; bool Found = false; int i = 0; for (; i < node.Children.Count; i++) { if (node.Children[i].Value == FirstValue) { Found = true; break; } } if (Found) { ConstructRoute(route.Skip(1).ToList(), node.Children[i]); } else { RouteNode newNode = new RouteNode(); newNode.Value = FirstValue; node.Children.Add(newNode); ConstructRoute(route.Skip(1).ToList(), newNode); } } }
public void AddRouteNode(RouteNode routeNode) { if (routeNode != null) { this.routeNodes.Add(routeNode); } }
public void CreateNamingInfoModified_ShouldReturnEvent_OnBeingPassedValidRouteNode() { var modifiedEventFactory = new ModifiedEventFactory(); var nodeId = Guid.NewGuid(); var routeNode = new RouteNode { Mrid = nodeId, ApplicationName = "GDB-integrator", ApplicationInfo = "Application info", NamingInfo = new NamingInfo { Description = "My description", Name = "My name" } }; var result = modifiedEventFactory.CreateNamingInfoModified(routeNode); using (var scope = new AssertionScope()) { result.EventType.Should().Be("NamingInfoModified"); result.EventId.Should().NotBeEmpty(); result.AggregateId.Should().Be(routeNode.Mrid); result.AggregateType.Should().Be("RouteNode"); result.ApplicationName.Should().Be(routeNode.ApplicationName); result.ApplicationInfo.Should().Be(routeNode.ApplicationInfo); result.EventTimestamp.Should().NotBe(new DateTime()); result.NamingInfo.Should().BeEquivalentTo(routeNode.NamingInfo); } }
public void CreateMappingInfoModified_ShouldReturnEvent_OnBeingPassedValidRouteNode() { var modifiedEventFactory = new ModifiedEventFactory(); var nodeId = Guid.NewGuid(); var routeNode = new RouteNode { Mrid = nodeId, ApplicationName = "GDB-integrator", ApplicationInfo = "Application info", MappingInfo = new MappingInfo { HorizontalAccuracy = "10", Method = MappingMethodEnum.Drafting, SourceInfo = "Some source info", SurveyDate = DateTime.UtcNow, VerticalAccuracy = "Vertical accuracy" } }; var result = modifiedEventFactory.CreateMappingInfoModified(routeNode); using (var scope = new AssertionScope()) { result.EventType.Should().Be("MappingInfoModified"); result.EventId.Should().NotBeEmpty(); result.AggregateId.Should().Be(routeNode.Mrid); result.AggregateType.Should().Be("RouteNode"); result.ApplicationName.Should().Be(routeNode.ApplicationName); result.ApplicationInfo.Should().Be(routeNode.ApplicationInfo); result.EventTimestamp.Should().NotBe(new DateTime()); result.MappingInfo.Should().BeEquivalentTo(routeNode.MappingInfo); } }
private void AddAndShowAndFollowRoute() { string[] segments = new Uri(Directory.GetCurrentDirectory()).Segments; string folderPath = segments.SubArray(0, segments.Length - 2).ToFullString() + @"Bike\Mountain_Bike\OBJ"; string objectPath = folderPath.Replace("%20", " ").Replace("/", @"\").Remove(0, 1) + @"\Mountain_Bike.obj"; RouteNode[] routeArray = new RouteNode[] { new RouteNode(new int[] { -120, 0, -120 }, new int[] { -80, 0, -80 }), new RouteNode(new int[] { -50, 0, -80 }, new int[] { 0, 0, -50 }), new RouteNode(new int[] { 0, 0, 0 }, new int[] { 50, 0, 0 }), new RouteNode(new int[] { 80, 0, 50 }, new int[] { 100, 0, 50 }) }; Tuple <string, JObject> addroute = SendToTunnel(jsonPacketBuilder.BuildRouteAddPacket(routeArray).Item1); string routeId = addroute.Item2.SelectToken("data.data.data.uuid").ToString(); SendToTunnel(jsonPacketBuilder.BuildRouteShowPacket(true).Item1); Tuple <string, JObject> addBike = SendToTunnel(jsonPacketBuilder.BuildModelLoadPacket("bike", objectPath, 0, 0, 0, 0.1, true, false, "animationname").Item1); SendToTunnel(jsonPacketBuilder.BuildRouteFollowPacket(addroute.Item2.SelectToken("data.data.data.uuid").ToString(), addBike.Item2.SelectToken("data.data.data.uuid").ToString(), 2.0f, 1f, "XYZ", 1.0f).Item1); RoadAdd(routeId); Tuple <string, JObject> cameraNode = SendToTunnel(jsonPacketBuilder.BuildFindNodePacket("Camera").Item1); string cameraId = (cameraNode.Item2.SelectToken("data.data.data") as JArray)[0].SelectToken("uuid").ToString(); Tuple <string, JObject> updateCamera = SendToTunnel(jsonPacketBuilder.BuildUpdateNodePacket(cameraId, addBike.Item2.SelectToken("data.data.data.uuid").ToString(), 7, 0, 0, 0, 0, 0, 0).Item1); }
public void CreateLifecycleInfoModified_ShouldReturnEvent_OnBeingPassedValidRouteNode() { var modifiedEventFactory = new ModifiedEventFactory(); var nodeId = Guid.NewGuid(); var routeNode = new RouteNode { Mrid = nodeId, ApplicationName = "GDB-integrator", ApplicationInfo = "Application info", LifeCycleInfo = new LifecycleInfo { DeploymentState = DeploymentStateEnum.Installed, InstallationDate = DateTime.UtcNow, RemovalDate = DateTime.UtcNow.AddDays(1) }, }; var result = modifiedEventFactory.CreateLifeCycleInfoModified(routeNode); using (var scope = new AssertionScope()) { result.EventType.Should().Be("LifecycleInfoModified"); result.EventId.Should().NotBeEmpty(); result.AggregateId.Should().Be(routeNode.Mrid); result.AggregateType.Should().Be("RouteNode"); result.ApplicationName.Should().Be(routeNode.ApplicationName); result.ApplicationInfo.Should().Be(routeNode.ApplicationInfo); result.EventTimestamp.Should().NotBe(new DateTime()); result.LifecycleInfo.Should().BeEquivalentTo(routeNode.LifeCycleInfo); } }
public void CreateLifeCycleInfoModified_ShouldThrowArgumentNullException_OnBeingPassedNullRouteNode() { var modifiedEventFactory = new ModifiedEventFactory(); RouteNode routeNode = null; modifiedEventFactory.Invoking(x => x.CreateLifeCycleInfoModified(routeNode)).Should().Throw <ArgumentNullException>(); }
public void FirstTestName() { var route = new RouteNode <Uri>(new StubRoute <Uri>()); var joinNode = new JoinNode <Uri>(_id++, new ConstantNode <Uri>()); joinNode.Add(route); var alpha = new AlphaNode <Uri>(_id++); alpha.Add(joinNode); var equal = new EqualNode <Uri>(() => _id++); equal.Add("version", alpha); var segment = new SegmentNode <Uri>(1); segment.Add(equal); var engine = new MagnumRoutingEngine <Uri>(x => x); engine.Match <RootNode <Uri> >().Single().Add(segment); bool called = false; var uri = new Uri("http://localhost/version"); engine.Route(uri, x => { called = true; }); called.ShouldBeTrue(); }
public void AddRouteParameterSegmentEndsPrefix() { string prefix = this.router.AddRoute("/system/users/{id}/profile", this.handler); Assert.Equal("system/users/", prefix); RouteNode root = GetRouteGraphRoot(this.router); RouteNode node = root.Children.Single(); Assert.Equal("system", node.Segment); node = node.Children.Single(); Assert.Equal("users", node.Segment); ParameterRouteNode parameterNode = node.Children.Single() as ParameterRouteNode; Assert.Equal("{id}", parameterNode.Segment); Assert.Equal("id", parameterNode.ParameterName); node = parameterNode.Children.Single(); Assert.Equal("profile", node.Segment); HandlerRouteNode handlerNode = node.Children.Single() as HandlerRouteNode; Assert.Equal(this.handler, handlerNode.Handler); }
public void CreateNewRoute() { start[No] = new RouteNode(); start[No].position = startPN.transform.position; start[No].prev = null; cur = start[No]; curPN = startPN; }
public RURouteNode(WFTEditor wftEditor, RouteNode selectedRouteNode, Point moveBaseOriginal, Point moveBaseFinal) { this.mainWindow = wftEditor; this.currentRouteNode = selectedRouteNode; this.operate = "OP_Move"; this.moveBaseOriginal = moveBaseOriginal; this.moveBaseFinal = moveBaseFinal; }
public async Task UpdateNode() { var n = new RouteNode { name = "mihai" }; await _client.UpdateDocument(_typesenseSetting.NodeCollection, "8b1952f4-8948-435b-8892-3000a674ae7a", n); }
//indexed by the ordinal of the Common.PathType public Dictionary<PathType, List<RouteInstance>> findRoutes(RouteNode origin, RouteNode destination, int weight, int volume) { //get the DateTime to the nearest minute as the requested Date Time DateTime requestTime = DateTime.Now; var paths = new Dictionary<PathType, List<RouteInstance>> { {PathType.Express, findPath(requestTime, origin, destination, weight, volume, time, allRoutes)}, {PathType.Standard, findPath(requestTime, origin, destination, weight, volume, cost, allRoutes)}, {PathType.AirExpress, findPath(requestTime, origin, destination, weight, volume, time, airOnly)}, {PathType.AirStandard, findPath(requestTime, origin, destination, weight, volume, cost, airOnly)} }; return paths; }
public void AddRoutes(IEnumerable<string> paths) { foreach (string path in paths) { var route = new RouteNode<Uri>(new StubRoute<Uri>()); var joinNode = new JoinNode<Uri>(_id++, new ConstantNode<Uri>()); joinNode.Add(route); var alpha = new AlphaNode<Uri>(_id++); alpha.Add(joinNode); _equal.Add(path.Substring(1), alpha); } }
/// <summary> /// Добавляет узел маршрута к списку узлов маршрута станции. /// </summary> /// <param name="RouteNode"></param> public void AddRouteNode(RouteNode RouteNode) { this._routeNodes.Add(RouteNode); }
public virtual void SaveRouteNode(RouteNode routeNode) { routeNodes[routeNode.ID] = routeNode; }
/// <summary> /// ��������� ���� �������� � ���������� ����������. /// </summary> /// <param name="RouteNode"></param> public void AddRouteNode(RouteNode RouteNode) { this._routenodes.Add(RouteNode); RouteNodeComparer rnc = new RouteNodeComparer(); this._routenodes.Sort(rnc); }
public void RemoveRouteNode(RouteNode routeNode) { this._routeNodes.Remove(routeNode); }
//, Excluder excluder) private List<RouteInstance> findPath(DateTime requestTime, RouteNode origin, RouteNode goal, int weight, int volume, NodeEvaluator evaluator, RouteExcluder excluder) { Delivery delivery = new Delivery(); delivery.Origin = origin; delivery.Destination = goal; delivery.WeightInGrams = weight; delivery.VolumeInCm3 = volume; delivery.TimeOfRequest = requestTime; originPath = new Dictionary<RouteNode, RouteInstance>(); nodeCost = new Dictionary<RouteNode, double>(); closed = new HashSet<RouteNode>(); var rc = new RouteComparer(); fringe = new SortedList<RouteNode, double>(rc); fringe.Add(origin, 0); originPath.Add(origin, new OriginRouteInstance(requestTime)); //if the queue is empty return null (no path) while (fringe.Count > 0) { //take new node off the top of the stack //this is guaranteed to be the best way to the node RouteNode curNode = fringe.Keys[0]; if (closed.Contains(curNode)) continue; nodeCost.Add(curNode, fringe.Values[0]); closed.Add(curNode); fringe.RemoveAt(0); //if it's the goal node exit and return path if (curNode.Equals(goal)) return completeDelivery(curNode); //grab a list of all of the routes where the given node is the origin IEnumerable<Route> routes = routeService.GetAll(curNode); //take each route that hasn't been ommited and evaluate foreach (Route path in excluder.Omit(routes)) { RouteInstance nextInstance = evaluator.GetNextInstance(path); RouteNode nextNode = path.Destination; double totalCost = evaluator.GetValue(nextInstance, delivery); //if the node is not in the fringe //or the current value is lower than //the new cost then set the new parent if (!fringe.ContainsKey(nextNode)) { originPath.Add(nextNode, nextInstance); fringe.Add(nextNode, totalCost); } else if (fringe[nextNode] > totalCost) { originPath.Remove(nextNode); fringe.Remove(nextNode); originPath.Add(nextNode, nextInstance); fringe.Add(nextNode, totalCost); } } } return null; }
/// <summary> /// Добавляет данные о станциях в оперативную память и /// добавляет станции к маршруту поезда. /// </summary> /// <param name="NumberOfTrain">Номер поезда.</param> /// <param name="RouteNodes">Список узлов типа Station.</param> private static void LoadRouteNodes(Train Train, XmlNodeList RouteNodes) { foreach(XmlNode RouteNode in RouteNodes) { string name = RouteNode.ChildNodes[0].InnerText; string timeOfDeparture = RouteNode.ChildNodes[1].InnerText; string timeOfArrival = RouteNode.ChildNodes[2].InnerText; Station station = Station.SearchByName(name); RouteNode routenode = new RouteNode(station, timeOfDeparture, timeOfArrival, Train); //Train.AddRouteNode(routenode); } }