Esempio n. 1
0
        /// <summary>
        /// Creates data feed that is required for the application.
        /// </summary>
        /// <param name="path">Path to the folder that will be the feed saved to.</param>
        public void CreateDataFeed(string path)
        {
            if (Directory.Exists(path))
            {
                Directory.Delete(path, true);
            }
            Directory.CreateDirectory(path);

            Trips.Write(new StreamWriter(path + "/trips.tfd"));       // This MUST come first because of trip reindexation (based on sorting).
            Stations.Write(new StreamWriter(path + "/stations.tfd")); // This MUST come first because of stations reindexation (based on sorting).

            Calendar.Write(new StreamWriter(path + "/calendar.tfd"));
            CalendarDates.Write(new StreamWriter(path + "/calendar_dates.tfd"));
            RoutesInfo.Write(new StreamWriter(path + "/routes_info.tfd"));
            Stops.Write(new StreamWriter(path + "/stops.tfd"));
            Footpaths.Write(new StreamWriter(path + "/footpaths.tfd"));
            StopTimes.Write(new StreamWriter(path + "/stop_times.tfd"));
            Routes.Write(new StreamWriter(path + "/routes.tfd"));

            using (var expiration = new StreamWriter(path + "/expires.tfd"))
                expiration.Write(ExpirationDate.ToString("yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture));
        }
Esempio n. 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));
                    }
                }
            }
        }