Exemple #1
0
        /// <summary>
        /// Initializes object using GTFS data feed.
        /// </summary>
        /// <param name="stops">Stops.</param>
        public GtfsFootpaths(Stops stops)
        {
            FootpathsExtensions.RecomputeAverageLatitudeAndLongitudeLength(stops);

            foreach (var A in stops)
            {
                foreach (var B in stops)
                {
                    int walkingTime = A.Value.GetWalkingTime(B.Value);
                    if (walkingTime < GlobalData.MaximalDurationOfTransfer && walkingTime > 0) // We will consider only the footpaths with walking time lower than 10 mins.
                    {
                        // Lets check if it is a transfer from surface to underground transport. If so, triple the walking time.

                        if (A.Value.ThroughgoingRoutes.Count != 0 && B.Value.ThroughgoingRoutes.Count != 0 && (
                                (A.Value.ThroughgoingRoutes[0].Type == RoutesInfo.RouteInfo.RouteType.Subway && B.Value.ThroughgoingRoutes[0].Type != RoutesInfo.RouteInfo.RouteType.Subway) ||
                                (A.Value.ThroughgoingRoutes[0].Type != RoutesInfo.RouteInfo.RouteType.Subway && B.Value.ThroughgoingRoutes[0].Type == RoutesInfo.RouteInfo.RouteType.Subway)))
                        {
                            if (GlobalData.CoefficientUndergroundToSurfaceTransfer * walkingTime < GlobalData.MaximalDurationOfTransfer)
                            {
                                list.Add(new Footpath((int)GlobalData.CoefficientUndergroundToSurfaceTransfer * walkingTime, A.Value, B.Value));
                            }
                        }

                        else if (A.Value.ThroughgoingRoutes.Count != 0 && B.Value.ThroughgoingRoutes.Count != 0 &&
                                 A.Value.ThroughgoingRoutes[0].Type == RoutesInfo.RouteInfo.RouteType.Subway && B.Value.ThroughgoingRoutes[0].Type == RoutesInfo.RouteInfo.RouteType.Subway)
                        {
                            // Transfer from subway to subway.

                            if (A.Value.ThroughgoingRoutes[0].ID == B.Value.ThroughgoingRoutes[0].ID)
                            {
                                // Transfer to same line usually take less time, multiply it by 0.5 by default. This is because distance is measured from the beginning of the platfrom.

                                list.Add(new Footpath((int)(GlobalData.CoefficientUndergroundTransfersWithinSameLine * walkingTime), A.Value, B.Value));
                            }

                            else
                            {
                                // Transfer between two lines usually take more time, multiply it by 2 by default.

                                list.Add(new Footpath((int)(GlobalData.CoefficientUndergroundTransfersWithinDifferentLines * walkingTime), A.Value, B.Value));
                            }
                        }

                        else
                        {
                            list.Add(new Footpath(walkingTime, A.Value, B.Value));
                        }
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Merges two collections into one.
        /// </summary>
        /// <param name="other">The other collection that should be merged.</param>
        public void MergeCollections(Footpaths other, Stops stopsA, Stops stopsB)
        {
            FootpathsExtensions.RecomputeAverageLatitudeAndLongitudeLength(stopsA, stopsB);

            foreach (var footpath in other)
            {
                list.Add(footpath);
            }

            other = null;

            foreach (var A in stopsA)
            {
                foreach (var B in stopsB)
                {
                    int walkingTime = A.Value.GetWalkingTime(B.Value);
                    if (walkingTime < GlobalData.MaximalDurationOfTransfer * 1.5 && walkingTime > 0)                     // While moving to another data feed, will consider only the footpaths with walking time lower than 15 mins by default.
                    {
                        list.Add(new Footpath(walkingTime, A.Value, B.Value));
                    }
                }
            }
        }