Skip to content

Commit

Permalink
fix driving time calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
mikepal2 committed Jun 8, 2024
1 parent 509b103 commit 8cbbea7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ferry_planner/route.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,12 @@ def from_segments(cls, _segments: Iterable[RoutePlanSegment], /) -> RoutePlan:
driving_distance = 0.0
plan_hash = hashlib.sha1(usedforsecurity=False)
for segment in segments:
driving_distance += segment.connection.distance
if isinstance(segment.connection, CarConnection):
driving_duration += segment.connection.duration
driving_distance += segment.connection.distance
plan_hash.update(segment.connection.destination.id.encode("utf-8"))
for time in segment.times:
plan_hash.update(time.start.isoformat().encode("utf-8"))
if time.type == TimeIntervalType.TRAVEL and isinstance(first_segment.connection, CarConnection):
driving_duration += int((time.end - time.start).total_seconds())

# Create Google Maps URL.
url = "https://www.google.com/maps/dir/?api=1&origin={origin}&destination={destination}&waypoints={waypoints}"
Expand Down

0 comments on commit 8cbbea7

Please sign in to comment.