6
6
import numpy as np
7
7
from nextpipe import FlowSpec , app , needs , step
8
8
from traveltimepy import Client
9
- from traveltimepy .requests .common import Location , Coordinates , Property
9
+ from traveltimepy .requests .common import Coordinates , Location , Property
10
10
from traveltimepy .requests .time_filter_fast import TimeFilterFastArrivalSearches , TimeFilterFastOneToMany
11
11
from traveltimepy .requests .transportation import TransportationFast
12
12
@@ -43,12 +43,7 @@ def build_locations_list(nextroute_input):
43
43
44
44
# Add stops first
45
45
for stop in nextroute_input .stops :
46
- locations .append (
47
- Location (
48
- id = stop .id ,
49
- coords = Coordinates (lat = stop .location .lat , lng = stop .location .lon )
50
- )
51
- )
46
+ locations .append (Location (id = stop .id , coords = Coordinates (lat = stop .location .lat , lng = stop .location .lon )))
52
47
53
48
# Add vehicle start/end locations for each vehicle
54
49
for vehicle in nextroute_input .vehicles :
@@ -59,8 +54,8 @@ def build_locations_list(nextroute_input):
59
54
id = start_id ,
60
55
coords = Coordinates (
61
56
lat = nextroute_input .defaults .vehicles .start_location .lat ,
62
- lng = nextroute_input .defaults .vehicles .start_location .lon
63
- )
57
+ lng = nextroute_input .defaults .vehicles .start_location .lon ,
58
+ ),
64
59
)
65
60
)
66
61
@@ -71,8 +66,8 @@ def build_locations_list(nextroute_input):
71
66
id = end_id ,
72
67
coords = Coordinates (
73
68
lat = nextroute_input .defaults .vehicles .end_location .lat ,
74
- lng = nextroute_input .defaults .vehicles .end_location .lon
75
- )
69
+ lng = nextroute_input .defaults .vehicles .end_location .lon ,
70
+ ),
76
71
)
77
72
)
78
73
@@ -145,17 +140,14 @@ def sync_part(input_data: dict, client):
145
140
arrival_location_ids = destinations ,
146
141
transportation = TransportationFast .DRIVING ,
147
142
travel_time = 7200 , # 2 hours maximum
148
- properties = [Property .TRAVEL_TIME , Property .DISTANCE ]
143
+ properties = [Property .TRAVEL_TIME , Property .DISTANCE ],
149
144
)
150
145
)
151
146
152
147
# Execute the API call
153
148
results = client .time_filter_fast (
154
149
locations = locations ,
155
- arrival_searches = TimeFilterFastArrivalSearches (
156
- one_to_many = one_to_many_searches ,
157
- many_to_one = []
158
- )
150
+ arrival_searches = TimeFilterFastArrivalSearches (one_to_many = one_to_many_searches , many_to_one = []),
159
151
)
160
152
161
153
# Build travel matrices from API results
@@ -164,7 +156,7 @@ def sync_part(input_data: dict, client):
164
156
return {
165
157
"duration_matrix" : duration_matrix .tolist (),
166
158
"distance_matrix" : distance_matrix .tolist (),
167
- "location_ids" : location_ids # Include location IDs for reference
159
+ "location_ids" : location_ids , # Include location IDs for reference
168
160
}
169
161
170
162
0 commit comments