From 8cbbea710beaedf59aaba3d585b566dd1cd5f806 Mon Sep 17 00:00:00 2001 From: mikepal2 <40579649+mikepal2@users.noreply.github.com> Date: Fri, 7 Jun 2024 22:53:03 -0700 Subject: [PATCH] fix driving time calculation --- src/ferry_planner/route.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ferry_planner/route.py b/src/ferry_planner/route.py index a0c278a..739b267 100644 --- a/src/ferry_planner/route.py +++ b/src/ferry_planner/route.py @@ -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}"