Skip to content

Commit 47a067d

Browse files
committed
Refactor parseRouteOrUrl function to use start_time_utc_millis and end_time_utc_millis in route_info
1 parent 05d1b85 commit 47a067d

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

route_or_url.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,8 @@ def parseRouteOrUrl(
138138
for route_info in json:
139139
start_in_route = False
140140
end_in_route = False
141-
# Assume the first segment_start_time is the start of the route
142-
route_start_time = route_info["segment_start_times"][0]
143-
# Assume the last segment_end_time is the end of the route
144-
route_end_time = route_info["segment_end_times"][-1]
141+
route_start_time = route_info["start_time_utc_millis"]
142+
route_end_time = route_info["end_time_utc_millis"]
145143
# Check if the start time is in the route
146144
if start_time >= route_start_time and start_time <= route_end_time:
147145
start_in_route = True
@@ -163,10 +161,17 @@ def parseRouteOrUrl(
163161
# Get the route name
164162
route_name = matched_route["fullname"]
165163
# Compute the start seconds
164+
166165
start_seconds = (start_time - route_start_time) // 1000
167166
# Compute the length seconds
168167
length_seconds = (end_time - start_time) // 1000
169168

169+
print(f"Route: {route_name}")
170+
print(f"Matched Route: {matched_route}")
171+
print(f"Start Seconds: {start_seconds}")
172+
print(f"Start Time: {start_time}")
173+
print(f'Route Start Time: {route_start_time}')
174+
print(f"Length Seconds: {length_seconds}")
170175
# Return the parsed route
171176
return ParsedRouteOrURL(route_name, start_seconds, length_seconds)
172177

0 commit comments

Comments
 (0)