Esempio n. 1
0
        /// <summary>
        /// Compares two feeds.
        /// </summary>
        /// <param name="actual"></param>
        /// <param name="expected"></param>
        public static void AreEqual(IGTFSFeed actual, IGTFSFeed expected)
        {
            // first compare feed info.
            GTFSAssert.AreEqual(actual.GetFeedInfo(), expected.GetFeedInfo());

            // compare agencies.
            GTFSAssert.AreEqual <Agency>(actual.Agencies, expected.Agencies,
                                         (x, y) => x.Id == y.Id, (x, y) => GTFSAssert.AreEqual(x, y));
            GTFSAssert.AreEqual <CalendarDate>(actual.CalendarDates, expected.CalendarDates,
                                               (x, y) => x.ServiceId == y.ServiceId && x.Date == y.Date && x.ExceptionType == y.ExceptionType, (x, y) => GTFSAssert.AreEqual(x, y));
            GTFSAssert.AreEqual <Calendar>(actual.Calendars, expected.Calendars,
                                           (x, y) => x.ToString() == y.ToString(), (x, y) => GTFSAssert.AreEqual(x, y));
            GTFSAssert.AreEqual <FareAttribute>(actual.FareAttributes, expected.FareAttributes,
                                                (x, y) => x.FareId == y.FareId, (x, y) => GTFSAssert.AreEqual(x, y));
            GTFSAssert.AreEqual <FareRule>(actual.FareRules, expected.FareRules,
                                           (x, y) => x.ContainsId == y.ContainsId && x.DestinationId == y.DestinationId &&
                                           x.FareId == y.FareId && x.OriginId == y.OriginId && x.RouteId == y.RouteId,
                                           (x, y) => GTFSAssert.AreEqual(x, y));
            GTFSAssert.AreEqual <Frequency>(actual.Frequencies, expected.Frequencies,
                                            (x, y) => x.TripId == y.TripId && x.StartTime == y.StartTime, (x, y) => GTFSAssert.AreEqual(x, y));
            GTFSAssert.AreEqual <Route>(actual.Routes, expected.Routes,
                                        (x, y) => x.Id == y.Id, (x, y) => GTFSAssert.AreEqual(x, y));
            GTFSAssert.AreEqual <Shape>(actual.Shapes, expected.Shapes,
                                        (x, y) => x.Id == y.Id && x.Sequence == y.Sequence, (x, y) => GTFSAssert.AreEqual(x, y));
            GTFSAssert.AreEqual <Stop>(actual.Stops, expected.Stops,
                                       (x, y) => x.Id == y.Id, (x, y) => GTFSAssert.AreEqual(x, y));
            GTFSAssert.AreEqual <StopTime>(actual.StopTimes, expected.StopTimes,
                                           (x, y) => x.TripId == y.TripId && x.StopId == y.StopId && x.StopSequence == y.StopSequence, (x, y) => GTFSAssert.AreEqual(x, y));
            GTFSAssert.AreEqual <Transfer>(actual.Transfers, expected.Transfers,
                                           (x, y) => x.FromStopId == y.FromStopId && x.ToStopId == y.ToStopId && x.TransferType == y.TransferType, (x, y) => GTFSAssert.AreEqual(x, y));
            GTFSAssert.AreEqual <Trip>(actual.Trips, expected.Trips,
                                       (x, y) => x.Id == y.Id, (x, y) => GTFSAssert.AreEqual(x, y));
        }
