public void AddWalkOfInterestInfo(WalkOfInterestInfo walkOfInterestInfo) { _walkOfInterests.Add(walkOfInterestInfo.Id, walkOfInterestInfo); // Add object relations to facilitate easier and faster lookup and traversal walkOfInterestInfo.RouteElements = new List <Core.GraphSupport.Model.GraphElement>(); bool isNode = true; foreach (var routeElementId in walkOfInterestInfo.RouteElementIds) { if (isNode) { var node = _routeNodeInfos[routeElementId]; node.AddWalkOfInterest(walkOfInterestInfo); walkOfInterestInfo.RouteElements.Add(node); } else { var segment = _routeSegmentInfos[routeElementId]; segment.AddWalkOfInterest(walkOfInterestInfo); walkOfInterestInfo.RouteElements.Add(segment); } if (isNode) { isNode = false; } else { isNode = true; } } }
private List <Guid> GetPassThroughNodes(ConduitSegmentInfo conduitSegment, WalkOfInterestInfo conduitWalkOfInterest) { List <Guid> result = new List <Guid>(); // Get pass through node candidates (the ones that the segment don't start or end at) HashSet <Guid> passThroughNodeCandidatess = new HashSet <Guid>(); foreach (var nodeId in conduitWalkOfInterest.AllNodeIds) { if (!(conduitSegment.FromRouteNodeId == nodeId || conduitSegment.ToRouteNodeId == nodeId)) { passThroughNodeCandidatess.Add(nodeId); } } var segmentWalkNodes = conduitWalkOfInterest.SubWalk2(conduitSegment.FromRouteNodeId, conduitSegment.ToRouteNodeId).AllNodeIds; foreach (var segmentWalkNode in segmentWalkNodes) { if (passThroughNodeCandidatess.Contains(segmentWalkNode)) { result.Add(segmentWalkNode); } } return(result); }
private List <Guid> GetPassThroughRouteSegments(FiberSegmentInfo fiberSegment, WalkOfInterestInfo conduitWalkOfInterest) { List <Guid> result = new List <Guid>(); // Get pass through segment candidates (the ones that the segment don't start or end at) HashSet <Guid> passThroughSegmentCandidatess = new HashSet <Guid>(); foreach (var segmentId in conduitWalkOfInterest.AllSegmentIds) { passThroughSegmentCandidatess.Add(segmentId); } var segmentWalkSegments = conduitWalkOfInterest.SubWalk2(fiberSegment.FromRouteNodeId, fiberSegment.ToRouteNodeId).AllSegmentIds; foreach (var segmentWalk in segmentWalkSegments) { if (passThroughSegmentCandidatess.Contains(segmentWalk)) { result.Add(segmentWalk); } } return(result); }
public static void CutConduit(ConduitInfo conduitInfo, WalkOfInterestInfo walkOfInterest, RouteNodeInfo nodeWhereToCut) { ConduitSegmentInfo newSegment = null; List <ISegment> newSegmentList = new List <ISegment>(); int newSequenceNumber = 1; var fromNodeId = conduitInfo.Segments[0].FromRouteNodeId; foreach (var existingSegment in conduitInfo.Segments) { List <Guid> segmentWalk = walkOfInterest.SubWalk(existingSegment.FromRouteNodeId, existingSegment.ToRouteNodeId); newSegmentList.Add(existingSegment); existingSegment.SequenceNumber = newSequenceNumber; existingSegment.FromRouteNodeId = fromNodeId; // If the segment is cut by point of interest, divide it if (segmentWalk.Contains(nodeWhereToCut.Id)) { // Create the segment newSequenceNumber++; if (conduitInfo.Kind != ConduitKindEnum.MultiConduit) { newSegment = new SingleConduitSegmentInfo(); } else { newSegment = new MultiConduitSegmentInfo(); } newSegment.Id = Guid.NewGuid(); newSegment.ConduitId = ((ConduitSegmentInfo)existingSegment).ConduitId; newSegment.SequenceNumber = newSequenceNumber; newSegment.FromRouteNodeId = nodeWhereToCut.Id; newSegment.ToRouteNodeId = existingSegment.ToRouteNodeId; // we need copy to side info newSegment.ToNodeId = existingSegment.ToNodeId; // we need copy to side info newSegment.ToNode = existingSegment.ToNode; // we need copy to side info // Update the existing segment existingSegment.ToRouteNodeId = nodeWhereToCut.Id; existingSegment.ToNodeId = Guid.Empty; // cannot possible have to junction anymore if it had so (transfered to new segment) existingSegment.ToNode = null; // cannot possible have to junction anymore if it had so (transfered to new segment) // Set from node on next segment to from node on inserted segment fromNodeId = newSegment.ToRouteNodeId; newSegmentList.Add(newSegment); } else { // set from node to this one to node fromNodeId = existingSegment.ToRouteNodeId; } newSequenceNumber++; } conduitInfo.Segments = newSegmentList; // Needed to wake up Marten conduitInfo.Name = conduitInfo.Name; }