@opentripplanner/core-utils 13.0.0-alpha.2 → 13.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/esm/query-params.js +773 -0
- package/esm/query-params.js.map +1 -0
- package/lib/itinerary.js +63 -51
- package/lib/itinerary.js.map +1 -1
- package/lib/profile.js +1 -1
- package/lib/profile.js.map +1 -1
- package/lib/query-gen.js +2 -1
- package/lib/query-gen.js.map +1 -1
- package/lib/query-params.js +735 -0
- package/lib/query-params.js.map +1 -0
- package/lib/query.js +4 -2
- package/lib/query.js.map +1 -1
- package/lib/time.js +9 -5
- package/lib/time.js.map +1 -1
- package/package.json +3 -3
- package/esm/query-params.jsx +0 -893
- package/lib/query-params.jsx +0 -893
|
@@ -0,0 +1,773 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
// TODO: Remove this entire file, as it is deprecated in favor of i18n-queryParams within
|
|
5
|
+
// the SettingsSelector package
|
|
6
|
+
|
|
7
|
+
// This is only used within stories
|
|
8
|
+
import cloneDeep from "lodash.clonedeep";
|
|
9
|
+
import React from "react";
|
|
10
|
+
import { Wheelchair } from "@styled-icons/foundation/Wheelchair";
|
|
11
|
+
import { isTransit, isAccessMode, isCar, hasTransit, hasBike, hasMicromobility } from "./itinerary";
|
|
12
|
+
import { getItem } from "./storage";
|
|
13
|
+
import { getCurrentDate, getCurrentTime } from "./time";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* name: the default name of the parameter used for internal reference and API calls
|
|
17
|
+
*
|
|
18
|
+
* routingTypes: array of routing type(s) (ITINERARY, PROFILE, or both) this param applies to
|
|
19
|
+
*
|
|
20
|
+
* applicable: an optional function (accepting the current full query as a
|
|
21
|
+
* parameter) indicating whether this query parameter is applicable to the query.
|
|
22
|
+
* (Applicability is assumed if this function is not provided.)
|
|
23
|
+
*
|
|
24
|
+
* default: the default value for this parameter. The default can be also be a
|
|
25
|
+
* function that gets executed when accessing the default value.
|
|
26
|
+
*
|
|
27
|
+
* itineraryRewrite: an optional function for translating the key and/or value
|
|
28
|
+
* for ITINERARY mode only (e.g. 'to' is rewritten as 'toPlace'). Accepts the
|
|
29
|
+
* initial internal value as a function parameter.
|
|
30
|
+
*
|
|
31
|
+
* profileRewrite: an optional function for translating the value for PROFILE mode
|
|
32
|
+
*
|
|
33
|
+
* label: a text label for for onscreen display. May either be a text string or a
|
|
34
|
+
* function (accepting the current full query as a parameter) returning a string
|
|
35
|
+
*
|
|
36
|
+
* selector: the default type of UI selector to use in the form. Can be one of:
|
|
37
|
+
* - DROPDOWN: a standard drop-down menu selector
|
|
38
|
+
*
|
|
39
|
+
* options: an array of text/value pairs used with a dropdown selector
|
|
40
|
+
*
|
|
41
|
+
* TODO: validation system for rewrite functions and/or better user documentation
|
|
42
|
+
* TODO: alphabetize below list
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
// FIXME: Use for parsing URL values?
|
|
46
|
+
// const stringToLocation = string => {
|
|
47
|
+
// const split = string.split(',')
|
|
48
|
+
// return split.length === 2
|
|
49
|
+
// ? {lat: split[0], lon: split[1]}
|
|
50
|
+
// : {lat: null, lon: null}
|
|
51
|
+
// }
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Format location object as string for use in fromPlace or toPlace query param.
|
|
55
|
+
*/
|
|
56
|
+
export function formatPlace(location, alternateName) {
|
|
57
|
+
if (!location) return null;
|
|
58
|
+
var name = location.name || "".concat(alternateName ? "".concat(alternateName, " ") : "", "(").concat(location.lat, ",").concat(location.lon, ")");
|
|
59
|
+
// This string is not language-specific
|
|
60
|
+
return "".concat(name, "::").concat(location.lat, ",").concat(location.lon);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Load stored default query settings from local storage
|
|
64
|
+
var storedSettings = getItem("defaultQuery", {});
|
|
65
|
+
var queryParams = [{
|
|
66
|
+
/* from - the trip origin. stored internally as a location (lat/lon/name) object */
|
|
67
|
+
name: "from",
|
|
68
|
+
routingTypes: ["ITINERARY", "PROFILE"],
|
|
69
|
+
"default": null,
|
|
70
|
+
itineraryRewrite: function itineraryRewrite(value) {
|
|
71
|
+
return {
|
|
72
|
+
fromPlace: formatPlace(value)
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
profileRewrite: function profileRewrite(value) {
|
|
76
|
+
return {
|
|
77
|
+
from: {
|
|
78
|
+
lat: value.lat,
|
|
79
|
+
lon: value.lon
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
// FIXME: Use for parsing URL values?
|
|
84
|
+
// fromURL: stringToLocation
|
|
85
|
+
}, {
|
|
86
|
+
/* to - the trip destination. stored internally as a location (lat/lon/name) object */
|
|
87
|
+
name: "to",
|
|
88
|
+
routingTypes: ["ITINERARY", "PROFILE"],
|
|
89
|
+
"default": null,
|
|
90
|
+
itineraryRewrite: function itineraryRewrite(value) {
|
|
91
|
+
return {
|
|
92
|
+
toPlace: formatPlace(value)
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
profileRewrite: function profileRewrite(value) {
|
|
96
|
+
return {
|
|
97
|
+
to: {
|
|
98
|
+
lat: value.lat,
|
|
99
|
+
lon: value.lon
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
// FIXME: Use for parsing URL values?
|
|
104
|
+
// fromURL: stringToLocation
|
|
105
|
+
}, {
|
|
106
|
+
/* date - the date of travel, in MM-DD-YYYY format */
|
|
107
|
+
name: "date",
|
|
108
|
+
routingTypes: ["ITINERARY", "PROFILE"],
|
|
109
|
+
"default": getCurrentDate
|
|
110
|
+
}, {
|
|
111
|
+
/* time - the arrival/departure time for an itinerary trip, in HH:mm format */
|
|
112
|
+
name: "time",
|
|
113
|
+
routingTypes: ["ITINERARY"],
|
|
114
|
+
"default": getCurrentTime
|
|
115
|
+
}, {
|
|
116
|
+
/* departArrive - whether this is a depart-at, arrive-by, or leave-now trip */
|
|
117
|
+
name: "departArrive",
|
|
118
|
+
routingTypes: ["ITINERARY"],
|
|
119
|
+
"default": "NOW",
|
|
120
|
+
itineraryRewrite: function itineraryRewrite(value) {
|
|
121
|
+
return {
|
|
122
|
+
arriveBy: value === "ARRIVE"
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}, {
|
|
126
|
+
/* startTime - the start time for a profile trip, in HH:mm format */
|
|
127
|
+
name: "startTime",
|
|
128
|
+
routingTypes: ["PROFILE"],
|
|
129
|
+
"default": "07:00"
|
|
130
|
+
}, {
|
|
131
|
+
/* endTime - the end time for a profile trip, in HH:mm format */
|
|
132
|
+
name: "endTime",
|
|
133
|
+
routingTypes: ["PROFILE"],
|
|
134
|
+
"default": "09:00"
|
|
135
|
+
}, {
|
|
136
|
+
/* mode - the allowed modes for a trip, as a comma-separated list */
|
|
137
|
+
name: "mode",
|
|
138
|
+
routingTypes: ["ITINERARY", "PROFILE"],
|
|
139
|
+
"default": "WALK,TRANSIT",
|
|
140
|
+
// TODO: make this dependent on routingType?
|
|
141
|
+
profileRewrite: function profileRewrite(value) {
|
|
142
|
+
var accessModes = [];
|
|
143
|
+
var directModes = [];
|
|
144
|
+
var transitModes = [];
|
|
145
|
+
if (value && value.length > 0) {
|
|
146
|
+
value.split(",").forEach(function (m) {
|
|
147
|
+
if (isTransit(m)) transitModes.push(m);
|
|
148
|
+
if (isAccessMode(m)) {
|
|
149
|
+
accessModes.push(m);
|
|
150
|
+
// TODO: make configurable whether direct-driving is considered
|
|
151
|
+
if (!isCar(m)) directModes.push(m);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
accessModes: accessModes,
|
|
157
|
+
directModes: directModes,
|
|
158
|
+
transitModes: transitModes
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
}, {
|
|
162
|
+
/* showIntermediateStops - whether response should include intermediate stops for transit legs */
|
|
163
|
+
name: "showIntermediateStops",
|
|
164
|
+
routingTypes: ["ITINERARY"],
|
|
165
|
+
"default": true
|
|
166
|
+
}, {
|
|
167
|
+
/* maxWalkDistance - the maximum distance in meters the user will walk to transit. */
|
|
168
|
+
name: "maxWalkDistance",
|
|
169
|
+
routingTypes: ["ITINERARY"],
|
|
170
|
+
applicable: function applicable(query) {
|
|
171
|
+
return (
|
|
172
|
+
/* Since this query variable isn't in this list, it's not included in the generated query
|
|
173
|
+
* It does however allow us to determine if we should show the OTP1 max walk distance
|
|
174
|
+
* dropdown or the OTP2 walk reluctance slider
|
|
175
|
+
*/
|
|
176
|
+
!query.otp2 && query.mode && hasTransit(query.mode) && query.mode.indexOf("WALK") !== -1
|
|
177
|
+
);
|
|
178
|
+
},
|
|
179
|
+
"default": 1609,
|
|
180
|
+
// 1 mi.
|
|
181
|
+
selector: "DROPDOWN",
|
|
182
|
+
label: "Maximum Walk",
|
|
183
|
+
options: [{
|
|
184
|
+
text: "1/10 mile",
|
|
185
|
+
value: 160.9
|
|
186
|
+
}, {
|
|
187
|
+
text: "1/4 mile",
|
|
188
|
+
value: 402.3
|
|
189
|
+
}, {
|
|
190
|
+
text: "1/2 mile",
|
|
191
|
+
value: 804.7
|
|
192
|
+
}, {
|
|
193
|
+
text: "3/4 mile",
|
|
194
|
+
value: 1207
|
|
195
|
+
}, {
|
|
196
|
+
text: "1 mile",
|
|
197
|
+
value: 1609
|
|
198
|
+
}, {
|
|
199
|
+
text: "2 miles",
|
|
200
|
+
value: 3219
|
|
201
|
+
}, {
|
|
202
|
+
text: "5 miles",
|
|
203
|
+
value: 8047
|
|
204
|
+
}]
|
|
205
|
+
}, {
|
|
206
|
+
/* maxBikeDistance - the maximum distance in meters the user will bike. Not
|
|
207
|
+
* actually an OTP parameter (maxWalkDistance doubles for biking) but we
|
|
208
|
+
* store it separately internally in order to allow different default values,
|
|
209
|
+
* options, etc. Translated to 'maxWalkDistance' via the rewrite function.
|
|
210
|
+
*/
|
|
211
|
+
name: "maxBikeDistance",
|
|
212
|
+
routingTypes: ["ITINERARY"],
|
|
213
|
+
applicable: function applicable(query) {
|
|
214
|
+
return query.mode && hasTransit(query.mode) && query.mode.indexOf("BICYCLE") !== -1;
|
|
215
|
+
},
|
|
216
|
+
"default": 4828,
|
|
217
|
+
// 3 mi.
|
|
218
|
+
selector: "DROPDOWN",
|
|
219
|
+
label: "Maximum Bike",
|
|
220
|
+
options: [{
|
|
221
|
+
text: "1/4 mile",
|
|
222
|
+
value: 402.3
|
|
223
|
+
}, {
|
|
224
|
+
text: "1/2 mile",
|
|
225
|
+
value: 804.7
|
|
226
|
+
}, {
|
|
227
|
+
text: "3/4 mile",
|
|
228
|
+
value: 1207
|
|
229
|
+
}, {
|
|
230
|
+
text: "1 mile",
|
|
231
|
+
value: 1609
|
|
232
|
+
}, {
|
|
233
|
+
text: "2 miles",
|
|
234
|
+
value: 3219
|
|
235
|
+
}, {
|
|
236
|
+
text: "3 miles",
|
|
237
|
+
value: 4828
|
|
238
|
+
}, {
|
|
239
|
+
text: "5 miles",
|
|
240
|
+
value: 8047
|
|
241
|
+
}, {
|
|
242
|
+
text: "10 miles",
|
|
243
|
+
value: 16093
|
|
244
|
+
}, {
|
|
245
|
+
text: "20 miles",
|
|
246
|
+
value: 32187
|
|
247
|
+
}, {
|
|
248
|
+
text: "30 miles",
|
|
249
|
+
value: 48280
|
|
250
|
+
}],
|
|
251
|
+
itineraryRewrite: function itineraryRewrite(value) {
|
|
252
|
+
return {
|
|
253
|
+
maxWalkDistance: value,
|
|
254
|
+
// ensures that the value is repopulated when loaded from URL params
|
|
255
|
+
maxBikeDistance: value
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
}, {
|
|
259
|
+
/* optimize -- how to optimize a trip (non-bike, non-micromobility trips) */
|
|
260
|
+
name: "optimize",
|
|
261
|
+
// This parameter doesn't seem to do anything
|
|
262
|
+
applicable: function applicable() {
|
|
263
|
+
return false;
|
|
264
|
+
},
|
|
265
|
+
routingTypes: ["ITINERARY"],
|
|
266
|
+
"default": "QUICK",
|
|
267
|
+
selector: "DROPDOWN",
|
|
268
|
+
label: "Optimize for",
|
|
269
|
+
options: [{
|
|
270
|
+
text: "Speed",
|
|
271
|
+
value: "QUICK"
|
|
272
|
+
}, {
|
|
273
|
+
text: "Fewest Transfers",
|
|
274
|
+
value: "TRANSFERS"
|
|
275
|
+
}]
|
|
276
|
+
}, {
|
|
277
|
+
/* optimizeBike -- how to optimize an bike-based trip */
|
|
278
|
+
name: "optimizeBike",
|
|
279
|
+
applicable: function applicable(query) {
|
|
280
|
+
return !query.otp2 && hasBike(query.mode);
|
|
281
|
+
},
|
|
282
|
+
routingTypes: ["ITINERARY"],
|
|
283
|
+
"default": "SAFE",
|
|
284
|
+
selector: "DROPDOWN",
|
|
285
|
+
label: "Optimize for",
|
|
286
|
+
options: function options() {
|
|
287
|
+
var opts = [{
|
|
288
|
+
text: "Speed",
|
|
289
|
+
value: "QUICK"
|
|
290
|
+
}, {
|
|
291
|
+
text: "Bike-Friendly Trip",
|
|
292
|
+
value: "SAFE"
|
|
293
|
+
}, {
|
|
294
|
+
text: "Flat Trip",
|
|
295
|
+
value: "FLAT"
|
|
296
|
+
}];
|
|
297
|
+
return opts;
|
|
298
|
+
},
|
|
299
|
+
itineraryRewrite: function itineraryRewrite(value) {
|
|
300
|
+
return {
|
|
301
|
+
optimize: value
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
}, {
|
|
305
|
+
/* maxWalkTime -- the maximum time the user will spend walking in minutes */
|
|
306
|
+
name: "maxWalkTime",
|
|
307
|
+
routingTypes: ["PROFILE"],
|
|
308
|
+
"default": 15,
|
|
309
|
+
selector: "DROPDOWN",
|
|
310
|
+
label: "Max Walk Time",
|
|
311
|
+
applicable: function applicable(query) {
|
|
312
|
+
return query.mode && hasTransit(query.mode) && query.mode.indexOf("WALK") !== -1;
|
|
313
|
+
},
|
|
314
|
+
options: [{
|
|
315
|
+
text: "5 minutes",
|
|
316
|
+
value: 5
|
|
317
|
+
}, {
|
|
318
|
+
text: "10 minutes",
|
|
319
|
+
value: 10
|
|
320
|
+
}, {
|
|
321
|
+
text: "15 minutes",
|
|
322
|
+
value: 15
|
|
323
|
+
}, {
|
|
324
|
+
text: "20 minutes",
|
|
325
|
+
value: 20
|
|
326
|
+
}, {
|
|
327
|
+
text: "30 minutes",
|
|
328
|
+
value: 30
|
|
329
|
+
}, {
|
|
330
|
+
text: "45 minutes",
|
|
331
|
+
value: 45
|
|
332
|
+
}, {
|
|
333
|
+
text: "1 hour",
|
|
334
|
+
value: 60
|
|
335
|
+
}]
|
|
336
|
+
}, {
|
|
337
|
+
name: "walkReluctance",
|
|
338
|
+
routingTypes: ["ITINERARY", "PROFILE"],
|
|
339
|
+
selector: "SLIDER",
|
|
340
|
+
low: 1,
|
|
341
|
+
high: 10,
|
|
342
|
+
step: 0.5,
|
|
343
|
+
label: "walk reluctance",
|
|
344
|
+
labelLow: "More Walking",
|
|
345
|
+
labelHigh: "More Transit",
|
|
346
|
+
applicable: function applicable(query) {
|
|
347
|
+
return (
|
|
348
|
+
/* Since this query variable isn't in this list, it's not included in the generated query
|
|
349
|
+
* It does however allow us to determine if we should show the OTP1 max walk distance
|
|
350
|
+
* dropdown or the OTP2 walk reluctance slider
|
|
351
|
+
*/
|
|
352
|
+
!!query.otp2 && query.mode && query.mode.indexOf("WALK") !== -1
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
}, {
|
|
356
|
+
/* maxBikeTime -- the maximum time the user will spend biking in minutes */
|
|
357
|
+
name: "maxBikeTime",
|
|
358
|
+
routingTypes: ["PROFILE"],
|
|
359
|
+
"default": 20,
|
|
360
|
+
selector: "DROPDOWN",
|
|
361
|
+
label: "Max Bike Time",
|
|
362
|
+
applicable: function applicable(query) {
|
|
363
|
+
return query.mode && hasTransit(query.mode) && query.mode.indexOf("BICYCLE") !== -1;
|
|
364
|
+
},
|
|
365
|
+
options: [{
|
|
366
|
+
text: "5 minutes",
|
|
367
|
+
value: 5
|
|
368
|
+
}, {
|
|
369
|
+
text: "10 minutes",
|
|
370
|
+
value: 10
|
|
371
|
+
}, {
|
|
372
|
+
text: "15 minutes",
|
|
373
|
+
value: 15
|
|
374
|
+
}, {
|
|
375
|
+
text: "20 minutes",
|
|
376
|
+
value: 20
|
|
377
|
+
}, {
|
|
378
|
+
text: "30 minutes",
|
|
379
|
+
value: 30
|
|
380
|
+
}, {
|
|
381
|
+
text: "45 minutes",
|
|
382
|
+
value: 45
|
|
383
|
+
}, {
|
|
384
|
+
text: "1 hour",
|
|
385
|
+
value: 60
|
|
386
|
+
}]
|
|
387
|
+
}, {
|
|
388
|
+
/* bikeSpeed -- the user's bikeSpeed speed in m/s */
|
|
389
|
+
name: "bikeSpeed",
|
|
390
|
+
routingTypes: ["ITINERARY", "PROFILE"],
|
|
391
|
+
"default": 3.58,
|
|
392
|
+
selector: "DROPDOWN",
|
|
393
|
+
label: "Bicycle Speed",
|
|
394
|
+
applicable: function applicable(query) {
|
|
395
|
+
return query.mode && query.mode.indexOf("BICYCLE") !== -1;
|
|
396
|
+
},
|
|
397
|
+
options: [{
|
|
398
|
+
text: "6 MPH",
|
|
399
|
+
value: 2.68
|
|
400
|
+
}, {
|
|
401
|
+
text: "8 MPH",
|
|
402
|
+
value: 3.58
|
|
403
|
+
}, {
|
|
404
|
+
text: "10 MPH",
|
|
405
|
+
value: 4.47
|
|
406
|
+
}, {
|
|
407
|
+
text: "12 MPH",
|
|
408
|
+
value: 5.36
|
|
409
|
+
}]
|
|
410
|
+
}, {
|
|
411
|
+
/* maxEScooterDistance - the maximum distance in meters the user will ride
|
|
412
|
+
* an E-scooter. Not actually an OTP parameter (maxWalkDistance doubles for
|
|
413
|
+
* any non-transit mode except for car) but we store it separately
|
|
414
|
+
* internally in order to allow different default values, options, etc.
|
|
415
|
+
* Translated to 'maxWalkDistance' via the rewrite function.
|
|
416
|
+
*/
|
|
417
|
+
name: "maxEScooterDistance",
|
|
418
|
+
routingTypes: ["ITINERARY"],
|
|
419
|
+
applicable: function applicable(query) {
|
|
420
|
+
return query.mode && hasTransit(query.mode) && hasMicromobility(query.mode);
|
|
421
|
+
},
|
|
422
|
+
"default": 4828,
|
|
423
|
+
// 3 mi.
|
|
424
|
+
selector: "DROPDOWN",
|
|
425
|
+
label: "Maximum E-scooter Distance",
|
|
426
|
+
options: [{
|
|
427
|
+
text: "1/4 mile",
|
|
428
|
+
value: 402.3
|
|
429
|
+
}, {
|
|
430
|
+
text: "1/2 mile",
|
|
431
|
+
value: 804.7
|
|
432
|
+
}, {
|
|
433
|
+
text: "3/4 mile",
|
|
434
|
+
value: 1207
|
|
435
|
+
}, {
|
|
436
|
+
text: "1 mile",
|
|
437
|
+
value: 1609
|
|
438
|
+
}, {
|
|
439
|
+
text: "2 miles",
|
|
440
|
+
value: 3219
|
|
441
|
+
}, {
|
|
442
|
+
text: "3 miles",
|
|
443
|
+
value: 4828
|
|
444
|
+
}, {
|
|
445
|
+
text: "5 miles",
|
|
446
|
+
value: 8047
|
|
447
|
+
}, {
|
|
448
|
+
text: "10 miles",
|
|
449
|
+
value: 16093
|
|
450
|
+
}, {
|
|
451
|
+
text: "20 miles",
|
|
452
|
+
value: 32187
|
|
453
|
+
}, {
|
|
454
|
+
text: "30 miles",
|
|
455
|
+
value: 48280
|
|
456
|
+
}],
|
|
457
|
+
itineraryRewrite: function itineraryRewrite(value) {
|
|
458
|
+
return {
|
|
459
|
+
maxWalkDistance: value,
|
|
460
|
+
// ensures that the value is repopulated when loaded from URL params
|
|
461
|
+
maxEScooterDistance: value
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
}, {
|
|
465
|
+
/* bikeSpeed -- the user's bikeSpeed speed in m/s */
|
|
466
|
+
name: "watts",
|
|
467
|
+
routingTypes: ["ITINERARY", "PROFILE"],
|
|
468
|
+
"default": 250,
|
|
469
|
+
selector: "DROPDOWN",
|
|
470
|
+
label: "E-scooter Power",
|
|
471
|
+
// this configuration should only be allowed for personal E-scooters as these
|
|
472
|
+
// settings will be defined by the vehicle type of an E-scooter being rented
|
|
473
|
+
applicable: function applicable(query) {
|
|
474
|
+
return query.mode && query.mode.indexOf("MICROMOBILITY") !== -1 && query.mode.indexOf("MICROMOBILITY_RENT") === -1 && query.mode.indexOf("SCOOTER") === -1;
|
|
475
|
+
},
|
|
476
|
+
options: [{
|
|
477
|
+
text: "Kid's hoverboard (6mph)",
|
|
478
|
+
value: 125
|
|
479
|
+
}, {
|
|
480
|
+
text: "Entry-level scooter (11mph)",
|
|
481
|
+
value: 250
|
|
482
|
+
}, {
|
|
483
|
+
text: "Robust E-scooter (18mph)",
|
|
484
|
+
value: 500
|
|
485
|
+
}, {
|
|
486
|
+
text: "Powerful E-scooter (24mph)",
|
|
487
|
+
value: 1500
|
|
488
|
+
}],
|
|
489
|
+
// rewrite a few other values to add some baseline assumptions about the
|
|
490
|
+
// vehicle
|
|
491
|
+
itineraryRewrite: function itineraryRewrite(value) {
|
|
492
|
+
var watts = value;
|
|
493
|
+
// the maximum cruising and downhill speed. Units in m/s
|
|
494
|
+
var maximumMicromobilitySpeed;
|
|
495
|
+
var weight;
|
|
496
|
+
// see https://en.wikipedia.org/wiki/Human_body_weight#Average_weight_around_the_world
|
|
497
|
+
// estimate is for an average North American human with clothes and stuff
|
|
498
|
+
// units are in kg
|
|
499
|
+
var TYPICAL_RIDER_WEIGHT = 90;
|
|
500
|
+
switch (watts) {
|
|
501
|
+
case 125:
|
|
502
|
+
// exemplar: Swagtron Turbo 5 hoverboard (https://swagtron.com/product/recertified-swagtron-turbo-five-hoverboard-classic/)
|
|
503
|
+
maximumMicromobilitySpeed = 2.8; // ~= 6mph
|
|
504
|
+
weight = TYPICAL_RIDER_WEIGHT + 9;
|
|
505
|
+
break;
|
|
506
|
+
case 250:
|
|
507
|
+
// exemplar: Xiaomi M365 (https://www.gearbest.com/skateboard/pp_596618.html)
|
|
508
|
+
maximumMicromobilitySpeed = 5; // ~= 11.5mph
|
|
509
|
+
weight = TYPICAL_RIDER_WEIGHT + 12.5;
|
|
510
|
+
break;
|
|
511
|
+
case 500:
|
|
512
|
+
// exemplar: Razor EcoSmart Metro (https://www.amazon.com/Razor-EcoSmart-Metro-Electric-Scooter/dp/B002ZDAEIS?SubscriptionId=AKIAJMXJ2YFJTEDLQMUQ&tag=digitren08-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=B002ZDAEIS&ascsubtag=15599460143449ocb)
|
|
513
|
+
maximumMicromobilitySpeed = 8; // ~= 18mph
|
|
514
|
+
weight = TYPICAL_RIDER_WEIGHT + 30;
|
|
515
|
+
break;
|
|
516
|
+
case 1000:
|
|
517
|
+
// exemplar: Boosted Rev (https://boostedboards.com/vehicles/scooters/boosted-rev)
|
|
518
|
+
maximumMicromobilitySpeed = 11; // ~= 24mph
|
|
519
|
+
weight = TYPICAL_RIDER_WEIGHT + 21;
|
|
520
|
+
break;
|
|
521
|
+
default:
|
|
522
|
+
break;
|
|
523
|
+
}
|
|
524
|
+
return {
|
|
525
|
+
maximumMicromobilitySpeed: maximumMicromobilitySpeed,
|
|
526
|
+
watts: watts,
|
|
527
|
+
weight: weight
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
}, {
|
|
531
|
+
/* ignoreRealtimeUpdates -- if true, do not use realtime updates in routing */
|
|
532
|
+
name: "ignoreRealtimeUpdates",
|
|
533
|
+
routingTypes: ["ITINERARY"],
|
|
534
|
+
"default": false
|
|
535
|
+
}, {
|
|
536
|
+
/* companies -- tnc companies to query */
|
|
537
|
+
name: "companies",
|
|
538
|
+
routingTypes: ["ITINERARY"]
|
|
539
|
+
}, {
|
|
540
|
+
/* wheelchair -- whether the user requires a wheelchair-accessible trip */
|
|
541
|
+
name: "wheelchair",
|
|
542
|
+
routingTypes: ["ITINERARY", "PROFILE"],
|
|
543
|
+
"default": false,
|
|
544
|
+
selector: "CHECKBOX",
|
|
545
|
+
label: "Prefer Wheelchair Accessible Routes",
|
|
546
|
+
icon: /*#__PURE__*/React.createElement(Wheelchair, null),
|
|
547
|
+
applicable: function applicable(query, config) {
|
|
548
|
+
if (!query.mode || !config.modes) return false;
|
|
549
|
+
var configModes = (config.modes.accessModes || []).concat(config.modes.transitModes || []);
|
|
550
|
+
return query.mode.split(",").some(function (mode) {
|
|
551
|
+
var configMode = configModes.find(function (m) {
|
|
552
|
+
return m.mode === mode;
|
|
553
|
+
});
|
|
554
|
+
if (!configMode || !configMode.showWheelchairSetting) return false;
|
|
555
|
+
if (configMode.company && (!query.companies || !query.companies.split(",").includes(configMode.company))) return false;
|
|
556
|
+
return true;
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
}, {
|
|
560
|
+
name: "bannedRoutes",
|
|
561
|
+
routingTypes: ["ITINERARY"]
|
|
562
|
+
}, {
|
|
563
|
+
name: "numItineraries",
|
|
564
|
+
routingTypes: ["ITINERARY"],
|
|
565
|
+
"default": 3
|
|
566
|
+
}, {
|
|
567
|
+
name: "intermediatePlaces",
|
|
568
|
+
"default": [],
|
|
569
|
+
routingTypes: ["ITINERARY"],
|
|
570
|
+
itineraryRewrite: function itineraryRewrite(places) {
|
|
571
|
+
return Array.isArray(places) && places.length > 0 ? {
|
|
572
|
+
intermediatePlaces: places.map(function (place) {
|
|
573
|
+
return formatPlace(place);
|
|
574
|
+
})
|
|
575
|
+
} : undefined;
|
|
576
|
+
}
|
|
577
|
+
}, {
|
|
578
|
+
// Time penalty in seconds the requester is willing to accept in order to
|
|
579
|
+
// complete journey on preferred route. I.e., number of seconds that we are
|
|
580
|
+
// willing to wait for the preferred route.
|
|
581
|
+
name: "otherThanPreferredRoutesPenalty",
|
|
582
|
+
"default": 15 * 60,
|
|
583
|
+
// 15 minutes
|
|
584
|
+
routingTypes: ["ITINERARY"]
|
|
585
|
+
},
|
|
586
|
+
// Below are less commonly used query params included so that in case they are
|
|
587
|
+
// passed in a query parameter they do not get filtered out from the ultimate
|
|
588
|
+
// API request.
|
|
589
|
+
{
|
|
590
|
+
name: "preferredRoutes",
|
|
591
|
+
routingTypes: ["ITINERARY"]
|
|
592
|
+
}, {
|
|
593
|
+
name: "maxPreTransitTime",
|
|
594
|
+
routingTypes: ["ITINERARY"]
|
|
595
|
+
}, {
|
|
596
|
+
name: "waitReluctance",
|
|
597
|
+
routingTypes: ["ITINERARY"]
|
|
598
|
+
}, {
|
|
599
|
+
name: "driveDistanceReluctance",
|
|
600
|
+
routingTypes: ["ITINERARY"]
|
|
601
|
+
}, {
|
|
602
|
+
name: "driveTimeReluctance",
|
|
603
|
+
routingTypes: ["ITINERARY"]
|
|
604
|
+
}, {
|
|
605
|
+
name: "waitAtBeginningFactor",
|
|
606
|
+
routingTypes: ["ITINERARY"]
|
|
607
|
+
}, {
|
|
608
|
+
name: "bikeSwitchTime",
|
|
609
|
+
routingTypes: ["ITINERARY"]
|
|
610
|
+
}, {
|
|
611
|
+
name: "bikeSwitchCost",
|
|
612
|
+
routingTypes: ["ITINERARY"]
|
|
613
|
+
}, {
|
|
614
|
+
name: "minTransferTime",
|
|
615
|
+
routingTypes: ["ITINERARY"]
|
|
616
|
+
}, {
|
|
617
|
+
name: "preferredAgencies",
|
|
618
|
+
routingTypes: ["ITINERARY"]
|
|
619
|
+
}, {
|
|
620
|
+
name: "unpreferredRoutes",
|
|
621
|
+
routingTypes: ["ITINERARY"]
|
|
622
|
+
}, {
|
|
623
|
+
name: "unpreferredAgencies",
|
|
624
|
+
routingTypes: ["ITINERARY"]
|
|
625
|
+
}, {
|
|
626
|
+
name: "walkBoardCost",
|
|
627
|
+
routingTypes: ["ITINERARY"]
|
|
628
|
+
}, {
|
|
629
|
+
name: "bikeBoardCost",
|
|
630
|
+
routingTypes: ["ITINERARY"]
|
|
631
|
+
}, {
|
|
632
|
+
name: "whiteListedRoutes",
|
|
633
|
+
routingTypes: ["ITINERARY"]
|
|
634
|
+
}, {
|
|
635
|
+
name: "bannedAgencies",
|
|
636
|
+
routingTypes: ["ITINERARY"]
|
|
637
|
+
}, {
|
|
638
|
+
name: "whiteListedAgencies",
|
|
639
|
+
routingTypes: ["ITINERARY"]
|
|
640
|
+
}, {
|
|
641
|
+
name: "bannedTrips",
|
|
642
|
+
routingTypes: ["ITINERARY"]
|
|
643
|
+
}, {
|
|
644
|
+
name: "bannedStops",
|
|
645
|
+
routingTypes: ["ITINERARY"]
|
|
646
|
+
}, {
|
|
647
|
+
name: "bannedStopsHard",
|
|
648
|
+
routingTypes: ["ITINERARY"]
|
|
649
|
+
}, {
|
|
650
|
+
name: "transferPenalty",
|
|
651
|
+
routingTypes: ["ITINERARY"]
|
|
652
|
+
}, {
|
|
653
|
+
name: "nonpreferredTransferPenalty",
|
|
654
|
+
routingTypes: ["ITINERARY"]
|
|
655
|
+
}, {
|
|
656
|
+
name: "maxTransfers",
|
|
657
|
+
routingTypes: ["ITINERARY"]
|
|
658
|
+
}, {
|
|
659
|
+
name: "batch",
|
|
660
|
+
routingTypes: ["ITINERARY"]
|
|
661
|
+
}, {
|
|
662
|
+
name: "startTransitStopId",
|
|
663
|
+
routingTypes: ["ITINERARY"]
|
|
664
|
+
}, {
|
|
665
|
+
name: "startTransitTripId",
|
|
666
|
+
routingTypes: ["ITINERARY"]
|
|
667
|
+
}, {
|
|
668
|
+
name: "clampInitialWait",
|
|
669
|
+
routingTypes: ["ITINERARY"]
|
|
670
|
+
}, {
|
|
671
|
+
name: "reverseOptimizeOnTheFly",
|
|
672
|
+
routingTypes: ["ITINERARY"]
|
|
673
|
+
}, {
|
|
674
|
+
name: "boardSlack",
|
|
675
|
+
routingTypes: ["ITINERARY"]
|
|
676
|
+
}, {
|
|
677
|
+
name: "alightSlack",
|
|
678
|
+
routingTypes: ["ITINERARY"]
|
|
679
|
+
}, {
|
|
680
|
+
name: "locale",
|
|
681
|
+
routingTypes: ["ITINERARY"]
|
|
682
|
+
}, {
|
|
683
|
+
name: "disableRemainingWeightHeuristic",
|
|
684
|
+
routingTypes: ["ITINERARY"]
|
|
685
|
+
}, {
|
|
686
|
+
name: "flexFlagStopBufferSize",
|
|
687
|
+
routingTypes: ["ITINERARY"]
|
|
688
|
+
}, {
|
|
689
|
+
name: "flexUseReservationServices",
|
|
690
|
+
routingTypes: ["ITINERARY"]
|
|
691
|
+
}, {
|
|
692
|
+
name: "flexUseEligibilityServices",
|
|
693
|
+
routingTypes: ["ITINERARY"]
|
|
694
|
+
}, {
|
|
695
|
+
name: "flexIgnoreDrtAdvanceBookMin",
|
|
696
|
+
routingTypes: ["ITINERARY"]
|
|
697
|
+
}, {
|
|
698
|
+
name: "maxHours",
|
|
699
|
+
routingTypes: ["ITINERARY"]
|
|
700
|
+
}, {
|
|
701
|
+
name: "useRequestedDateTimeInMaxHours",
|
|
702
|
+
routingTypes: ["ITINERARY"]
|
|
703
|
+
}, {
|
|
704
|
+
name: "disableAlertFiltering",
|
|
705
|
+
routingTypes: ["ITINERARY"]
|
|
706
|
+
}, {
|
|
707
|
+
name: "geoidElevation",
|
|
708
|
+
routingTypes: ["ITINERARY"]
|
|
709
|
+
}, {
|
|
710
|
+
name: "invalidDateStrategy",
|
|
711
|
+
routingTypes: ["ITINERARY"]
|
|
712
|
+
}, {
|
|
713
|
+
name: "minTransitDistance",
|
|
714
|
+
routingTypes: ["ITINERARY"]
|
|
715
|
+
}, {
|
|
716
|
+
name: "searchTimeout",
|
|
717
|
+
routingTypes: ["ITINERARY"]
|
|
718
|
+
}, {
|
|
719
|
+
name: "pathComparator",
|
|
720
|
+
routingTypes: ["ITINERARY"]
|
|
721
|
+
}, {
|
|
722
|
+
name: "onlyTransitTrips",
|
|
723
|
+
routingTypes: ["ITINERARY"]
|
|
724
|
+
}, {
|
|
725
|
+
name: "minimumMicromobilitySpeed",
|
|
726
|
+
routingTypes: ["ITINERARY"]
|
|
727
|
+
}];
|
|
728
|
+
// Iterate over stored settings and update query param defaults.
|
|
729
|
+
// FIXME: this does not get updated if the user defaults are cleared
|
|
730
|
+
queryParams.forEach(function (param) {
|
|
731
|
+
if (param.name in storedSettings) {
|
|
732
|
+
param["default"] = storedSettings[param.name];
|
|
733
|
+
param.userDefaultOverride = true;
|
|
734
|
+
}
|
|
735
|
+
});
|
|
736
|
+
export default queryParams;
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* You can customize the queryParams labels and options, and labels and values for each option.
|
|
740
|
+
* @param customizations The optional customizations to apply: an object whose fields
|
|
741
|
+
* correspond to the items in queryParams with the corresponding name,
|
|
742
|
+
* the value for those fields being an object which fields (label, options...)
|
|
743
|
+
* will override the originals.
|
|
744
|
+
* Example:
|
|
745
|
+
* {
|
|
746
|
+
* // Matches the name param
|
|
747
|
+
* maxWalkDistance: {
|
|
748
|
+
* // Any fields that should be overridden go here
|
|
749
|
+
* options: [
|
|
750
|
+
* // ...new options
|
|
751
|
+
* ],
|
|
752
|
+
* default: 500,
|
|
753
|
+
* label: "max walk dist"
|
|
754
|
+
* }
|
|
755
|
+
* }
|
|
756
|
+
* @returns A copy of the default queryParams that has the given customizations applied.
|
|
757
|
+
* If no customizations parameter is provided, returns the queryParams object itself.
|
|
758
|
+
*/
|
|
759
|
+
export function getCustomQueryParams(customizations) {
|
|
760
|
+
if (!customizations) return queryParams;
|
|
761
|
+
var clonedParams = cloneDeep(queryParams);
|
|
762
|
+
Object.keys(customizations).forEach(function (k) {
|
|
763
|
+
// Merge fields into the cloned object
|
|
764
|
+
var paramIndex = clonedParams.findIndex(function (param) {
|
|
765
|
+
return param.name === k;
|
|
766
|
+
});
|
|
767
|
+
if (paramIndex !== -1) {
|
|
768
|
+
clonedParams[paramIndex] = _objectSpread(_objectSpread({}, clonedParams[paramIndex]), customizations[k]);
|
|
769
|
+
}
|
|
770
|
+
});
|
|
771
|
+
return clonedParams;
|
|
772
|
+
}
|
|
773
|
+
//# sourceMappingURL=query-params.js.map
|