Skip to content

Commit 09ddf1e

Browse files
committed
feat(core-utils): restore walkSpeed param for walk-only trips
1 parent 5cab01d commit 09ddf1e

File tree

5 files changed

+73
-4
lines changed

5 files changed

+73
-4
lines changed

packages/core-utils/src/__tests__/__snapshots__/query-params.ts.snap

+25
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,31 @@ Array [
7575
"ITINERARY",
7676
],
7777
},
78+
Object {
79+
"applicable": [Function],
80+
"default": 1.34,
81+
"label": "Walk Speed",
82+
"name": "walkSpeed",
83+
"options": Array [
84+
Object {
85+
"text": "2 MPH",
86+
"value": 0.89,
87+
},
88+
Object {
89+
"text": "3 MPH",
90+
"value": 1.34,
91+
},
92+
Object {
93+
"text": "4 MPH",
94+
"value": 1.79,
95+
},
96+
],
97+
"routingTypes": Array [
98+
"ITINERARY",
99+
"PROFILE",
100+
],
101+
"selector": "DROPDOWN",
102+
},
78103
Object {
79104
"applicable": [Function],
80105
"default": 1609,

packages/core-utils/src/__tests__/__snapshots__/query.js.snap

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Object {
2424
"startTime": "07:00",
2525
"time": "19:34",
2626
"to": null,
27+
"walkSpeed": 1.34,
2728
"watts": 250,
2829
"wheelchair": false,
2930
}
@@ -53,6 +54,7 @@ Object {
5354
"startTime": "07:00",
5455
"time": "19:34",
5556
"to": null,
57+
"walkSpeed": 1.34,
5658
"watts": 250,
5759
"wheelchair": false,
5860
}
@@ -86,6 +88,7 @@ Object {
8688
"showIntermediateStops": true,
8789
"time": "21:53",
8890
"toPlace": "Municipal Wharf St, Santa Cruz, CA, 95060, USA::36.961843106786766,-122.02402657342725",
91+
"walkSpeed": 1.34,
8992
}
9093
`;
9194

packages/core-utils/src/__tests__/query.js

+15-3
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,23 @@ describe("query", () => {
185185
).toBe(false);
186186
});
187187

188-
it("should return true for query with modified maxWalkDistance", () => {
188+
it("should return true for query with modified walkSpeed", () => {
189189
setDefaultTestTime();
190190
const query = getDefaultQuery(config);
191-
// Double the max walk distance
192-
query.maxWalkDistance *= 2;
191+
// Set the mode to walk only so walkSpeed is applicable
192+
query.mode = "WALK";
193+
// Double the walk speed
194+
query.walkSpeed *= 2;
195+
expect(isNotDefaultQuery(query, config)).toBe(true);
196+
});
197+
198+
it("should return true for query with modified bikeSpeed", () => {
199+
setDefaultTestTime();
200+
const query = getDefaultQuery(config);
201+
// Set the mode to bicycle
202+
query.mode = "BICYCLE";
203+
// Double the bike speed
204+
query.bikeSpeed *= 2;
193205
expect(isNotDefaultQuery(query, config)).toBe(true);
194206
});
195207

packages/core-utils/src/query-params.js

+29
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,33 @@ const queryParams = [
163163
default: true
164164
},
165165

166+
{
167+
/* walkSpeed -- the user's walking speed in m/s */
168+
name: "walkSpeed",
169+
routingTypes: ["ITINERARY", "PROFILE"],
170+
default: 1.34,
171+
selector: "DROPDOWN",
172+
label: "Walk Speed",
173+
applicable: query =>
174+
query.mode &&
175+
!hasTransit(query.mode) && // Only applicable for walk-only trips (see walkTolerance for transit+walk)
176+
query.mode.indexOf("WALK") !== -1,
177+
options: [
178+
{
179+
text: "2 MPH",
180+
value: 0.89
181+
},
182+
{
183+
text: "3 MPH",
184+
value: 1.34
185+
},
186+
{
187+
text: "4 MPH",
188+
value: 1.79
189+
}
190+
]
191+
},
192+
166193
{
167194
/* maxWalkDistance - the maximum distance in meters the user will walk to transit. */
168195
name: "maxWalkDistance",
@@ -365,6 +392,7 @@ const queryParams = [
365392
}
366393
]
367394
},
395+
368396
{
369397
name: "walkReluctance",
370398
routingTypes: ["ITINERARY", "PROFILE"],
@@ -382,6 +410,7 @@ const queryParams = [
382410
*/
383411
!!query.otp2 && query.mode && query.mode.indexOf("WALK") !== -1
384412
},
413+
385414
{
386415
/* maxBikeTime -- the maximum time the user will spend biking in minutes */
387416
name: "maxBikeTime",

packages/core-utils/src/query.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import {
1616

1717
export const defaultParams = [
1818
"wheelchair",
19-
"maxWalkDistance",
2019
"walkReluctance",
20+
"walkSpeed",
2121
"maxWalkTime",
2222
"maxBikeDistance",
2323
"maxBikeTime",

0 commit comments

Comments
 (0)