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

Fix #449: Avoid exception in ValidateTransferWalkingTime if lat/lon is unset #466

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions tests/transitfeed/testtransfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,21 @@ def testVeryCloseStationsDoNotTriggerWarning(self):
transfer.Validate(self.problems)
self.accumulator.AssertNoMoreExceptions()

def testStationsWithoutCoordsDoNotCrashValidation(self):
# from_stop_id and to_stop_id are present in schedule,
# but one of the stops has no coordinates
schedule = transitfeed.Schedule()
stop1 = schedule.AddStop(57.5, 30.2, "stop 1")
stop2 = schedule.AddStop(None, None, "stop 2")
transfer = transitfeed.Transfer(schedule=schedule)
transfer.from_stop_id = stop1.stop_id
transfer.to_stop_id = stop2.stop_id
transfer.transfer_type = 2
transfer.min_transfer_time = 60
repr(transfer) # shouldn't crash
transfer.Validate(self.problems)
self.accumulator.AssertNoMoreExceptions()

def testCustomAttribute(self):
"""Add unknown attributes to a Transfer and make sure they are saved."""
transfer = transitfeed.Transfer()
Expand Down
4 changes: 4 additions & 0 deletions transitfeed/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ def ValidateTransferWalkingTime(self, problems):
return

distance = self.GetTransferDistance()
# if distance is None, lat/lon of one or both stops are invalid,
# which is already reported
if distance is None:
return
# If min_transfer_time + 120s isn't enough for someone walking very fast
# (2m/s) then issue a warning.
#
Expand Down