Esempio n. 2
0
        /// <summary>
        /// Merges the content of the given feed with this feed by adding or replacing entities.
        /// </summary>
        public static void Merge(this IGTFSFeed thisFeed, IGTFSFeed feed)
        {
            var feedInfo = feed.GetFeedInfo();

            if (feedInfo != null)
            {
                thisFeed.SetFeedInfo(feedInfo);
            }
            foreach (var entity in feed.Agencies)
            {
                thisFeed.Agencies.AddOrReplace(entity, x => x.Id);
            }
            foreach (var entity in feed.CalendarDates)
            {
                thisFeed.CalendarDates.AddOrReplace(entity);
            }
            foreach (var entity in feed.Calendars)
            {
                thisFeed.Calendars.AddOrReplace(entity);
            }
            foreach (var entity in feed.FareAttributes)
            {
                thisFeed.FareAttributes.AddOrReplace(entity);
            }
            foreach (var entity in feed.FareRules)
            {
                thisFeed.FareRules.AddOrReplace(entity, x => x.FareId);
            }
            foreach (var entity in feed.Frequencies)
            {
                thisFeed.Frequencies.AddOrReplace(entity);
            }
            foreach (var entity in feed.Routes)
            {
                thisFeed.Routes.AddOrReplace(entity, x => x.Id);
            }
            foreach (var entity in feed.Shapes)
            {
                thisFeed.Shapes.AddOrReplace(entity);
            }
            foreach (var entity in feed.Stops)
            {
                thisFeed.Stops.AddOrReplace(entity, x => x.Id);
            }
            foreach (var entity in feed.StopTimes)
            {
                thisFeed.StopTimes.AddOrReplace(entity);
            }
            foreach (var entity in feed.Transfers)
            {
                thisFeed.Transfers.AddOrReplace(entity);
            }
            foreach (var entity in feed.Trips)
            {
                thisFeed.Trips.AddOrReplace(entity, x => x.Id);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Copies this feed to the given feed.
        /// </summary>
        public static void CopyTo(this IGTFSFeed thisFeed, IGTFSFeed feed)
        {
            var feedInfo = thisFeed.GetFeedInfo();

            if (feedInfo != null)
            {
                feed.SetFeedInfo(feedInfo);
            }
            foreach (var entity in thisFeed.Agencies)
            {
                feed.Agencies.Add(entity);
            }
            foreach (var entity in thisFeed.CalendarDates)
            {
                feed.CalendarDates.Add(entity);
            }
            foreach (var entity in thisFeed.Calendars)
            {
                feed.Calendars.Add(entity);
            }
            foreach (var entity in thisFeed.FareAttributes)
            {
                feed.FareAttributes.Add(entity);
            }
            foreach (var entity in thisFeed.FareRules)
            {
                feed.FareRules.Add(entity);
            }
            foreach (var entity in thisFeed.Frequencies)
            {
                feed.Frequencies.Add(entity);
            }
            foreach (var entity in thisFeed.Routes)
            {
                feed.Routes.Add(entity);
            }
            foreach (var entity in thisFeed.Shapes)
            {
                feed.Shapes.Add(entity);
            }
            foreach (var entity in thisFeed.Stops)
            {
                feed.Stops.Add(entity);
            }
            foreach (var entity in thisFeed.StopTimes)
            {
                feed.StopTimes.Add(entity);
            }
            foreach (var entity in thisFeed.Transfers)
            {
                feed.Transfers.Add(entity);
            }
            foreach (var entity in thisFeed.Trips)
            {
                feed.Trips.Add(entity);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Copies this feed to the given feed.
        /// </summary>
        public static void CopyTo(this IGTFSFeed thisFeed, IGTFSFeed feed)
        {
            var feedInfo = thisFeed.GetFeedInfo();

            if (feedInfo != null)
            {
                feed.SetFeedInfo(feedInfo);
            }

            feed.Agencies.AddRange(thisFeed.Agencies);
            feed.CalendarDates.AddRange(thisFeed.CalendarDates);
            feed.Calendars.AddRange(thisFeed.Calendars);
            feed.FareAttributes.AddRange(thisFeed.FareAttributes);
            feed.FareRules.AddRange(thisFeed.FareRules);
            feed.Frequencies.AddRange(thisFeed.Frequencies);
            feed.Routes.AddRange(thisFeed.Routes);
            feed.Shapes.AddRange(thisFeed.Shapes);
            feed.Stops.AddRange(thisFeed.Stops);
            feed.StopTimes.AddRange(thisFeed.StopTimes);
            feed.Transfers.AddRange(thisFeed.Transfers);
            feed.Trips.AddRange(thisFeed.Trips);
            feed.Levels.AddRange(thisFeed.Levels);
            feed.Pathways.AddRange(thisFeed.Pathways);
        }