Exemplo n.º 1
0
        public StopConnection Create(
            RouteStop routeStop,
            Departure departure,
            StopVertex currentVertex,
            RouteStop nextRouteStop,
            StopVertex nextVertex,
            DateTime connectionStartDay,
            bool betweenTwoDays)
        {
            var endDay = connectionStartDay;

            if (betweenTwoDays)
            {
                endDay = endDay.AddDays(1);
            }
            return(new StopConnection()
            {
                Line = routeStop.Line,
                StartDateTime = connectionStartDay + departure.DepartureTime,
                SourceStop = currentVertex,
                EndDateTime = endDay + nextRouteStop
                              .Departures
                              .Where(p => p.RunIndex == departure.RunIndex)
                              .First()
                              .DepartureTime,
                DestinationStop = nextVertex,
            });
        }
Exemplo n.º 2
0
 public StopVertex MarkVertexAsVisited(StopVertex stopVertex)
 {
     stopVertex.IsVisited = true;
     foreach (var similarStopVertex in stopVertex.SimilarStopVertices)
     {
         similarStopVertex.IsVisited = true;
     }
     return(stopVertex);
 }
Exemplo n.º 3
0
        public IEnumerable <StopConnection> GetConnectionsFromSimilarVertices(StopVertex stopVertex, IEnumerable <StopVertex> similarStopVertices)
        {
            var allStopConnections = new List <StopConnection>();

            allStopConnections.AddRange(stopVertex.StopConnections);
            foreach (var similarVertex in stopVertex.SimilarStopVertices)
            {
                allStopConnections.AddRange(similarVertex.StopConnections);
            }
            return(allStopConnections);
        }
        private bool ShouldSearchingContinue(SearchInput search, StopVertex currentVertex)
        {
            bool isCurrentVertexDestinationStop = currentVertex != null &&
                                                  currentVertex.Stop.Id == search.DestinationStop.Id;

            if (isCurrentVertexDestinationStop == true)
            {
                return(false);
            }
            foreach (var similarVertex in currentVertex.SimilarStopVertices)
            {
                if (similarVertex.Stop.Id == search.DestinationStop.Id)
                {
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 5
0
        public IEnumerable <StopConnection> SetTransferConnectionsToSimilarVertices(
            IEnumerable <StopConnection> vertexFastestConnections,
            StopVertex stopVertex,
            IEnumerable <StopVertex> similarStopVertices)
        {
            var connectionToStopVertex = vertexFastestConnections
                                         .FirstOrNull(p => p.DestinationStop.Stop.Id == stopVertex.Stop.Id);

            foreach (var similarVertex in similarStopVertices)
            {
                var similarVertexFastestConnection = vertexFastestConnections
                                                     .FirstOrNull(p => p.DestinationStop.Stop.Id == similarVertex.Stop.Id);
                similarVertexFastestConnection.SourceStop    = stopVertex;
                similarVertexFastestConnection.StartDateTime = connectionToStopVertex.EndDateTime;
                similarVertexFastestConnection.EndDateTime   = connectionToStopVertex.EndDateTime;
                similarVertexFastestConnection.Line          = null;
                similarVertexFastestConnection.IsTransfer    = true;
            }
            return(vertexFastestConnections);
        }