Skip to content

feat(core-utils): restore walkSpeed param for walk-only trips #813

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,31 @@ Array [
"ITINERARY",
],
},
Object {
"applicable": [Function],
"default": 1.34,
"label": "Walk Speed",
"name": "walkSpeed",
"options": Array [
Object {
"text": "2 MPH",
"value": 0.89,
},
Object {
"text": "3 MPH",
"value": 1.34,
},
Object {
"text": "4 MPH",
"value": 1.79,
},
],
"routingTypes": Array [
"ITINERARY",
"PROFILE",
],
"selector": "DROPDOWN",
},
Object {
"applicable": [Function],
"default": 1609,
Expand Down
3 changes: 3 additions & 0 deletions packages/core-utils/src/__tests__/__snapshots__/query.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Object {
"startTime": "07:00",
"time": "19:34",
"to": null,
"walkSpeed": 1.34,
"watts": 250,
"wheelchair": false,
}
Expand Down Expand Up @@ -53,6 +54,7 @@ Object {
"startTime": "07:00",
"time": "19:34",
"to": null,
"walkSpeed": 1.34,
"watts": 250,
"wheelchair": false,
}
Expand Down Expand Up @@ -86,6 +88,7 @@ Object {
"showIntermediateStops": true,
"time": "21:53",
"toPlace": "Municipal Wharf St, Santa Cruz, CA, 95060, USA::36.961843106786766,-122.02402657342725",
"walkSpeed": 1.34,
}
`;

Expand Down
18 changes: 15 additions & 3 deletions packages/core-utils/src/__tests__/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,23 @@ describe("query", () => {
).toBe(false);
});

it("should return true for query with modified maxWalkDistance", () => {
it("should return true for query with modified walkSpeed", () => {
setDefaultTestTime();
const query = getDefaultQuery(config);
// Double the max walk distance
query.maxWalkDistance *= 2;
// Set the mode to walk only so walkSpeed is applicable
query.mode = "WALK";
// Double the walk speed
query.walkSpeed *= 2;
expect(isNotDefaultQuery(query, config)).toBe(true);
});

it("should return true for query with modified bikeSpeed", () => {
setDefaultTestTime();
const query = getDefaultQuery(config);
// Set the mode to bicycle
query.mode = "BICYCLE";
// Double the bike speed
query.bikeSpeed *= 2;
expect(isNotDefaultQuery(query, config)).toBe(true);
});

Expand Down
29 changes: 29 additions & 0 deletions packages/core-utils/src/query-params.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,33 @@ const queryParams = [
default: true
},

{
/* walkSpeed -- the user's walking speed in m/s */
name: "walkSpeed",
routingTypes: ["ITINERARY", "PROFILE"],
default: 1.34,
selector: "DROPDOWN",
label: "Walk Speed",
applicable: query =>
query.mode &&
!hasTransit(query.mode) && // Only applicable for walk-only trips (see walkTolerance for transit+walk)
query.mode.indexOf("WALK") !== -1,
options: [
{
text: "2 MPH",
value: 0.89
},
{
text: "3 MPH",
value: 1.34
},
{
text: "4 MPH",
value: 1.79
}
]
},

{
/* maxWalkDistance - the maximum distance in meters the user will walk to transit. */
name: "maxWalkDistance",
Expand Down Expand Up @@ -365,6 +392,7 @@ const queryParams = [
}
]
},

{
name: "walkReluctance",
routingTypes: ["ITINERARY", "PROFILE"],
Expand All @@ -382,6 +410,7 @@ const queryParams = [
*/
!!query.otp2 && query.mode && query.mode.indexOf("WALK") !== -1
},

{
/* maxBikeTime -- the maximum time the user will spend biking in minutes */
name: "maxBikeTime",
Expand Down
2 changes: 1 addition & 1 deletion packages/core-utils/src/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import {

export const defaultParams = [
"wheelchair",
"maxWalkDistance",
"walkReluctance",
"walkSpeed",
"maxWalkTime",
"maxBikeDistance",
"maxBikeTime",
Expand Down
Loading