@opentripplanner/core-utils 4.11.0 → 4.11.3

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.
@@ -42,7 +42,7 @@ Object {
42
42
  "maxBikeDistance": 4828,
43
43
  "maxBikeTime": 20,
44
44
  "maxEScooterDistance": 4828,
45
- "maxWalkDistance": 1207,
45
+ "maxWalkDistance": 1609,
46
46
  "maxWalkTime": 15,
47
47
  "mode": "WALK,TRANSIT",
48
48
  "numItineraries": 3,
@@ -66,7 +66,7 @@ Object {
66
66
  "date": "2020-08-24",
67
67
  "fromPlace": "Steamer Lane, Santa Cruz, CA, 95060, USA::36.95471026341096,-122.0248185852425",
68
68
  "ignoreRealtimeUpdates": false,
69
- "maxWalkDistance": 1207,
69
+ "maxWalkDistance": 1609,
70
70
  "mode": "WALK,FLEX_EGRESS,FLEX_ACCESS,FLEX_DIRECT,TRANSIT",
71
71
  "numItineraries": 3,
72
72
  "optimize": "QUICK",
@@ -100,7 +100,7 @@ Object {
100
100
  "date": "2020-08-24",
101
101
  "fromPlace": "Steamer Lane, Santa Cruz, CA, 95060, USA::36.95471026341096,-122.0248185852425",
102
102
  "ignoreRealtimeUpdates": false,
103
- "maxWalkDistance": 1207,
103
+ "maxWalkDistance": 1609,
104
104
  "mode": "FLEX_EGRESS,FLEX_ACCESS,FLEX_DIRECT,WALK,BIKE,WALK,TRANSIT,BUS",
105
105
  "numItineraries": 3,
106
106
  "optimize": "QUICK",
@@ -157,7 +157,7 @@ Object {
157
157
  "Lighthouse Point Park, Santa Cruz, CA, USA::36.95145225211049,-122.02672866668283",
158
158
  "Natural Bridges State Beach, 2531 W Cliff Dr, Santa Cruz, CA, 95060, USA::36.95028619314903,-122.05711810284686",
159
159
  ],
160
- "maxWalkDistance": 1207,
160
+ "maxWalkDistance": 1609,
161
161
  "mode": "WALK,TRANSIT",
162
162
  "numItineraries": 3,
163
163
  "optimize": "QUICK",
@@ -191,13 +191,32 @@ Object {
191
191
  }
192
192
  `;
193
193
 
194
+ exports[`query getRoutingParams should create routing params for personal micromobility query 2`] = `
195
+ Object {
196
+ "arriveBy": false,
197
+ "companies": "FAKECOMPANY",
198
+ "date": "2020-08-24",
199
+ "fromPlace": "Steamer Lane, Santa Cruz, CA, 95060, USA::36.95471026341096,-122.0248185852425",
200
+ "ignoreRealtimeUpdates": false,
201
+ "maxEScooterDistance": 4828,
202
+ "maxWalkDistance": 4828,
203
+ "mode": "SCOOTER,BUS",
204
+ "numItineraries": 3,
205
+ "optimize": "QUICK",
206
+ "otherThanPreferredRoutesPenalty": 900,
207
+ "showIntermediateStops": true,
208
+ "time": "21:53",
209
+ "toPlace": "Municipal Wharf St, Santa Cruz, CA, 95060, USA::36.961843106786766,-122.02402657342725",
210
+ }
211
+ `;
212
+
194
213
  exports[`query getRoutingParams should create routing params for standard flex query 1`] = `
195
214
  Object {
196
215
  "arriveBy": false,
197
216
  "date": "2020-08-24",
198
217
  "fromPlace": "Steamer Lane, Santa Cruz, CA, 95060, USA::36.95471026341096,-122.0248185852425",
199
218
  "ignoreRealtimeUpdates": false,
200
- "maxWalkDistance": 1207,
219
+ "maxWalkDistance": 1609,
201
220
  "mode": "WALK,TRANSIT,FLEX_EGRESS,FLEX_ACCESS,FLEX_DIRECT",
202
221
  "numItineraries": 3,
203
222
  "optimize": "QUICK",
@@ -230,7 +249,7 @@ Object {
230
249
  "date": "2020-08-24",
231
250
  "fromPlace": "Steamer Lane, Santa Cruz, CA, 95060, USA::36.95471026341096,-122.0248185852425",
232
251
  "ignoreRealtimeUpdates": false,
233
- "maxWalkDistance": 1207,
252
+ "maxWalkDistance": 1609,
234
253
  "mode": "WALK,TRANSIT",
235
254
  "numItineraries": 3,
236
255
  "optimize": "QUICK",
@@ -80,6 +80,14 @@ describe("query", () => {
80
80
  watts: 250
81
81
  })
82
82
  ).toMatchSnapshot();
83
+ expect(
84
+ getRoutingParams(fakeConfig, {
85
+ ...makeBaseTestQuery(),
86
+ companies: "FAKECOMPANY",
87
+ mode: "SCOOTER,BUS",
88
+ watts: 250
89
+ })
90
+ ).toMatchSnapshot();
83
91
  });
84
92
 
85
93
  it("should create routing params for intermediate places query", () => {
package/src/deprecated.js CHANGED
@@ -1,7 +1,14 @@
1
1
  import moment from "moment";
2
2
 
3
- // Need to avoid cyclic dependency resolution
3
+ /**
4
+ * To disable cyclic dependency resolution we need to require() within methods
5
+ * This is a good reason to disable this eslint-rule
6
+ */
4
7
  /* eslint-disable global-require */
8
+
9
+ /**
10
+ * Generates a warning to tell developer that they are using deprecated methods!
11
+ */
5
12
  export function logDeprecationWarning(method, alternative) {
6
13
  console.warn(
7
14
  `${method ||
@@ -83,6 +90,7 @@ export function getLegModeLabel(leg) {
83
90
  return "Streetcar";
84
91
  return "Light Rail";
85
92
  case "MICROMOBILITY":
93
+ case "SCOOTER":
86
94
  return "Ride";
87
95
  default:
88
96
  return require("./itinerary").toSentenceCase(leg.mode);
package/src/itinerary.js CHANGED
@@ -104,7 +104,7 @@ export function isCar(mode) {
104
104
 
105
105
  export function isMicromobility(mode) {
106
106
  if (!mode) return false;
107
- return mode.startsWith("MICROMOBILITY");
107
+ return mode.startsWith("MICROMOBILITY") || mode.startsWith("SCOOTER");
108
108
  }
109
109
 
110
110
  export function isAccessMode(mode) {
@@ -177,7 +177,7 @@ export function getMapColor(mode) {
177
177
  if (mode === "TRAM") return "#800";
178
178
  if (mode === "FERRY") return "#008";
179
179
  if (mode === "CAR") return "#444";
180
- if (mode === "MICROMOBILITY") return "#f5a729";
180
+ if (mode === "MICROMOBILITY" || mode === "SCOOTER") return "#f5a729";
181
181
  return "#aaa";
182
182
  }
183
183
 
@@ -204,7 +204,11 @@ export function getCompanyFromLeg(leg) {
204
204
  if (mode === "BICYCLE" && rentedBike && from.networks) {
205
205
  return from.networks[0];
206
206
  }
207
- if (mode === "MICROMOBILITY" && rentedVehicle && from.networks) {
207
+ if (
208
+ (mode === "MICROMOBILITY" || mode === "SCOOTER") &&
209
+ rentedVehicle &&
210
+ from.networks
211
+ ) {
208
212
  return from.networks[0];
209
213
  }
210
214
  return null;
package/src/map.js CHANGED
@@ -1,4 +1,10 @@
1
- import { getPlaceName, isTransit, isFlex, toSentenceCase } from "./itinerary";
1
+ import {
2
+ getPlaceName,
3
+ isTransit,
4
+ isFlex,
5
+ toSentenceCase,
6
+ isAccessMode
7
+ } from "./itinerary";
2
8
 
3
9
  import {
4
10
  coordsToString,
@@ -102,15 +108,11 @@ export function itineraryToTransitive(
102
108
  });
103
109
 
104
110
  itin.legs.forEach((leg, idx) => {
105
- if (
106
- leg.mode === "WALK" ||
107
- leg.mode === "BICYCLE" ||
108
- leg.mode === "CAR" ||
109
- leg.mode === "MICROMOBILITY"
110
- ) {
111
+ if (isAccessMode(leg.mode)) {
111
112
  let fromPlaceId;
112
113
  if (leg.from.bikeShareId) {
113
114
  fromPlaceId = `bicycle_rent_station_${leg.from.bikeShareId}`;
115
+ // TODO: does this need to change to be OTP2 compatible?
114
116
  } else if (leg.from.vertexType === "VEHICLERENTAL") {
115
117
  fromPlaceId = `escooter_rent_station_${leg.from.name}`;
116
118
  } else if (
package/src/profile.js CHANGED
@@ -28,7 +28,7 @@ export function filterProfileOptions(response) {
28
28
  }
29
29
 
30
30
  function locationString(str) {
31
- return str ? str.split(",")[0] : null;
31
+ return str?.split(",")[0];
32
32
  }
33
33
 
34
34
  function accessToLeg(access, origin, destination) {
@@ -176,7 +176,7 @@ const queryParams = [
176
176
  query.mode &&
177
177
  hasTransit(query.mode) &&
178
178
  query.mode.indexOf("WALK") !== -1,
179
- default: 1207, // 3/4 mi.
179
+ default: 1609, // 1 mi.
180
180
  selector: "DROPDOWN",
181
181
  label: "Maximum Walk",
182
182
  options: [
@@ -278,7 +278,8 @@ const queryParams = [
278
278
  {
279
279
  /* optimize -- how to optimize a trip (non-bike, non-micromobility trips) */
280
280
  name: "optimize",
281
- applicable: query => hasTransit(query.mode) && !hasBike(query.mode),
281
+ applicable: query =>
282
+ !query.otp2 && hasTransit(query.mode) && !hasBike(query.mode),
282
283
  routingTypes: ["ITINERARY"],
283
284
  default: "QUICK",
284
285
  selector: "DROPDOWN",
@@ -298,7 +299,7 @@ const queryParams = [
298
299
  {
299
300
  /* optimizeBike -- how to optimize an bike-based trip */
300
301
  name: "optimizeBike",
301
- applicable: query => hasBike(query.mode),
302
+ applicable: query => !query.otp2 && hasBike(query.mode),
302
303
  routingTypes: ["ITINERARY"],
303
304
  default: "SAFE",
304
305
  selector: "DROPDOWN",
@@ -405,6 +406,8 @@ const queryParams = [
405
406
  high: 20,
406
407
  step: 0.5,
407
408
  label: "walk reluctance",
409
+ labelLow: "More Walking",
410
+ labelHigh: "More Transit",
408
411
  applicable: query =>
409
412
  /* Since this query variable isn't in this list, it's not included in the generated query
410
413
  * It does however allow us to determine if we should show the OTP1 max walk distance
@@ -558,7 +561,8 @@ const queryParams = [
558
561
  applicable: query =>
559
562
  query.mode &&
560
563
  query.mode.indexOf("MICROMOBILITY") !== -1 &&
561
- query.mode.indexOf("MICROMOBILITY_RENT") === -1,
564
+ query.mode.indexOf("MICROMOBILITY_RENT") === -1 &&
565
+ query.mode.indexOf("SCOOTER") === -1,
562
566
  options: [
563
567
  {
564
568
  text: "Kid's hoverboard (6mph)",
package/src/time.js CHANGED
@@ -109,9 +109,9 @@ export function formatDuration(seconds) {
109
109
 
110
110
  /**
111
111
  * Formats an elapsed time in seconds, minutes, hours duration for display in narrative
112
- * TODO: internationalization
113
112
  * @param {number} seconds duration in seconds
114
- * @returns {string} formatted text representation
113
+ * @param {object} region an object that allows internationalization of the time
114
+ * @returns {string} formatted text representation
115
115
  */
116
116
  export function formatDurationWithSeconds(seconds, region) {
117
117
  return formatDurationLikeMoment(seconds, { enabled: true, code: region });