Navigation Menu

Skip to content
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.

Commit

Permalink
When generating new trip ids for a trip during the merge process, sto…
Browse files Browse the repository at this point in the history
…re the original trip id in the new trips.txt original_trip_id field.
  • Loading branch information
bdferris committed Mar 4, 2015
1 parent 8237ec9 commit 39b6554
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions merge.py
Expand Up @@ -1437,6 +1437,7 @@ def _Migrate(self, original_trip, schedule, newid):
if newid:
migrated_trip.trip_id = self.feed_merger.GenerateId(
original_trip.trip_id)
migrated_trip.original_trip_id = original_trip.trip_id
# Need to add trip to schedule before copying stoptimes
self.feed_merger.merged_schedule.AddTripObject(migrated_trip,
validate=False)
Expand Down
7 changes: 6 additions & 1 deletion tests/testmerge.py
Expand Up @@ -1049,6 +1049,7 @@ def testConflictingTripid(self):
a1_in_b = transitfeed.Agency(field_dict=self.a1)
r1_in_b = transitfeed.Route(field_dict=self.r1)
t1_in_b = transitfeed.Trip(field_dict=self.t1)
t1_in_b.trip_short_name = 't1-b'
shape_in_b = transitfeed.Shape('shape1')
shape_in_b.AddPoint(30.0, 30.0)
s_in_b = transitfeed.ServicePeriod('s1')
Expand All @@ -1065,7 +1066,11 @@ def testConflictingTripid(self):
self.fm.MergeSchedules()
# 3 trips moved to merged_schedule: from a_schedule t1, t2 and from
# b_schedule t1
self.assertEquals(len(self.fm.merged_schedule.GetTripList()), 3)
trips = self.fm.merged_schedule.GetTripList()
self.assertEquals(len(trips), 3)
t1_in_b_merged = [trip for trip in trips if trip.trip_short_name == 't1-b']
self.assertEquals(len(t1_in_b_merged), 1)
self.assertEquals(t1_in_b_merged[0].original_trip_id, 't1')


class TestFareMerger(util.TestCase):
Expand Down

0 comments on commit 39b6554

Please sign in to comment.