@opentripplanner/core-utils 15.0.0 → 16.0.0

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.
Files changed (58) hide show
  1. package/esm/index.js +3 -0
  2. package/esm/index.js.map +1 -1
  3. package/esm/itinerary.js +95 -78
  4. package/esm/itinerary.js.map +1 -1
  5. package/esm/map.js +2 -2
  6. package/esm/map.js.map +1 -1
  7. package/esm/query-gen.js +9 -5
  8. package/esm/query-gen.js.map +1 -1
  9. package/esm/route.js +26 -20
  10. package/esm/route.js.map +1 -1
  11. package/esm/storage.js +4 -1
  12. package/esm/storage.js.map +1 -1
  13. package/esm/time.js +6 -5
  14. package/esm/time.js.map +1 -1
  15. package/esm/ui.js +4 -2
  16. package/esm/ui.js.map +1 -1
  17. package/lib/index.d.ts.map +1 -1
  18. package/lib/index.js +6 -0
  19. package/lib/index.js.map +1 -1
  20. package/lib/itinerary.d.ts +17 -11
  21. package/lib/itinerary.d.ts.map +1 -1
  22. package/lib/itinerary.js +89 -84
  23. package/lib/itinerary.js.map +1 -1
  24. package/lib/map.d.ts +2 -2
  25. package/lib/map.d.ts.map +1 -1
  26. package/lib/map.js +1 -1
  27. package/lib/map.js.map +1 -1
  28. package/lib/query-gen.d.ts +1 -19
  29. package/lib/query-gen.d.ts.map +1 -1
  30. package/lib/query-gen.js +9 -5
  31. package/lib/query-gen.js.map +1 -1
  32. package/lib/route.d.ts +10 -8
  33. package/lib/route.d.ts.map +1 -1
  34. package/lib/route.js +22 -16
  35. package/lib/route.js.map +1 -1
  36. package/lib/storage.d.ts +1 -1
  37. package/lib/storage.d.ts.map +1 -1
  38. package/lib/storage.js +4 -1
  39. package/lib/storage.js.map +1 -1
  40. package/lib/time.d.ts +3 -1
  41. package/lib/time.d.ts.map +1 -1
  42. package/lib/time.js +5 -4
  43. package/lib/time.js.map +1 -1
  44. package/lib/ui.d.ts.map +1 -1
  45. package/lib/ui.js +4 -2
  46. package/lib/ui.js.map +1 -1
  47. package/package.json +9 -7
  48. package/src/__tests__/itinerary.ts +55 -5
  49. package/src/index.ts +3 -0
  50. package/src/itinerary.ts +134 -97
  51. package/src/map.ts +5 -3
  52. package/src/query-gen.ts +15 -9
  53. package/src/route.ts +65 -38
  54. package/src/storage.ts +8 -2
  55. package/src/time.ts +7 -6
  56. package/src/ui.ts +8 -6
  57. package/tsconfig.json +1 -0
  58. package/tsconfig.tsbuildinfo +1 -1
package/esm/index.js CHANGED
@@ -1,7 +1,10 @@
1
1
  import * as itinerary from "./itinerary";
2
2
  import * as map from "./map";
3
+ // @ts-expect-error not typed
3
4
  import * as profile from "./profile";
5
+ // @ts-expect-error not typed
4
6
  import * as query from "./query";
7
+ // @ts-expect-error not typed
5
8
  import * as queryParams from "./query-params";
6
9
  import * as route from "./route";
7
10
  import * as storage from "./storage";
package/esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["itinerary","map","profile","query","queryParams","route","storage","time","ui","queryGen","SafeSuspense","core"],"sources":["../src/index.ts"],"sourcesContent":["import * as itinerary from \"./itinerary\";\nimport * as map from \"./map\";\nimport * as profile from \"./profile\";\nimport * as query from \"./query\";\nimport * as queryParams from \"./query-params\";\nimport * as route from \"./route\";\nimport * as storage from \"./storage\";\nimport * as time from \"./time\";\nimport * as ui from \"./ui\";\nimport * as queryGen from \"./query-gen\";\nimport SafeSuspense from \"./suspense\";\n\nconst core = {\n itinerary,\n map,\n profile,\n query,\n queryGen,\n queryParams,\n route,\n storage,\n time,\n ui\n};\n\nexport { SafeSuspense };\nexport default core;\n"],"mappings":"AAAA,OAAO,KAAKA,SAAS,MAAM,aAAa;AACxC,OAAO,KAAKC,GAAG,MAAM,OAAO;AAC5B,OAAO,KAAKC,OAAO,MAAM,WAAW;AACpC,OAAO,KAAKC,KAAK,MAAM,SAAS;AAChC,OAAO,KAAKC,WAAW,MAAM,gBAAgB;AAC7C,OAAO,KAAKC,KAAK,MAAM,SAAS;AAChC,OAAO,KAAKC,OAAO,MAAM,WAAW;AACpC,OAAO,KAAKC,IAAI,MAAM,QAAQ;AAC9B,OAAO,KAAKC,EAAE,MAAM,MAAM;AAC1B,OAAO,KAAKC,QAAQ,MAAM,aAAa;AACvC,OAAOC,YAAY,MAAM,YAAY;AAErC,IAAMC,IAAI,GAAG;EACXX,SAAS,EAATA,SAAS;EACTC,GAAG,EAAHA,GAAG;EACHC,OAAO,EAAPA,OAAO;EACPC,KAAK,EAALA,KAAK;EACLM,QAAQ,EAARA,QAAQ;EACRL,WAAW,EAAXA,WAAW;EACXC,KAAK,EAALA,KAAK;EACLC,OAAO,EAAPA,OAAO;EACPC,IAAI,EAAJA,IAAI;EACJC,EAAE,EAAFA;AACF,CAAC;AAED,SAASE,YAAY;AACrB,eAAeC,IAAI","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["itinerary","map","profile","query","queryParams","route","storage","time","ui","queryGen","SafeSuspense","core"],"sources":["../src/index.ts"],"sourcesContent":["import * as itinerary from \"./itinerary\";\nimport * as map from \"./map\";\n// @ts-expect-error not typed\nimport * as profile from \"./profile\";\n// @ts-expect-error not typed\nimport * as query from \"./query\";\n// @ts-expect-error not typed\nimport * as queryParams from \"./query-params\";\nimport * as route from \"./route\";\nimport * as storage from \"./storage\";\nimport * as time from \"./time\";\nimport * as ui from \"./ui\";\nimport * as queryGen from \"./query-gen\";\nimport SafeSuspense from \"./suspense\";\n\nconst core = {\n itinerary,\n map,\n profile,\n query,\n queryGen,\n queryParams,\n route,\n storage,\n time,\n ui\n};\n\nexport { SafeSuspense };\nexport default core;\n"],"mappings":"AAAA,OAAO,KAAKA,SAAS,MAAM,aAAa;AACxC,OAAO,KAAKC,GAAG,MAAM,OAAO;AAC5B;AACA,OAAO,KAAKC,OAAO,MAAM,WAAW;AACpC;AACA,OAAO,KAAKC,KAAK,MAAM,SAAS;AAChC;AACA,OAAO,KAAKC,WAAW,MAAM,gBAAgB;AAC7C,OAAO,KAAKC,KAAK,MAAM,SAAS;AAChC,OAAO,KAAKC,OAAO,MAAM,WAAW;AACpC,OAAO,KAAKC,IAAI,MAAM,QAAQ;AAC9B,OAAO,KAAKC,EAAE,MAAM,MAAM;AAC1B,OAAO,KAAKC,QAAQ,MAAM,aAAa;AACvC,OAAOC,YAAY,MAAM,YAAY;AAErC,IAAMC,IAAI,GAAG;EACXX,SAAS,EAATA,SAAS;EACTC,GAAG,EAAHA,GAAG;EACHC,OAAO,EAAPA,OAAO;EACPC,KAAK,EAALA,KAAK;EACLM,QAAQ,EAARA,QAAQ;EACRL,WAAW,EAAXA,WAAW;EACXC,KAAK,EAALA,KAAK;EACLC,OAAO,EAAPA,OAAO;EACPC,IAAI,EAAJA,IAAI;EACJC,EAAE,EAAFA;AACF,CAAC;AAED,SAASE,YAAY;AACrB,eAAeC,IAAI","ignoreList":[]}
package/esm/itinerary.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import _typeof from "@babel/runtime/helpers/typeof";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
4
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
4
5
  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; }
5
6
  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; }
@@ -58,10 +59,11 @@ export function legContainsGeometry(leg) {
58
59
  }
59
60
  export function isAdvanceBookingRequired(info) {
60
61
  var _info$latestBookingTi;
61
- return (info === null || info === void 0 || (_info$latestBookingTi = info.latestBookingTime) === null || _info$latestBookingTi === void 0 ? void 0 : _info$latestBookingTi.daysPrior) > 0;
62
+ var daysPrior = info === null || info === void 0 || (_info$latestBookingTi = info.latestBookingTime) === null || _info$latestBookingTi === void 0 ? void 0 : _info$latestBookingTi.daysPrior;
63
+ return typeof daysPrior === "number" && daysPrior > 0;
62
64
  }
63
65
  export function legDropoffRequiresAdvanceBooking(leg) {
64
- return isAdvanceBookingRequired(leg === null || leg === void 0 ? void 0 : leg.dropOffBookingInfo);
66
+ return isAdvanceBookingRequired(leg.dropOffBookingInfo);
65
67
  }
66
68
 
67
69
  /**
@@ -166,6 +168,7 @@ export function hasRental(modesStr) {
166
168
  });
167
169
  }
168
170
  export function getMapColor(mode) {
171
+ // @ts-expect-error this is not typed
169
172
  mode = mode || this.get("mode");
170
173
  if (mode === "WALK") return "#444";
171
174
  if (mode === "BICYCLE") return "#0073e5";
@@ -199,14 +202,15 @@ export function getCompanyFromLeg(leg) {
199
202
  rentedCar = leg.rentedCar,
200
203
  rentedVehicle = leg.rentedVehicle,
201
204
  rideHailingEstimate = leg.rideHailingEstimate;
205
+ var firstNetwork = Array.isArray(from.networks) && from.networks.length > 0 ? from.networks[0] : null;
202
206
  if (mode === "CAR" && rentedCar) {
203
- return from.networks[0];
207
+ return firstNetwork;
204
208
  }
205
209
  if (mode === "CAR" && rideHailingEstimate) {
206
210
  return rideHailingEstimate.provider.id;
207
211
  }
208
- if (mode === "BICYCLE" && rentedBike && from.networks) {
209
- return from.networks[0];
212
+ if (mode === "BICYCLE" && rentedBike) {
213
+ return firstNetwork;
210
214
  }
211
215
  if (from.rentalVehicle) {
212
216
  return from.rentalVehicle.network;
@@ -214,8 +218,8 @@ export function getCompanyFromLeg(leg) {
214
218
  if ((_from$vehicleRentalSt = from.vehicleRentalStation) !== null && _from$vehicleRentalSt !== void 0 && _from$vehicleRentalSt.rentalNetwork) {
215
219
  return from.vehicleRentalStation.rentalNetwork.networkId;
216
220
  }
217
- if ((mode === "MICROMOBILITY" || mode === "SCOOTER") && rentedVehicle && from.networks) {
218
- return from.networks[0];
221
+ if ((mode === "MICROMOBILITY" || mode === "SCOOTER") && rentedVehicle) {
222
+ return firstNetwork;
219
223
  }
220
224
  return null;
221
225
  }
@@ -225,7 +229,7 @@ export function getItineraryBounds(itinerary) {
225
229
  var legCoords = polyline.toGeoJSON(leg.legGeometry.points).coordinates.map(function (c) {
226
230
  return [c[1], c[0]];
227
231
  });
228
- coords = [].concat(_toConsumableArray(coords), _toConsumableArray(legCoords));
232
+ coords.push.apply(coords, _toConsumableArray(legCoords));
229
233
  });
230
234
  return coords;
231
235
  }
@@ -248,51 +252,50 @@ export function getLegBounds(leg) {
248
252
  }
249
253
 
250
254
  /* Returns an interpolated lat-lon at a specified distance along a leg */
251
-
252
255
  export function legLocationAtDistance(leg, distance) {
253
- if (!leg.legGeometry) return null;
256
+ if (!leg.legGeometry) return undefined;
254
257
  try {
258
+ var _pt$geometry;
255
259
  var line = polyline.toGeoJSON(leg.legGeometry.points);
256
260
  var pt = turfAlong(line, distance, {
257
261
  units: "meters"
258
262
  });
259
- if (pt && pt.geometry && pt.geometry.coordinates) {
260
- return [pt.geometry.coordinates[1], pt.geometry.coordinates[0]];
261
- }
262
- } catch (e) {
263
- // FIXME handle error!
263
+ var coords = pt === null || pt === void 0 || (_pt$geometry = pt.geometry) === null || _pt$geometry === void 0 ? void 0 : _pt$geometry.coordinates;
264
+ return [coords[1], coords[0]];
265
+ } catch (_unused) {
266
+ // This is designed to catch the toGeoJSON from throwing if the geometry is not in the correct format
264
267
  }
265
268
  return null;
266
269
  }
267
270
 
268
- /* Returns an interpolated elevation at a specified distance along a leg */
271
+ /**
272
+ * Returns an interpolated elevation at a specified distance along a leg
273
+ * @param points - The points of the elevation profile. Each point is a tuple of [distance, elevation].
274
+ * @param distance - The distance along the leg to interpolate the elevation at
275
+ * @returns The interpolated elevation at the specified distance
276
+ */
269
277
 
270
278
  export function legElevationAtDistance(points, distance) {
271
- // Iterate through the combined elevation profile
272
- var traversed = 0;
273
- // If first point distance is not zero, insert starting point at zero with
274
- // null elevation. Encountering this value should trigger the warning below.
275
- if (points[0][0] > 0) {
276
- points.unshift([0, null]);
277
- }
278
- for (var i = 1; i < points.length; i++) {
279
- var start = points[i - 1];
280
- var elevDistanceSpan = points[i][0] - start[0];
281
- if (distance >= traversed && distance <= traversed + elevDistanceSpan) {
282
- // Distance falls within this point and the previous one;
283
- // compute & return interpolated elevation value
284
- if (start[1] === null) {
285
- console.warn("Elevation value does not exist for distance.", distance, traversed);
286
- return null;
287
- }
288
- var pct = (distance - traversed) / elevDistanceSpan;
289
- var elevSpan = points[i][1] - start[1];
290
- return start[1] + elevSpan * pct;
279
+ var elevation = points.reduce(function (acc, point, index) {
280
+ var prevPoint = points[index - 1];
281
+ // at the first index there is no previous point
282
+ if (!prevPoint) return acc;
283
+ var _point = _slicedToArray(point, 2),
284
+ pointDistance = _point[0],
285
+ pointElevation = _point[1];
286
+ var _prevPoint = _slicedToArray(prevPoint, 2),
287
+ prevPointDistance = _prevPoint[0],
288
+ prevPointElevation = _prevPoint[1];
289
+ if (distance >= prevPointDistance && distance <= pointDistance) {
290
+ return prevPointElevation + (pointElevation - prevPointElevation) * (distance - prevPointDistance) / (pointDistance - prevPointDistance);
291
291
  }
292
- traversed += elevDistanceSpan;
292
+ return acc;
293
+ }, undefined);
294
+ if (elevation === undefined) {
295
+ console.warn("Elevation value does not exist for distance.", distance);
296
+ return undefined;
293
297
  }
294
- console.warn("Elevation value does not exist for distance.", distance, traversed);
295
- return null;
298
+ return elevation;
296
299
  }
297
300
  export function mapOldElevationComponentToNew(oldElev) {
298
301
  return {
@@ -365,6 +368,7 @@ export function getTextWidth(text) {
365
368
  // reuse canvas object for better performance
366
369
  var canvas = getTextWidth.canvas || (getTextWidth.canvas = document.createElement("canvas"));
367
370
  var context = canvas.getContext("2d");
371
+ if (!context) return 0;
368
372
  context.font = font;
369
373
  var metrics = context.measureText(text);
370
374
  return metrics.width;
@@ -430,18 +434,16 @@ export function calculatePhysicalActivity(itinerary) {
430
434
  */
431
435
  export function calculateTncFares(itinerary) {
432
436
  return itinerary.legs.filter(function (leg) {
433
- return leg.mode === "CAR" && leg.rideHailingEstimate;
434
- }).reduce(function (_ref, _ref2) {
435
- var maxTNCFare = _ref.maxTNCFare,
436
- minTNCFare = _ref.minTNCFare;
437
- var rideHailingEstimate = _ref2.rideHailingEstimate;
438
- var minPrice = rideHailingEstimate.minPrice,
439
- maxPrice = rideHailingEstimate.maxPrice;
437
+ return leg.mode === "CAR" && leg.rideHailingEstimate !== undefined;
438
+ }).reduce(function (acc, leg) {
439
+ var _leg$rideHailingEstim2 = leg.rideHailingEstimate,
440
+ minPrice = _leg$rideHailingEstim2.minPrice,
441
+ maxPrice = _leg$rideHailingEstim2.maxPrice;
440
442
  return {
441
443
  // Assumes a single currency for entire itinerary.
442
444
  currencyCode: minPrice.currency.code,
443
- maxTNCFare: maxTNCFare + maxPrice.amount,
444
- minTNCFare: minTNCFare + minPrice.amount
445
+ maxTNCFare: acc.maxTNCFare + maxPrice.amount,
446
+ minTNCFare: acc.minTNCFare + minPrice.amount
445
447
  };
446
448
  }, {
447
449
  currencyCode: null,
@@ -539,7 +541,6 @@ export var zeroDollars = function zeroDollars(currency) {
539
541
  currency: currency
540
542
  };
541
543
  };
542
-
543
544
  /**
544
545
  * Extracts useful data from the fare products on a leg, such as the leg cost and transfer info.
545
546
  * @param leg Leg with Fares v2 information
@@ -555,9 +556,9 @@ export function getLegCost(leg, mediumId, riderCategoryId, seenFareIds) {
555
556
  if (!leg.fareProducts) return {
556
557
  price: undefined
557
558
  };
558
- var relevantFareProducts = leg.fareProducts.filter(function (_ref3) {
559
+ var relevantFareProducts = leg.fareProducts.filter(function (_ref) {
559
560
  var _product$riderCategor, _product$riderCategor2, _product$medium, _product$medium2;
560
- var product = _ref3.product;
561
+ var product = _ref.product;
561
562
  // riderCategory and medium can be specifically defined as null to handle
562
563
  // generic GTFS based fares from OTP when there is no fare model
563
564
 
@@ -567,13 +568,18 @@ export function getLegCost(leg, mediumId, riderCategoryId, seenFareIds) {
567
568
  return productRiderCategoryId === riderCategoryId && productMediaId === mediumId && (// Make sure there's a price
568
569
  // Some fare products don't have a price at all.
569
570
  product === null || product === void 0 ? void 0 : product.price);
571
+ })
572
+ // Make sure there's a price
573
+ // Some fare products don't have a price at all.
574
+ .filter(function (fare) {
575
+ var _fare$product;
576
+ return ((_fare$product = fare.product) === null || _fare$product === void 0 ? void 0 : _fare$product.price) !== undefined;
570
577
  }).map(function (fare) {
571
- var alreadySeen = (seenFareIds === null || seenFareIds === void 0 ? void 0 : seenFareIds.indexOf(fare.id)) > -1;
572
- var currency = fare.product.price.currency;
578
+ var alreadySeen = !!seenFareIds && (seenFareIds === null || seenFareIds === void 0 ? void 0 : seenFareIds.indexOf(fare.id)) > -1;
573
579
  return {
574
580
  id: fare.id,
575
581
  product: _objectSpread(_objectSpread({}, fare.product), {}, {
576
- legPrice: alreadySeen ? zeroDollars(currency) : fare.product.price
582
+ legPrice: alreadySeen && fare.product.price ? zeroDollars(fare.product.price.currency) : fare.product.price
577
583
  })
578
584
  };
579
585
  }).sort(function (a, b) {
@@ -607,34 +613,40 @@ export function getLegCost(leg, mediumId, riderCategoryId, seenFareIds) {
607
613
  * @returns Money object for the total itinerary cost.
608
614
  */
609
615
  export function getItineraryCost(legs, mediumId, riderCategoryId) {
610
- // TODO: Better input type handling
611
616
  if (Array.isArray(mediumId) || Array.isArray(riderCategoryId)) {
612
- if ((mediumId === null || mediumId === void 0 ? void 0 : mediumId.length) !== riderCategoryId.length) {
613
- console.warn("Invalid input types, only using first item. medium id list and rider category list must have same number of items");
614
- return getItineraryCost(legs, mediumId[0], riderCategoryId[0]);
615
- }
616
- var total = {
617
- amount: 0,
618
- currency: null
619
- };
620
- for (var i = 0; i < mediumId.length; i++) {
621
- var newCost = getItineraryCost(legs, mediumId[i], riderCategoryId[i]);
622
- if (newCost) {
623
- var _total, _total$currency;
624
- total = {
625
- amount: ((_total = total) === null || _total === void 0 ? void 0 : _total.amount) + ((newCost === null || newCost === void 0 ? void 0 : newCost.amount) || 0),
626
- currency: (_total$currency = total.currency) !== null && _total$currency !== void 0 ? _total$currency : newCost === null || newCost === void 0 ? void 0 : newCost.currency
627
- };
617
+ // TODO: Better input type handling
618
+ if (Array.isArray(mediumId) && Array.isArray(riderCategoryId)) {
619
+ var _total$currency;
620
+ if (mediumId.length !== riderCategoryId.length) {
621
+ console.warn("Invalid input types, only using first item. medium id list and rider category list must have same number of items");
622
+ return getItineraryCost(legs, mediumId[0], riderCategoryId[0]);
628
623
  }
624
+ var total = mediumId.reduce(function (acc, currentMediumId, index) {
625
+ var _newCost$currency;
626
+ var newCost = getItineraryCost(legs, currentMediumId, riderCategoryId[index]);
627
+ if (!newCost) return acc;
628
+ return {
629
+ amount: acc.amount + (newCost.amount || 0),
630
+ currency: acc.currency.code !== "" ? acc.currency : (_newCost$currency = newCost.currency) !== null && _newCost$currency !== void 0 ? _newCost$currency : acc.currency
631
+ };
632
+ }, {
633
+ amount: 0,
634
+ currency: {
635
+ code: "",
636
+ digits: 0
637
+ }
638
+ });
639
+ if (!((_total$currency = total.currency) !== null && _total$currency !== void 0 && _total$currency.code)) return undefined;
640
+ return total;
629
641
  }
630
- if (total.currency === null) return undefined;
631
- return total;
642
+ console.warn("Invalid input types, only using first item. medium id list and rider category list must have same number of items");
643
+ return undefined;
632
644
  }
633
645
  var legCosts = legs
634
646
  // Only legs with fares (no walking legs)
635
647
  .filter(function (leg) {
636
648
  var _leg$fareProducts;
637
- return ((_leg$fareProducts = leg.fareProducts) === null || _leg$fareProducts === void 0 ? void 0 : _leg$fareProducts.length) > 0;
649
+ return ((_leg$fareProducts = leg.fareProducts) === null || _leg$fareProducts === void 0 ? void 0 : _leg$fareProducts.length) && leg.fareProducts.length > 0;
638
650
  })
639
651
  // Get the leg cost object of each leg
640
652
  .reduce(function (acc, leg) {
@@ -646,6 +658,7 @@ export function getItineraryCost(legs, mediumId, riderCategoryId) {
646
658
  appliedFareProduct = _getLegCost.appliedFareProduct,
647
659
  productUseId = _getLegCost.productUseId;
648
660
  if (!appliedFareProduct) return acc;
661
+ if (!productUseId) return acc;
649
662
  return {
650
663
  legCosts: [].concat(_toConsumableArray(acc.legCosts), [appliedFareProduct]),
651
664
  seenIds: [].concat(_toConsumableArray(acc.seenIds), [productUseId])
@@ -659,14 +672,18 @@ export function getItineraryCost(legs, mediumId, riderCategoryId) {
659
672
  if (legCosts.length === 0) return undefined;
660
673
  // Calculate the total
661
674
  return legCosts.reduce(function (prev, cur) {
662
- var _prev$currency;
663
675
  return {
664
676
  amount: prev.amount + (cur === null || cur === void 0 ? void 0 : cur.amount) || 0,
665
- currency: (_prev$currency = prev.currency) !== null && _prev$currency !== void 0 ? _prev$currency : cur === null || cur === void 0 ? void 0 : cur.currency
677
+ currency: prev.currency.code !== "" ? prev.currency : cur.currency
666
678
  };
667
- }, {
679
+ },
680
+ // eslint-disable-next-line prettier/prettier -- old eslint doesn't know satisfies
681
+ {
668
682
  amount: 0,
669
- currency: null
683
+ currency: {
684
+ code: "",
685
+ digits: 0
686
+ }
670
687
  });
671
688
  }
672
689
  var pickupDropoffTypeToOtp1 = function pickupDropoffTypeToOtp1(otp2Type) {
@@ -1 +1 @@
1
- {"version":3,"file":"itinerary.js","names":["polyline","turfAlong","transitModes","getTransitModes","config","modes","map","tm","mode","isTransitLeg","leg","transitLeg","isTransit","includes","isReservationRequired","boardRule","alightRule","isCoordinationRequired","containsGeometry","place","_place$stop","_place$stop2","stop","geometries","undefined","endsWithGeometry","to","startsWithGeometry","from","legContainsGeometry","isAdvanceBookingRequired","info","_info$latestBookingTi","latestBookingTime","daysPrior","legDropoffRequiresAdvanceBooking","dropOffBookingInfo","isFlex","_leg$stopCalls","stopCalls","some","call","_call$stopLocation","stopLocation","__typename","startsWith","isRideshareLeg","_leg$rideHailingEstim","rideHailingEstimate","provider","id","isWalk","isBicycle","isBicycleRent","isCar","isMicromobility","isAccessMode","hasTransit","modesStr","split","hasCar","hasBike","hasMicromobility","hasHail","indexOf","hasRental","getMapColor","get","toSentenceCase","str","String","charAt","toUpperCase","substr","toLowerCase","getCompanyFromLeg","_from$vehicleRentalSt","rentedBike","rentedCar","rentedVehicle","networks","rentalVehicle","network","vehicleRentalStation","rentalNetwork","networkId","getItineraryBounds","itinerary","coords","legs","forEach","legCoords","toGeoJSON","legGeometry","points","coordinates","c","concat","_toConsumableArray","getLegBounds","length","push","lat","lon","legLocationAtDistance","distance","line","pt","units","geometry","e","legElevationAtDistance","traversed","unshift","i","start","elevDistanceSpan","console","warn","pct","elevSpan","mapOldElevationComponentToNew","oldElev","first","elevation","second","getElevationProfile","steps","unitConversion","arguments","minElev","maxElev","gain","loss","previous","step","_step$elevation","stepElevationProfile","elevationProfile","Array","isArray","elev","diff","convertedElevation","getTextWidth","text","font","canvas","document","createElement","context","getContext","metrics","measureText","width","getCompanyForNetwork","networkString","companies","company","find","co","getCompaniesLabelFromNetworks","filter","label","join","getTNCLocation","type","location","toFixed","calculatePhysicalActivity","walkDuration","bikeDuration","duration","caloriesBurned","calculateTncFares","reduce","_ref","_ref2","maxTNCFare","minTNCFare","minPrice","maxPrice","currencyCode","currency","code","amount","CARBON_INTENSITY_DEFAULTS","walk","bicycle","car","tram","trolleybus","subway","rail","bus","ferry","cable_car","gondola","funicular","transit","leg_switch","airplane","micromobility","calculateEmissions","_itinerary$legs","carbonIntensity","carbonIntensityWithDefaults","_objectSpread","totalCarbon","total","getDisplayedStopCode","placeOrStop","_placeOrStop$stopCode","stopCode","_placeOrStop$code","descope","item","index","substring","zeroDollars","getLegCost","mediumId","riderCategoryId","seenFareIds","fareProducts","price","relevantFareProducts","_ref3","_product$riderCategor","_product$riderCategor2","_product$medium","_product$medium2","product","productRiderCategoryId","riderCategory","productMediaId","medium","fare","alreadySeen","legPrice","sort","a","b","_a$product","_b$product","cheapestRelevantFareProduct","alternateFareProducts","splice","fp","appliedFareProduct","isDependent","productUseId","getItineraryCost","newCost","_total","_total$currency","legCosts","_leg$fareProducts","acc","_getLegCost","seenIds","lc","prev","cur","_prev$currency","pickupDropoffTypeToOtp1","otp2Type","convertGraphQLResponseToLegacy","_leg$agency","_leg$agency2","_leg$agency3","_leg$agency4","_leg$from$stop","_leg$from$stop2","_leg$route","_leg$route2","_leg$route3","_leg$route4","_leg$route5","_leg$route6","_leg$to$stop","_leg$to$stop2","_leg$trip","_leg$trip2","agencyBrandingUrl","agency","url","agencyId","agencyName","name","agencyUrl","dropoffType","pickupType","bookingRuleInfo","dropOff","pickUp","pickupBookingInfo","stopId","gtfsId","route","shortName","routeColor","color","routeId","routeLongName","longName","routeShortName","routeTextColor","textColor","tripHeadsign","trip","tripId","getLegRouteShortName","_typeof","getLegRouteLongName","getLegRouteName"],"sources":["../src/itinerary.ts"],"sourcesContent":["import polyline from \"@mapbox/polyline\";\nimport {\n AppliedFareProduct,\n Company,\n Config,\n Currency,\n ElevationProfile,\n ElevationProfileComponent,\n FlexBookingInfo,\n ItineraryOnlyLegsRequired,\n LatLngArray,\n Leg,\n MassUnitOption,\n Money,\n Place,\n Step,\n Stop,\n TncFare\n} from \"@opentripplanner/types\";\nimport turfAlong from \"@turf/along\";\n\n// All OTP transit modes\nexport const transitModes = [\n \"TRAM\",\n \"TROLLEYBUS\",\n \"BUS\",\n \"SUBWAY\",\n \"FERRY\",\n \"RAIL\",\n \"GONDOLA\"\n];\n\n/**\n * @param {config} config OTP-RR configuration object\n * @return {Array} List of all transit modes defined in config; otherwise default mode list\n */\n\nexport function getTransitModes(config: Config): string[] {\n if (!config || !config.modes || !config.modes.transitModes)\n return transitModes;\n\n return config.modes.transitModes.map(tm =>\n typeof tm !== \"string\" ? tm.mode : tm\n );\n}\n\nexport function isTransitLeg(leg: Leg): boolean {\n return leg.transitLeg;\n}\n\nexport function isTransit(mode: string): boolean {\n return transitModes.includes(mode) || mode === \"TRANSIT\";\n}\n\n/**\n * Returns true if the leg pickup rules enabled which require\n * calling ahead for the service to run. \"mustPhone\" is the only\n * property which encodes this info.\n */\nexport function isReservationRequired(leg: Leg): boolean {\n return leg?.boardRule === \"mustPhone\" || leg?.alightRule === \"mustPhone\";\n}\n/**\n * Returns true if a user must ask the driver to let the user off\n * or if the user must flag the driver down for pickup.\n * \"coordinateWithDriver\" in board/alight rule encodes this info.\n */\nexport function isCoordinationRequired(leg: Leg): boolean {\n return (\n leg?.boardRule === \"coordinateWithDriver\" ||\n leg?.alightRule === \"coordinateWithDriver\"\n );\n}\n\nexport function containsGeometry(place: Place): boolean {\n return (\n place?.stop?.geometries !== null && place?.stop?.geometries !== undefined\n );\n}\nexport function endsWithGeometry(leg: Leg): boolean {\n return containsGeometry(leg?.to);\n}\nexport function startsWithGeometry(leg: Leg): boolean {\n return containsGeometry(leg?.from);\n}\nexport function legContainsGeometry(leg: Leg): boolean {\n return endsWithGeometry(leg) || startsWithGeometry(leg);\n}\nexport function isAdvanceBookingRequired(info: FlexBookingInfo): boolean {\n return info?.latestBookingTime?.daysPrior > 0;\n}\nexport function legDropoffRequiresAdvanceBooking(leg: Leg): boolean {\n return isAdvanceBookingRequired(leg?.dropOffBookingInfo);\n}\n\n/**\n * The two rules checked by the above two functions are the only values\n * returned by OTP when a leg is a flex leg.\n */\nexport function isFlex(leg: Leg): boolean {\n return (\n leg?.stopCalls?.some(call =>\n // Flex calls are \"Location\" or \"LocationGroup\"\n // eslint-disable-next-line no-underscore-dangle\n call?.stopLocation?.__typename.startsWith(\"Location\")\n ) || false\n );\n}\nexport function isRideshareLeg(leg: Leg): boolean {\n return !!leg.rideHailingEstimate?.provider?.id;\n}\n\nexport function isWalk(mode: string): boolean {\n if (!mode) return false;\n\n return mode === \"WALK\";\n}\n\nexport function isBicycle(mode: string): boolean {\n if (!mode) return false;\n\n return mode === \"BICYCLE\";\n}\n\nexport function isBicycleRent(mode: string): boolean {\n if (!mode) return false;\n\n return mode === \"BICYCLE_RENT\";\n}\n\nexport function isCar(mode: string): boolean {\n if (!mode) return false;\n return mode.startsWith(\"CAR\");\n}\n\nexport function isMicromobility(mode: string): boolean {\n if (!mode) return false;\n return mode.startsWith(\"MICROMOBILITY\") || mode.startsWith(\"SCOOTER\");\n}\n\nexport function isAccessMode(mode: string): boolean {\n return (\n isWalk(mode) ||\n isBicycle(mode) ||\n isBicycleRent(mode) ||\n isCar(mode) ||\n isMicromobility(mode)\n );\n}\n\n/**\n * @param {string} modesStr a comma-separated list of OTP modes\n * @return {boolean} whether any of the modes are transit modes\n */\nexport function hasTransit(modesStr: string): boolean {\n return modesStr.split(\",\").some(mode => isTransit(mode));\n}\n\n/**\n * @param {string} modesStr a comma-separated list of OTP modes\n * @return {boolean} whether any of the modes are car-based modes\n */\nexport function hasCar(modesStr: string): boolean {\n return modesStr.split(\",\").some(mode => isCar(mode));\n}\n\n/**\n * @param {string} modesStr a comma-separated list of OTP modes\n * @return {boolean} whether any of the modes are bicycle-based modes\n */\nexport function hasBike(modesStr: string): boolean {\n return modesStr\n .split(\",\")\n .some(mode => isBicycle(mode) || isBicycleRent(mode));\n}\n\n/**\n * @param {string} modesStr a comma-separated list of OTP modes\n * @return {boolean} whether any of the modes are micromobility-based modes\n */\nexport function hasMicromobility(modesStr: string): boolean {\n return modesStr.split(\",\").some(mode => isMicromobility(mode));\n}\n\n/**\n * @param {string} modesStr a comma-separated list of OTP modes\n * @return {boolean} whether any of the modes is a hailing mode\n */\nexport function hasHail(modesStr: string): boolean {\n return modesStr.split(\",\").some(mode => mode.indexOf(\"_HAIL\") > -1);\n}\n\n/**\n * @param {string} modesStr a comma-separated list of OTP modes\n * @return {boolean} whether any of the modes is a rental mode\n */\nexport function hasRental(modesStr: string): boolean {\n return modesStr.split(\",\").some(mode => mode.indexOf(\"_RENT\") > -1);\n}\n\nexport function getMapColor(mode: string): string {\n mode = mode || this.get(\"mode\");\n if (mode === \"WALK\") return \"#444\";\n if (mode === \"BICYCLE\") return \"#0073e5\";\n if (mode === \"SUBWAY\") return \"#e60000\";\n if (mode === \"RAIL\") return \"#b00\";\n if (mode === \"BUS\") return \"#080\";\n if (mode === \"TROLLEYBUS\") return \"#080\";\n if (mode === \"TRAM\") return \"#800\";\n if (mode === \"FERRY\") return \"#008\";\n if (mode === \"CAR\") return \"#444\";\n if (mode === \"MICROMOBILITY\" || mode === \"SCOOTER\") return \"#f5a729\";\n return \"#aaa\";\n}\n\nexport function toSentenceCase(str: string): string {\n if (str == null) {\n return \"\";\n }\n str = String(str);\n return str.charAt(0).toUpperCase() + str.substr(1).toLowerCase();\n}\n\n/**\n * Derive the company string based on mode and network associated with leg.\n */\nexport function getCompanyFromLeg(leg: Leg): string {\n if (!leg) return null;\n const {\n from,\n mode,\n rentedBike,\n rentedCar,\n rentedVehicle,\n rideHailingEstimate\n } = leg;\n if (mode === \"CAR\" && rentedCar) {\n return from.networks[0];\n }\n if (mode === \"CAR\" && rideHailingEstimate) {\n return rideHailingEstimate.provider.id;\n }\n if (mode === \"BICYCLE\" && rentedBike && from.networks) {\n return from.networks[0];\n }\n if (from.rentalVehicle) {\n return from.rentalVehicle.network;\n }\n if (from.vehicleRentalStation?.rentalNetwork) {\n return from.vehicleRentalStation.rentalNetwork.networkId;\n }\n if (\n (mode === \"MICROMOBILITY\" || mode === \"SCOOTER\") &&\n rentedVehicle &&\n from.networks\n ) {\n return from.networks[0];\n }\n return null;\n}\n\nexport function getItineraryBounds(\n itinerary: ItineraryOnlyLegsRequired\n): LatLngArray[] {\n let coords = [];\n itinerary.legs.forEach(leg => {\n const legCoords = polyline\n .toGeoJSON(leg.legGeometry.points)\n .coordinates.map((c: number[]) => [c[1], c[0]]);\n coords = [...coords, ...legCoords];\n });\n return coords;\n}\n\n/**\n * Return a coords object that encloses the given leg's geometry.\n */\nexport function getLegBounds(leg: Leg): number[][] {\n const coords = polyline\n .toGeoJSON(leg.legGeometry.points)\n .coordinates.map(c => [c[1], c[0]]);\n\n // in certain cases, there might be zero-length coordinates in the leg\n // geometry. In these cases, build us an array of coordinates using the from\n // and to data of the leg.\n if (coords.length === 0) {\n coords.push([leg.from.lat, leg.from.lon], [leg.to.lat, leg.to.lon]);\n }\n return coords;\n}\n\n/* Returns an interpolated lat-lon at a specified distance along a leg */\n\nexport function legLocationAtDistance(leg: Leg, distance: number): number[] {\n if (!leg.legGeometry) return null;\n\n try {\n const line = polyline.toGeoJSON(leg.legGeometry.points);\n const pt = turfAlong(line, distance, { units: \"meters\" });\n if (pt && pt.geometry && pt.geometry.coordinates) {\n return [pt.geometry.coordinates[1], pt.geometry.coordinates[0]];\n }\n } catch (e) {\n // FIXME handle error!\n }\n\n return null;\n}\n\n/* Returns an interpolated elevation at a specified distance along a leg */\n\nexport function legElevationAtDistance(\n points: number[][],\n distance: number\n): number {\n // Iterate through the combined elevation profile\n let traversed = 0;\n // If first point distance is not zero, insert starting point at zero with\n // null elevation. Encountering this value should trigger the warning below.\n if (points[0][0] > 0) {\n points.unshift([0, null]);\n }\n for (let i = 1; i < points.length; i++) {\n const start = points[i - 1];\n const elevDistanceSpan = points[i][0] - start[0];\n if (distance >= traversed && distance <= traversed + elevDistanceSpan) {\n // Distance falls within this point and the previous one;\n // compute & return interpolated elevation value\n if (start[1] === null) {\n console.warn(\n \"Elevation value does not exist for distance.\",\n distance,\n traversed\n );\n return null;\n }\n const pct = (distance - traversed) / elevDistanceSpan;\n const elevSpan = points[i][1] - start[1];\n return start[1] + elevSpan * pct;\n }\n traversed += elevDistanceSpan;\n }\n console.warn(\n \"Elevation value does not exist for distance.\",\n distance,\n traversed\n );\n return null;\n}\n\nexport function mapOldElevationComponentToNew(oldElev: {\n first: number;\n second: number;\n}): ElevationProfileComponent {\n return {\n distance: oldElev.first,\n elevation: oldElev.second\n };\n}\n\n// Iterate through the steps, building the array of elevation points and\n// keeping track of the minimum and maximum elevations reached\nexport function getElevationProfile(\n steps: Step[],\n unitConversion = 1\n): ElevationProfile {\n let minElev = 100000;\n let maxElev = -100000;\n let traversed = 0;\n let gain = 0;\n let loss = 0;\n let previous: ElevationProfileComponent | null = null;\n const points = [];\n steps.forEach(step => {\n // Support for old REST response data (in step.elevation)\n const stepElevationProfile =\n step.elevationProfile ||\n (Array.isArray(step.elevation) &&\n step.elevation?.map<ElevationProfileComponent>(\n mapOldElevationComponentToNew\n ));\n\n if (!stepElevationProfile || stepElevationProfile.length === 0) {\n traversed += step.distance;\n return;\n }\n for (let i = 0; i < stepElevationProfile.length; i++) {\n const elev = stepElevationProfile[i];\n if (previous) {\n const diff = (elev.elevation - previous.elevation) * unitConversion;\n if (diff > 0) gain += diff;\n else loss += diff;\n }\n if (i === 0 && elev.distance !== 0) {\n // console.warn(`No elevation data available for step ${stepIndex}-${i} at beginning of segment`, elev)\n }\n const convertedElevation = elev.elevation * unitConversion;\n if (convertedElevation < minElev) minElev = convertedElevation;\n if (convertedElevation > maxElev) maxElev = convertedElevation;\n points.push([traversed + elev.distance, elev.elevation]);\n // Insert \"filler\" point if the last point in elevation profile does not\n // reach the full distance of the step.\n if (\n i === stepElevationProfile.length - 1 &&\n elev.distance !== step.distance\n ) {\n // points.push([traversed + step.distance, elev.second])\n }\n previous = elev;\n }\n traversed += step.distance;\n });\n return { maxElev, minElev, points, traversed, gain, loss };\n}\n\n/**\n * Uses canvas.measureText to compute and return the width of the given text of given font in pixels.\n *\n * @param {string} text The text to be rendered.\n * @param {string} font The css font descriptor that text is to be rendered with (e.g. \"bold 14px verdana\").\n *\n * @see https://stackoverflow.com/questions/118241/calculate-text-width-with-javascript/21015393#21015393\n */\nexport function getTextWidth(text: string, font = \"22px Arial\"): number {\n // Create custom type for function including reused canvas object\n type GetTextWidth = typeof getTextWidth & { canvas: HTMLCanvasElement };\n\n // reuse canvas object for better performance\n const canvas =\n (getTextWidth as GetTextWidth).canvas ||\n ((getTextWidth as GetTextWidth).canvas = document.createElement(\"canvas\"));\n const context = canvas.getContext(\"2d\");\n context.font = font;\n const metrics = context.measureText(text);\n return metrics.width;\n}\n\n/**\n * Get the configured company object for the given network string if the company\n * has been defined in the provided companies array config.\n */\nexport function getCompanyForNetwork(\n networkString: string,\n companies: Company[] = []\n): Company {\n const company = companies.find(co => co.id === networkString);\n if (!company) {\n console.warn(\n `No company found in config.yml that matches rented vehicle network: ${networkString}`,\n companies\n );\n }\n return company;\n}\n\n/**\n * Get a string label to display from a list of vehicle rental networks. Returns\n * empty string if no networks provided.\n *\n * @param {Array<string>} networks A list of network ids.\n * @param {Array<object>} [companies=[]] An optional list of the companies config.\n * @return {string} A label for use in presentation on a website.\n */\nexport function getCompaniesLabelFromNetworks(\n networks?: string[] | string,\n companies: Company[] = []\n): string {\n if (!networks) return \"\";\n return (Array.isArray(networks) ? networks : [networks])\n .map(network => getCompanyForNetwork(network, companies))\n .filter(co => !!co)\n .map(co => co.label)\n .join(\"/\");\n}\n\nexport function getTNCLocation(leg: Leg, type: string): string {\n const location = leg[type];\n return `${location.lat.toFixed(5)},${location.lon.toFixed(5)}`;\n}\n\nexport function calculatePhysicalActivity(\n itinerary: ItineraryOnlyLegsRequired\n): {\n bikeDuration: number;\n caloriesBurned: number;\n walkDuration: number;\n} {\n let walkDuration = 0;\n let bikeDuration = 0;\n itinerary.legs.forEach(leg => {\n if (leg.mode.startsWith(\"WALK\")) walkDuration += leg.duration;\n if (leg.mode.startsWith(\"BICYCLE\")) bikeDuration += leg.duration;\n });\n const caloriesBurned =\n (walkDuration / 3600) * 280 + (bikeDuration / 3600) * 290;\n return {\n bikeDuration,\n caloriesBurned,\n walkDuration\n };\n}\n\n/**\n * For an itinerary, calculates the TNC fares and returns an object with\n * these values and currency info.\n * It is assumed that the same currency is used for all TNC legs.\n */\nexport function calculateTncFares(\n itinerary: ItineraryOnlyLegsRequired\n): TncFare {\n return itinerary.legs\n .filter(leg => leg.mode === \"CAR\" && leg.rideHailingEstimate)\n .reduce(\n ({ maxTNCFare, minTNCFare }, { rideHailingEstimate }) => {\n const { minPrice, maxPrice } = rideHailingEstimate;\n return {\n // Assumes a single currency for entire itinerary.\n currencyCode: minPrice.currency.code,\n maxTNCFare: maxTNCFare + maxPrice.amount,\n minTNCFare: minTNCFare + minPrice.amount\n };\n },\n {\n currencyCode: null,\n maxTNCFare: 0,\n minTNCFare: 0\n }\n );\n}\n\n/**\n * Sources:\n * - https://www.itf-oecd.org/sites/default/files/docs/environmental-performance-new-mobility.pdf\n * - https://www.thrustcarbon.com/insights/how-to-calculate-emissions-from-a-ferry-journey\n * - https://www.itf-oecd.org/sites/default/files/life-cycle-assessment-calculations-2020.xlsx\n * Other values extrapolated.\n */\nconst CARBON_INTENSITY_DEFAULTS = {\n walk: 0.026,\n bicycle: 0.017,\n car: 0.162,\n tram: 0.066,\n trolleybus: 0.066,\n subway: 0.066,\n rail: 0.066,\n bus: 0.09,\n ferry: 0.082,\n cable_car: 0.021,\n gondola: 0.021,\n funicular: 0.066,\n transit: 0.066,\n leg_switch: 0,\n airplane: 0.382,\n micromobility: 0.095\n};\n\n/**\n * @param {itinerary} itinerary OTP trip itinierary, only legs is required.\n * @param {carbonIntensity} carbonIntensity carbon intensity by mode in grams/meter\n * @param {units} units units to be used in return value\n * @return Amount of carbon in chosen unit\n */\nexport function calculateEmissions(\n // This type makes all the properties from Itinerary optional except legs.\n itinerary: ItineraryOnlyLegsRequired,\n carbonIntensity: Record<string, number> = {},\n units?: MassUnitOption\n): number {\n // Apply defaults for any values that we don't have.\n const carbonIntensityWithDefaults = {\n ...CARBON_INTENSITY_DEFAULTS,\n ...carbonIntensity\n };\n\n // Distance is in meters, totalCarbon is in grams\n const totalCarbon =\n itinerary?.legs?.reduce((total, leg) => {\n return (\n (leg.distance * carbonIntensityWithDefaults[leg.mode.toLowerCase()] ||\n 0) + total\n );\n }, 0) || 0;\n\n switch (units) {\n case \"ounce\":\n return totalCarbon / 28.35;\n case \"kilogram\":\n return totalCarbon / 1000;\n case \"pound\":\n return totalCarbon / 454;\n case \"gram\":\n default:\n return totalCarbon;\n }\n}\n\n/**\n * Returns the user-facing stop code to display for a stop or place\n */\nexport function getDisplayedStopCode(\n placeOrStop: Place | Stop\n): string | undefined {\n if (\"stopId\" in placeOrStop) {\n return placeOrStop.stopCode ?? undefined;\n }\n if (\"id\" in placeOrStop) {\n return placeOrStop.code ?? undefined;\n }\n return undefined;\n}\n\n/**\n * Removes the first part of the OTP standard scope (\":\"), if it is present.\n * @param item String that is potentially scoped with `:` character\n * @returns descoped string\n */\nexport const descope = (item?: string | null): string | null | undefined => {\n if (!item) return item;\n const index = item.indexOf(\":\");\n return index === -1 ? item : item.substring(index + 1);\n};\n\nexport type ExtendedMoney = Money & { originalAmount?: number };\n\nexport const zeroDollars = (currency: Currency): Money => ({\n amount: 0,\n currency\n});\n\n/**\n * Extracts useful data from the fare products on a leg, such as the leg cost and transfer info.\n * @param leg Leg with Fares v2 information\n * @param mediumId Desired medium ID to calculate fare for\n * @param riderCategoryId Desire rider category to calculate fare for\n * @param seenFareIds Fare IDs used on previous legs. Used to detect transfer discounts.\n * @returns Object containing price as well as transfer/dependent\n * fare information. `AppliedFareProduct` should contain\n * all the information needed, but the other fields are kept to\n * make the transition to Fares V2 less jarring.\n */\nexport function getLegCost(\n leg: Leg,\n mediumId?: string | null,\n riderCategoryId?: string | null,\n seenFareIds?: string[]\n): {\n alternateFareProducts?: AppliedFareProduct[];\n appliedFareProduct?: AppliedFareProduct;\n isDependent?: boolean;\n price?: Money;\n productUseId?: string;\n} {\n if (!leg.fareProducts) return { price: undefined };\n const relevantFareProducts = leg.fareProducts\n .filter(({ product }) => {\n // riderCategory and medium can be specifically defined as null to handle\n // generic GTFS based fares from OTP when there is no fare model\n\n // Remove (optional) agency scoping\n const productRiderCategoryId =\n descope(product?.riderCategory?.id) ||\n product?.riderCategory?.id ||\n null;\n\n const productMediaId =\n descope(product?.medium?.id) || product?.medium?.id || null;\n\n return (\n productRiderCategoryId === riderCategoryId &&\n productMediaId === mediumId &&\n // Make sure there's a price\n // Some fare products don't have a price at all.\n product?.price\n );\n })\n .map(fare => {\n const alreadySeen = seenFareIds?.indexOf(fare.id) > -1;\n const { currency } = fare.product.price;\n return {\n id: fare.id,\n product: {\n ...fare.product,\n legPrice: alreadySeen ? zeroDollars(currency) : fare.product.price\n } as AppliedFareProduct\n };\n })\n .sort((a, b) => a.product?.legPrice?.amount - b.product?.legPrice?.amount);\n\n // Return the cheapest, but include other matches as well\n const cheapestRelevantFareProduct = relevantFareProducts[0];\n\n // TODO: return one object here instead of dumbing it down?\n return {\n alternateFareProducts: relevantFareProducts.splice(1).map(fp => fp.product),\n appliedFareProduct: cheapestRelevantFareProduct?.product,\n isDependent:\n // eslint-disable-next-line no-underscore-dangle\n cheapestRelevantFareProduct?.product.__typename ===\n \"DependentFareProduct\",\n price: cheapestRelevantFareProduct?.product.legPrice,\n productUseId: cheapestRelevantFareProduct?.id\n };\n}\n\n/**\n * Returns the total itinerary cost for a given set of legs.\n * @param legs Itinerary legs with fare products (must have used getLegsWithFares)\n * @param category Rider category (youth, regular, senior)\n * @param container Fare container (cash, electronic)\n * @param seenFareIds List of fare product IDs that have already been seen on prev legs.\n * @returns Money object for the total itinerary cost.\n */\nexport function getItineraryCost(\n legs: Leg[],\n mediumId?: string | string[] | null,\n riderCategoryId?: string | string[] | null\n): Money | undefined {\n // TODO: Better input type handling\n if (Array.isArray(mediumId) || Array.isArray(riderCategoryId)) {\n if (mediumId?.length !== riderCategoryId.length) {\n console.warn(\n \"Invalid input types, only using first item. medium id list and rider category list must have same number of items\"\n );\n return getItineraryCost(legs, mediumId[0], riderCategoryId[0]);\n }\n\n let total = { amount: 0, currency: null };\n for (let i = 0; i < mediumId.length; i++) {\n const newCost = getItineraryCost(legs, mediumId[i], riderCategoryId[i]);\n if (newCost) {\n total = {\n amount: total?.amount + (newCost?.amount || 0),\n currency: total.currency ?? newCost?.currency\n };\n }\n }\n if (total.currency === null) return undefined;\n return total;\n }\n\n const legCosts = legs\n // Only legs with fares (no walking legs)\n .filter(leg => leg.fareProducts?.length > 0)\n // Get the leg cost object of each leg\n .reduce<{ seenIds: string[]; legCosts: AppliedFareProduct[] }>(\n (acc, leg) => {\n // getLegCost handles filtering out duplicate use IDs\n // One fare product can be used on multiple legs,\n // and we don't want to count it more than once.\n // Use an object keyed by productUseId to deduplicate, then extract prices\n const { appliedFareProduct, productUseId } = getLegCost(\n leg,\n mediumId,\n riderCategoryId,\n acc.seenIds\n );\n if (!appliedFareProduct) return acc;\n return {\n legCosts: [...acc.legCosts, appliedFareProduct],\n seenIds: [...acc.seenIds, productUseId]\n };\n },\n { seenIds: [], legCosts: [] }\n )\n .legCosts.map(lc => lc.legPrice);\n\n if (legCosts.length === 0) return undefined;\n // Calculate the total\n return legCosts.reduce<Money>(\n (prev, cur) => ({\n amount: prev.amount + cur?.amount || 0,\n currency: prev.currency ?? cur?.currency\n }),\n { amount: 0, currency: null }\n );\n}\n\nconst pickupDropoffTypeToOtp1 = (otp2Type: string): string | null => {\n switch (otp2Type) {\n case \"COORDINATE_WITH_DRIVER\":\n return \"coordinateWithDriver\";\n case \"CALL_AGENCY\":\n return \"mustPhone\";\n case \"SCHEDULED\":\n return \"scheduled\";\n case \"NONE\":\n return \"none\";\n default:\n return null;\n }\n};\n\nexport const convertGraphQLResponseToLegacy = (leg: any): any => ({\n ...leg,\n agencyBrandingUrl: leg.agency?.url,\n agencyId: leg.agency?.id,\n agencyName: leg.agency?.name,\n agencyUrl: leg.agency?.url,\n alightRule: pickupDropoffTypeToOtp1(leg.dropoffType),\n boardRule: pickupDropoffTypeToOtp1(leg.pickupType),\n bookingRuleInfo: {\n dropOff: leg?.dropOffBookingInfo || {},\n pickUp: leg?.pickupBookingInfo || {}\n },\n dropOffBookingInfo: {\n latestBookingTime: leg.dropOffBookingInfo\n },\n from: {\n ...leg.from,\n stopCode: leg.from.stop?.code,\n stopId: leg.from.stop?.gtfsId\n },\n route: leg.route?.shortName,\n routeColor: leg.route?.color,\n routeId: leg.route?.gtfsId,\n routeLongName: leg.route?.longName,\n routeShortName: leg.route?.shortName,\n routeTextColor: leg.route?.textColor,\n to: {\n ...leg.to,\n stopCode: leg.to.stop?.code,\n stopId: leg.to.stop?.gtfsId\n },\n tripHeadsign: leg.trip?.tripHeadsign,\n tripId: leg.trip?.gtfsId\n});\n\n/** Extracts the route number for a leg returned from OTP1 or OTP2. */\nexport const getLegRouteShortName = (\n leg: Pick<Leg, \"route\" | \"routeShortName\">\n): string | null => {\n const { route, routeShortName } = leg;\n // typeof route === \"object\" denotes newer OTP2 responses. routeShortName and route as string is OTP1.\n return typeof route === \"object\"\n ? route?.shortName\n : routeShortName || (route as string);\n};\n\n/** Extract the route long name for a leg returned from OTP1 or OTP2. */\nexport const getLegRouteLongName = (\n leg: Pick<Leg, \"route\" | \"routeLongName\">\n): string | null => {\n const { route, routeLongName } = leg;\n // typeof route === \"object\" denotes newer OTP2 responses. routeLongName is OTP1.\n return typeof route === \"object\" ? route?.longName : routeLongName;\n};\n\n/**\n * Returns the route short name, or the route long name if no short name is provided.\n * This is happens with Seattle area streetcars and ferries.\n */\nexport const getLegRouteName = (\n leg: Pick<Leg, \"route\" | \"routeLongName\" | \"routeShortName\">\n): string => {\n return getLegRouteShortName(leg) || getLegRouteLongName(leg);\n};\n"],"mappings":";;;;;AAAA,OAAOA,QAAQ,MAAM,kBAAkB;AAmBvC,OAAOC,SAAS,MAAM,aAAa;;AAEnC;AACA,OAAO,IAAMC,YAAY,GAAG,CAC1B,MAAM,EACN,YAAY,EACZ,KAAK,EACL,QAAQ,EACR,OAAO,EACP,MAAM,EACN,SAAS,CACV;;AAED;AACA;AACA;AACA;;AAEA,OAAO,SAASC,eAAeA,CAACC,MAAc,EAAY;EACxD,IAAI,CAACA,MAAM,IAAI,CAACA,MAAM,CAACC,KAAK,IAAI,CAACD,MAAM,CAACC,KAAK,CAACH,YAAY,EACxD,OAAOA,YAAY;EAErB,OAAOE,MAAM,CAACC,KAAK,CAACH,YAAY,CAACI,GAAG,CAAC,UAAAC,EAAE;IAAA,OACrC,OAAOA,EAAE,KAAK,QAAQ,GAAGA,EAAE,CAACC,IAAI,GAAGD,EAAE;EAAA,CACvC,CAAC;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B,IAAQiS,KAAK,GAAqBjS,GAAG,CAA7BiS,KAAK;IAAEO,cAAc,GAAKxS,GAAG,CAAtBwS,cAAc;EAC7B;EACA,OAAOO,OAAA,CAAOd,KAAK,MAAK,QAAQ,GAC5BA,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEC,SAAS,GAChBM,cAAc,IAAKP,KAAgB;AACzC,CAAC;;AAED;AACA,OAAO,IAAMe,mBAAmB,GAAG,SAAtBA,mBAAmBA,CAC9BhT,GAAyC,EACvB;EAClB,IAAQiS,KAAK,GAAoBjS,GAAG,CAA5BiS,KAAK;IAAEK,aAAa,GAAKtS,GAAG,CAArBsS,aAAa;EAC5B;EACA,OAAOS,OAAA,CAAOd,KAAK,MAAK,QAAQ,GAAGA,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEM,QAAQ,GAAGD,aAAa;AACpE,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,IAAMW,eAAe,GAAG,SAAlBA,eAAeA,CAC1BjT,GAA4D,EACjD;EACX,OAAO8S,oBAAoB,CAAC9S,GAAG,CAAC,IAAIgT,mBAAmB,CAAChT,GAAG,CAAC;AAC9D,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"itinerary.js","names":["polyline","turfAlong","transitModes","getTransitModes","config","modes","map","tm","mode","isTransitLeg","leg","transitLeg","isTransit","includes","isReservationRequired","boardRule","alightRule","isCoordinationRequired","containsGeometry","place","_place$stop","_place$stop2","stop","geometries","undefined","endsWithGeometry","to","startsWithGeometry","from","legContainsGeometry","isAdvanceBookingRequired","info","_info$latestBookingTi","daysPrior","latestBookingTime","legDropoffRequiresAdvanceBooking","dropOffBookingInfo","isFlex","_leg$stopCalls","stopCalls","some","call","_call$stopLocation","stopLocation","__typename","startsWith","isRideshareLeg","_leg$rideHailingEstim","rideHailingEstimate","provider","id","isWalk","isBicycle","isBicycleRent","isCar","isMicromobility","isAccessMode","hasTransit","modesStr","split","hasCar","hasBike","hasMicromobility","hasHail","indexOf","hasRental","getMapColor","get","toSentenceCase","str","String","charAt","toUpperCase","substr","toLowerCase","getCompanyFromLeg","_from$vehicleRentalSt","rentedBike","rentedCar","rentedVehicle","firstNetwork","Array","isArray","networks","length","rentalVehicle","network","vehicleRentalStation","rentalNetwork","networkId","getItineraryBounds","itinerary","coords","legs","forEach","legCoords","toGeoJSON","legGeometry","points","coordinates","c","push","apply","_toConsumableArray","getLegBounds","lat","lon","legLocationAtDistance","distance","_pt$geometry","line","pt","units","geometry","_unused","legElevationAtDistance","elevation","reduce","acc","point","index","prevPoint","_point","_slicedToArray","pointDistance","pointElevation","_prevPoint","prevPointDistance","prevPointElevation","console","warn","mapOldElevationComponentToNew","oldElev","first","second","getElevationProfile","steps","unitConversion","arguments","minElev","maxElev","traversed","gain","loss","previous","step","_step$elevation","stepElevationProfile","elevationProfile","i","elev","diff","convertedElevation","getTextWidth","text","font","canvas","document","createElement","context","getContext","metrics","measureText","width","getCompanyForNetwork","networkString","companies","company","find","co","concat","getCompaniesLabelFromNetworks","filter","label","join","getTNCLocation","type","location","toFixed","calculatePhysicalActivity","walkDuration","bikeDuration","duration","caloriesBurned","calculateTncFares","_leg$rideHailingEstim2","minPrice","maxPrice","currencyCode","currency","code","maxTNCFare","amount","minTNCFare","CARBON_INTENSITY_DEFAULTS","walk","bicycle","car","tram","trolleybus","subway","rail","bus","ferry","cable_car","gondola","funicular","transit","leg_switch","airplane","micromobility","calculateEmissions","_itinerary$legs","carbonIntensity","carbonIntensityWithDefaults","_objectSpread","totalCarbon","total","getDisplayedStopCode","placeOrStop","_placeOrStop$stopCode","stopCode","_placeOrStop$code","descope","item","substring","zeroDollars","getLegCost","mediumId","riderCategoryId","seenFareIds","fareProducts","price","relevantFareProducts","_ref","_product$riderCategor","_product$riderCategor2","_product$medium","_product$medium2","product","productRiderCategoryId","riderCategory","productMediaId","medium","fare","_fare$product","alreadySeen","legPrice","sort","a","b","_a$product","_b$product","cheapestRelevantFareProduct","alternateFareProducts","splice","fp","appliedFareProduct","isDependent","productUseId","getItineraryCost","_total$currency","currentMediumId","_newCost$currency","newCost","digits","legCosts","_leg$fareProducts","_getLegCost","seenIds","lc","prev","cur","pickupDropoffTypeToOtp1","otp2Type","convertGraphQLResponseToLegacy","_leg$agency","_leg$agency2","_leg$agency3","_leg$agency4","_leg$from$stop","_leg$from$stop2","_leg$route","_leg$route2","_leg$route3","_leg$route4","_leg$route5","_leg$route6","_leg$to$stop","_leg$to$stop2","_leg$trip","_leg$trip2","agencyBrandingUrl","agency","url","agencyId","agencyName","name","agencyUrl","dropoffType","pickupType","bookingRuleInfo","dropOff","pickUp","pickupBookingInfo","stopId","gtfsId","route","shortName","routeColor","color","routeId","routeLongName","longName","routeShortName","routeTextColor","textColor","tripHeadsign","trip","tripId","getLegRouteShortName","_typeof","getLegRouteLongName","getLegRouteName"],"sources":["../src/itinerary.ts"],"sourcesContent":["import polyline from \"@mapbox/polyline\";\nimport {\n AppliedFareProduct,\n Company,\n Config,\n Currency,\n ElevationProfile,\n ElevationProfileComponent,\n FareProduct,\n FlexBookingInfo,\n ItineraryOnlyLegsRequired,\n LatLngArray,\n Leg,\n MassUnitOption,\n Money,\n Place,\n Step,\n Stop,\n TncFare\n} from \"@opentripplanner/types\";\nimport turfAlong from \"@turf/along\";\n\n// All OTP transit modes\nexport const transitModes = [\n \"TRAM\",\n \"TROLLEYBUS\",\n \"BUS\",\n \"SUBWAY\",\n \"FERRY\",\n \"RAIL\",\n \"GONDOLA\"\n];\n\n/**\n * @param {config} config OTP-RR configuration object\n * @return {Array} List of all transit modes defined in config; otherwise default mode list\n */\n\nexport function getTransitModes(config: Config): string[] {\n if (!config || !config.modes || !config.modes.transitModes)\n return transitModes;\n\n return config.modes.transitModes.map(tm =>\n typeof tm !== \"string\" ? tm.mode : tm\n );\n}\n\nexport function isTransitLeg(leg: Leg): boolean {\n return leg.transitLeg;\n}\n\nexport function isTransit(mode: string): boolean {\n return transitModes.includes(mode) || mode === \"TRANSIT\";\n}\n\n/**\n * Returns true if the leg pickup rules enabled which require\n * calling ahead for the service to run. \"mustPhone\" is the only\n * property which encodes this info.\n */\nexport function isReservationRequired(leg: Leg): boolean {\n return leg?.boardRule === \"mustPhone\" || leg?.alightRule === \"mustPhone\";\n}\n/**\n * Returns true if a user must ask the driver to let the user off\n * or if the user must flag the driver down for pickup.\n * \"coordinateWithDriver\" in board/alight rule encodes this info.\n */\nexport function isCoordinationRequired(leg: Leg): boolean {\n return (\n leg?.boardRule === \"coordinateWithDriver\" ||\n leg?.alightRule === \"coordinateWithDriver\"\n );\n}\n\nexport function containsGeometry(place: Place): boolean {\n return (\n place?.stop?.geometries !== null && place?.stop?.geometries !== undefined\n );\n}\nexport function endsWithGeometry(leg: Leg): boolean {\n return containsGeometry(leg?.to);\n}\nexport function startsWithGeometry(leg: Leg): boolean {\n return containsGeometry(leg?.from);\n}\nexport function legContainsGeometry(leg: Leg): boolean {\n return endsWithGeometry(leg) || startsWithGeometry(leg);\n}\nexport function isAdvanceBookingRequired(info?: FlexBookingInfo): boolean {\n const daysPrior = info?.latestBookingTime?.daysPrior;\n return typeof daysPrior === \"number\" && daysPrior > 0;\n}\nexport function legDropoffRequiresAdvanceBooking(leg: Leg): boolean {\n return isAdvanceBookingRequired(leg.dropOffBookingInfo);\n}\n\n/**\n * The two rules checked by the above two functions are the only values\n * returned by OTP when a leg is a flex leg.\n */\nexport function isFlex(leg: Leg): boolean {\n return (\n leg?.stopCalls?.some(call =>\n // Flex calls are \"Location\" or \"LocationGroup\"\n // eslint-disable-next-line no-underscore-dangle\n call?.stopLocation?.__typename.startsWith(\"Location\")\n ) || false\n );\n}\nexport function isRideshareLeg(leg: Leg): boolean {\n return !!leg.rideHailingEstimate?.provider?.id;\n}\n\nexport function isWalk(mode: string): boolean {\n if (!mode) return false;\n\n return mode === \"WALK\";\n}\n\nexport function isBicycle(mode: string): boolean {\n if (!mode) return false;\n\n return mode === \"BICYCLE\";\n}\n\nexport function isBicycleRent(mode: string): boolean {\n if (!mode) return false;\n\n return mode === \"BICYCLE_RENT\";\n}\n\nexport function isCar(mode: string): boolean {\n if (!mode) return false;\n return mode.startsWith(\"CAR\");\n}\n\nexport function isMicromobility(mode: string): boolean {\n if (!mode) return false;\n return mode.startsWith(\"MICROMOBILITY\") || mode.startsWith(\"SCOOTER\");\n}\n\nexport function isAccessMode(mode: string): boolean {\n return (\n isWalk(mode) ||\n isBicycle(mode) ||\n isBicycleRent(mode) ||\n isCar(mode) ||\n isMicromobility(mode)\n );\n}\n\n/**\n * @param {string} modesStr a comma-separated list of OTP modes\n * @return {boolean} whether any of the modes are transit modes\n */\nexport function hasTransit(modesStr: string): boolean {\n return modesStr.split(\",\").some(mode => isTransit(mode));\n}\n\n/**\n * @param {string} modesStr a comma-separated list of OTP modes\n * @return {boolean} whether any of the modes are car-based modes\n */\nexport function hasCar(modesStr: string): boolean {\n return modesStr.split(\",\").some(mode => isCar(mode));\n}\n\n/**\n * @param {string} modesStr a comma-separated list of OTP modes\n * @return {boolean} whether any of the modes are bicycle-based modes\n */\nexport function hasBike(modesStr: string): boolean {\n return modesStr\n .split(\",\")\n .some(mode => isBicycle(mode) || isBicycleRent(mode));\n}\n\n/**\n * @param {string} modesStr a comma-separated list of OTP modes\n * @return {boolean} whether any of the modes are micromobility-based modes\n */\nexport function hasMicromobility(modesStr: string): boolean {\n return modesStr.split(\",\").some(mode => isMicromobility(mode));\n}\n\n/**\n * @param {string} modesStr a comma-separated list of OTP modes\n * @return {boolean} whether any of the modes is a hailing mode\n */\nexport function hasHail(modesStr: string): boolean {\n return modesStr.split(\",\").some(mode => mode.indexOf(\"_HAIL\") > -1);\n}\n\n/**\n * @param {string} modesStr a comma-separated list of OTP modes\n * @return {boolean} whether any of the modes is a rental mode\n */\nexport function hasRental(modesStr: string): boolean {\n return modesStr.split(\",\").some(mode => mode.indexOf(\"_RENT\") > -1);\n}\n\nexport function getMapColor(mode: string): string {\n // @ts-expect-error this is not typed\n mode = mode || this.get(\"mode\");\n if (mode === \"WALK\") return \"#444\";\n if (mode === \"BICYCLE\") return \"#0073e5\";\n if (mode === \"SUBWAY\") return \"#e60000\";\n if (mode === \"RAIL\") return \"#b00\";\n if (mode === \"BUS\") return \"#080\";\n if (mode === \"TROLLEYBUS\") return \"#080\";\n if (mode === \"TRAM\") return \"#800\";\n if (mode === \"FERRY\") return \"#008\";\n if (mode === \"CAR\") return \"#444\";\n if (mode === \"MICROMOBILITY\" || mode === \"SCOOTER\") return \"#f5a729\";\n return \"#aaa\";\n}\n\nexport function toSentenceCase(str: string): string {\n if (str == null) {\n return \"\";\n }\n str = String(str);\n return str.charAt(0).toUpperCase() + str.substr(1).toLowerCase();\n}\n\n/**\n * Derive the company string based on mode and network associated with leg.\n */\nexport function getCompanyFromLeg(leg?: Leg): string | null {\n if (!leg) return null;\n const {\n from,\n mode,\n rentedBike,\n rentedCar,\n rentedVehicle,\n rideHailingEstimate\n } = leg;\n\n const firstNetwork =\n Array.isArray(from.networks) && from.networks.length > 0\n ? from.networks[0]\n : null;\n\n if (mode === \"CAR\" && rentedCar) {\n return firstNetwork;\n }\n if (mode === \"CAR\" && rideHailingEstimate) {\n return rideHailingEstimate.provider.id;\n }\n if (mode === \"BICYCLE\" && rentedBike) {\n return firstNetwork;\n }\n if (from.rentalVehicle) {\n return from.rentalVehicle.network;\n }\n if (from.vehicleRentalStation?.rentalNetwork) {\n return from.vehicleRentalStation.rentalNetwork.networkId;\n }\n if ((mode === \"MICROMOBILITY\" || mode === \"SCOOTER\") && rentedVehicle) {\n return firstNetwork;\n }\n return null;\n}\n\nexport function getItineraryBounds(\n itinerary: ItineraryOnlyLegsRequired\n): LatLngArray[] {\n const coords: LatLngArray[] = [];\n itinerary.legs.forEach(leg => {\n const legCoords = polyline\n .toGeoJSON(leg.legGeometry.points)\n .coordinates.map((c): LatLngArray => [c[1], c[0]]);\n coords.push(...legCoords);\n });\n return coords;\n}\n\n/**\n * Return a coords object that encloses the given leg's geometry.\n */\nexport function getLegBounds(leg: Leg): number[][] {\n const coords = polyline\n .toGeoJSON(leg.legGeometry.points)\n .coordinates.map(c => [c[1], c[0]]);\n\n // in certain cases, there might be zero-length coordinates in the leg\n // geometry. In these cases, build us an array of coordinates using the from\n // and to data of the leg.\n if (coords.length === 0) {\n coords.push([leg.from.lat, leg.from.lon], [leg.to.lat, leg.to.lon]);\n }\n return coords;\n}\n\n/* Returns an interpolated lat-lon at a specified distance along a leg */\nexport function legLocationAtDistance(\n leg: Leg,\n distance: number\n): LatLngArray | undefined | null {\n if (!leg.legGeometry) return undefined;\n\n try {\n const line = polyline.toGeoJSON(leg.legGeometry.points);\n const pt = turfAlong(line, distance, { units: \"meters\" });\n const coords = pt?.geometry?.coordinates;\n return [coords[1], coords[0]];\n } catch {\n // This is designed to catch the toGeoJSON from throwing if the geometry is not in the correct format\n }\n\n return null;\n}\n\n/**\n * Returns an interpolated elevation at a specified distance along a leg\n * @param points - The points of the elevation profile. Each point is a tuple of [distance, elevation].\n * @param distance - The distance along the leg to interpolate the elevation at\n * @returns The interpolated elevation at the specified distance\n */\n\nexport function legElevationAtDistance(\n points: [number, number][],\n distance: number\n): number | undefined {\n const elevation = points.reduce<number | undefined>((acc, point, index) => {\n const prevPoint = points[index - 1];\n // at the first index there is no previous point\n if (!prevPoint) return acc;\n const [pointDistance, pointElevation] = point;\n const [prevPointDistance, prevPointElevation] = prevPoint;\n if (distance >= prevPointDistance && distance <= pointDistance) {\n return (\n prevPointElevation +\n ((pointElevation - prevPointElevation) *\n (distance - prevPointDistance)) /\n (pointDistance - prevPointDistance)\n );\n }\n return acc;\n }, undefined);\n if (elevation === undefined) {\n console.warn(\"Elevation value does not exist for distance.\", distance);\n return undefined;\n }\n return elevation;\n}\n\nexport function mapOldElevationComponentToNew(oldElev: {\n first: number;\n second: number;\n}): ElevationProfileComponent {\n return {\n distance: oldElev.first,\n elevation: oldElev.second\n };\n}\n\n// Iterate through the steps, building the array of elevation points and\n// keeping track of the minimum and maximum elevations reached\nexport function getElevationProfile(\n steps: Step[],\n unitConversion = 1\n): ElevationProfile {\n let minElev = 100000;\n let maxElev = -100000;\n let traversed = 0;\n let gain = 0;\n let loss = 0;\n let previous: ElevationProfileComponent | null = null;\n const points: [number, number][] = [];\n steps.forEach(step => {\n // Support for old REST response data (in step.elevation)\n const stepElevationProfile =\n step.elevationProfile ||\n (Array.isArray(step.elevation) &&\n step.elevation?.map<ElevationProfileComponent>(\n mapOldElevationComponentToNew\n ));\n\n if (!stepElevationProfile || stepElevationProfile.length === 0) {\n traversed += step.distance;\n return;\n }\n for (let i = 0; i < stepElevationProfile.length; i++) {\n const elev = stepElevationProfile[i];\n if (previous) {\n const diff = (elev.elevation - previous.elevation) * unitConversion;\n if (diff > 0) gain += diff;\n else loss += diff;\n }\n if (i === 0 && elev.distance !== 0) {\n // console.warn(`No elevation data available for step ${stepIndex}-${i} at beginning of segment`, elev)\n }\n const convertedElevation = elev.elevation * unitConversion;\n if (convertedElevation < minElev) minElev = convertedElevation;\n if (convertedElevation > maxElev) maxElev = convertedElevation;\n points.push([traversed + elev.distance, elev.elevation]);\n // Insert \"filler\" point if the last point in elevation profile does not\n // reach the full distance of the step.\n if (\n i === stepElevationProfile.length - 1 &&\n elev.distance !== step.distance\n ) {\n // points.push([traversed + step.distance, elev.second])\n }\n previous = elev;\n }\n traversed += step.distance;\n });\n return { maxElev, minElev, points, traversed, gain, loss };\n}\n\n/**\n * Uses canvas.measureText to compute and return the width of the given text of given font in pixels.\n *\n * @param {string} text The text to be rendered.\n * @param {string} font The css font descriptor that text is to be rendered with (e.g. \"bold 14px verdana\").\n *\n * @see https://stackoverflow.com/questions/118241/calculate-text-width-with-javascript/21015393#21015393\n */\nexport function getTextWidth(text: string, font = \"22px Arial\"): number {\n // Create custom type for function including reused canvas object\n type GetTextWidth = typeof getTextWidth & { canvas: HTMLCanvasElement };\n\n // reuse canvas object for better performance\n const canvas =\n (getTextWidth as GetTextWidth).canvas ||\n ((getTextWidth as GetTextWidth).canvas = document.createElement(\"canvas\"));\n const context = canvas.getContext(\"2d\");\n if (!context) return 0;\n context.font = font;\n const metrics = context.measureText(text);\n return metrics.width;\n}\n\n/**\n * Get the configured company object for the given network string if the company\n * has been defined in the provided companies array config.\n */\nexport function getCompanyForNetwork(\n networkString: string,\n companies: Company[] = []\n): Company | undefined {\n const company = companies.find(co => co.id === networkString);\n if (!company) {\n console.warn(\n `No company found in config.yml that matches rented vehicle network: ${networkString}`,\n companies\n );\n }\n return company;\n}\n\n/**\n * Get a string label to display from a list of vehicle rental networks. Returns\n * empty string if no networks provided.\n *\n * @param {Array<string>} networks A list of network ids.\n * @param {Array<object>} [companies=[]] An optional list of the companies config.\n * @return {string} A label for use in presentation on a website.\n */\nexport function getCompaniesLabelFromNetworks(\n networks?: string[] | string,\n companies: Company[] = []\n): string {\n if (!networks) return \"\";\n return (Array.isArray(networks) ? networks : [networks])\n .map(network => getCompanyForNetwork(network, companies))\n .filter(co => !!co)\n .map(co => co.label)\n .join(\"/\");\n}\n\nexport function getTNCLocation(\n leg: Pick<Leg, \"from\" | \"to\">,\n type: \"from\" | \"to\"\n): string {\n const location = leg[type];\n return `${location.lat.toFixed(5)},${location.lon.toFixed(5)}`;\n}\n\nexport function calculatePhysicalActivity(\n itinerary: ItineraryOnlyLegsRequired\n): {\n bikeDuration: number;\n caloriesBurned: number;\n walkDuration: number;\n} {\n let walkDuration = 0;\n let bikeDuration = 0;\n itinerary.legs.forEach(leg => {\n if (leg.mode.startsWith(\"WALK\")) walkDuration += leg.duration;\n if (leg.mode.startsWith(\"BICYCLE\")) bikeDuration += leg.duration;\n });\n const caloriesBurned =\n (walkDuration / 3600) * 280 + (bikeDuration / 3600) * 290;\n return {\n bikeDuration,\n caloriesBurned,\n walkDuration\n };\n}\n\n/**\n * For an itinerary, calculates the TNC fares and returns an object with\n * these values and currency info.\n * It is assumed that the same currency is used for all TNC legs.\n */\nexport function calculateTncFares(\n itinerary: ItineraryOnlyLegsRequired\n): TncFare {\n return itinerary.legs\n .filter(\n (\n leg\n ): leg is Leg & {\n rideHailingEstimate: NonNullable<Leg[\"rideHailingEstimate\"]>;\n } => leg.mode === \"CAR\" && leg.rideHailingEstimate !== undefined\n )\n .reduce<TncFare>(\n (acc, leg) => {\n const { minPrice, maxPrice } = leg.rideHailingEstimate;\n return {\n // Assumes a single currency for entire itinerary.\n currencyCode: minPrice.currency.code,\n maxTNCFare: acc.maxTNCFare + maxPrice.amount,\n minTNCFare: acc.minTNCFare + minPrice.amount\n };\n },\n {\n currencyCode: null,\n maxTNCFare: 0,\n minTNCFare: 0\n }\n );\n}\n\n/**\n * Sources:\n * - https://www.itf-oecd.org/sites/default/files/docs/environmental-performance-new-mobility.pdf\n * - https://www.thrustcarbon.com/insights/how-to-calculate-emissions-from-a-ferry-journey\n * - https://www.itf-oecd.org/sites/default/files/life-cycle-assessment-calculations-2020.xlsx\n * Other values extrapolated.\n */\nconst CARBON_INTENSITY_DEFAULTS: Record<string, number> = {\n walk: 0.026,\n bicycle: 0.017,\n car: 0.162,\n tram: 0.066,\n trolleybus: 0.066,\n subway: 0.066,\n rail: 0.066,\n bus: 0.09,\n ferry: 0.082,\n cable_car: 0.021,\n gondola: 0.021,\n funicular: 0.066,\n transit: 0.066,\n leg_switch: 0,\n airplane: 0.382,\n micromobility: 0.095\n};\n\n/**\n * @param {itinerary} itinerary OTP trip itinierary, only legs is required.\n * @param {carbonIntensity} carbonIntensity carbon intensity by mode in grams/meter\n * @param {units} units units to be used in return value\n * @return Amount of carbon in chosen unit\n */\nexport function calculateEmissions(\n // This type makes all the properties from Itinerary optional except legs.\n itinerary: ItineraryOnlyLegsRequired,\n carbonIntensity: Record<string, number> = {},\n units?: MassUnitOption\n): number {\n // Apply defaults for any values that we don't have.\n const carbonIntensityWithDefaults = {\n ...CARBON_INTENSITY_DEFAULTS,\n ...carbonIntensity\n };\n\n // Distance is in meters, totalCarbon is in grams\n const totalCarbon =\n itinerary?.legs?.reduce((total, leg) => {\n return (\n (leg.distance * carbonIntensityWithDefaults[leg.mode.toLowerCase()] ||\n 0) + total\n );\n }, 0) || 0;\n\n switch (units) {\n case \"ounce\":\n return totalCarbon / 28.35;\n case \"kilogram\":\n return totalCarbon / 1000;\n case \"pound\":\n return totalCarbon / 454;\n case \"gram\":\n default:\n return totalCarbon;\n }\n}\n\n/**\n * Returns the user-facing stop code to display for a stop or place\n */\nexport function getDisplayedStopCode(\n placeOrStop: Place | Stop\n): string | undefined {\n if (\"stopId\" in placeOrStop) {\n return placeOrStop.stopCode ?? undefined;\n }\n if (\"id\" in placeOrStop) {\n return placeOrStop.code ?? undefined;\n }\n return undefined;\n}\n\n/**\n * Removes the first part of the OTP standard scope (\":\"), if it is present.\n * @param item String that is potentially scoped with `:` character\n * @returns descoped string\n */\nexport const descope = (item?: string | null): string | null | undefined => {\n if (!item) return item;\n const index = item.indexOf(\":\");\n return index === -1 ? item : item.substring(index + 1);\n};\n\nexport type ExtendedMoney = Money & { originalAmount?: number };\n\nexport const zeroDollars = (currency: Currency): Money => ({\n amount: 0,\n currency\n});\n\ntype FareProductWithPrice = FareProduct & { price: Money };\n\n/**\n * Extracts useful data from the fare products on a leg, such as the leg cost and transfer info.\n * @param leg Leg with Fares v2 information\n * @param mediumId Desired medium ID to calculate fare for\n * @param riderCategoryId Desire rider category to calculate fare for\n * @param seenFareIds Fare IDs used on previous legs. Used to detect transfer discounts.\n * @returns Object containing price as well as transfer/dependent\n * fare information. `AppliedFareProduct` should contain\n * all the information needed, but the other fields are kept to\n * make the transition to Fares V2 less jarring.\n */\nexport function getLegCost(\n leg: Leg,\n mediumId?: string | null,\n riderCategoryId?: string | null,\n seenFareIds?: string[] | null\n): {\n alternateFareProducts?: AppliedFareProduct[];\n appliedFareProduct?: AppliedFareProduct;\n isDependent?: boolean;\n price?: Money;\n productUseId?: string;\n} {\n if (!leg.fareProducts) return { price: undefined };\n const relevantFareProducts = leg.fareProducts\n .filter(({ product }) => {\n // riderCategory and medium can be specifically defined as null to handle\n // generic GTFS based fares from OTP when there is no fare model\n\n // Remove (optional) agency scoping\n const productRiderCategoryId =\n descope(product?.riderCategory?.id) ||\n product?.riderCategory?.id ||\n null;\n\n const productMediaId =\n descope(product?.medium?.id) || product?.medium?.id || null;\n\n return (\n productRiderCategoryId === riderCategoryId &&\n productMediaId === mediumId &&\n // Make sure there's a price\n // Some fare products don't have a price at all.\n product?.price\n );\n })\n // Make sure there's a price\n // Some fare products don't have a price at all.\n .filter(\n (fare): fare is { id: string; product: FareProductWithPrice } =>\n fare.product?.price !== undefined\n )\n .map(fare => {\n const alreadySeen = !!seenFareIds && seenFareIds?.indexOf(fare.id) > -1;\n return {\n id: fare.id,\n product: {\n ...fare.product,\n legPrice:\n alreadySeen && fare.product.price\n ? zeroDollars(fare.product.price.currency)\n : fare.product.price\n } as AppliedFareProduct\n };\n })\n .sort((a, b) => a.product?.legPrice?.amount - b.product?.legPrice?.amount);\n\n // Return the cheapest, but include other matches as well\n const cheapestRelevantFareProduct = relevantFareProducts[0];\n\n // TODO: return one object here instead of dumbing it down?\n return {\n alternateFareProducts: relevantFareProducts.splice(1).map(fp => fp.product),\n appliedFareProduct: cheapestRelevantFareProduct?.product,\n isDependent:\n // eslint-disable-next-line no-underscore-dangle\n cheapestRelevantFareProduct?.product.__typename ===\n \"DependentFareProduct\",\n price: cheapestRelevantFareProduct?.product.legPrice,\n productUseId: cheapestRelevantFareProduct?.id\n };\n}\n\n/**\n * Returns the total itinerary cost for a given set of legs.\n * @param legs Itinerary legs with fare products (must have used getLegsWithFares)\n * @param category Rider category (youth, regular, senior)\n * @param container Fare container (cash, electronic)\n * @param seenFareIds List of fare product IDs that have already been seen on prev legs.\n * @returns Money object for the total itinerary cost.\n */\nexport function getItineraryCost(\n legs: Leg[],\n mediumId?: string | (string | null)[] | null,\n riderCategoryId?: string | (string | null)[] | null\n): Money | undefined {\n if (Array.isArray(mediumId) || Array.isArray(riderCategoryId)) {\n // TODO: Better input type handling\n if (Array.isArray(mediumId) && Array.isArray(riderCategoryId)) {\n if (mediumId.length !== riderCategoryId.length) {\n console.warn(\n \"Invalid input types, only using first item. medium id list and rider category list must have same number of items\"\n );\n return getItineraryCost(legs, mediumId[0], riderCategoryId[0]);\n }\n\n const total = mediumId.reduce<Money>(\n (acc, currentMediumId, index) => {\n const newCost = getItineraryCost(\n legs,\n currentMediumId,\n riderCategoryId[index]\n );\n if (!newCost) return acc;\n\n return {\n amount: acc.amount + (newCost.amount || 0),\n currency:\n acc.currency.code !== \"\"\n ? acc.currency\n : newCost.currency ?? acc.currency\n };\n },\n { amount: 0, currency: { code: \"\", digits: 0 } }\n );\n\n if (!total.currency?.code) return undefined;\n return total;\n }\n console.warn(\n \"Invalid input types, only using first item. medium id list and rider category list must have same number of items\"\n );\n return undefined;\n }\n\n const legCosts = legs\n // Only legs with fares (no walking legs)\n .filter(leg => leg.fareProducts?.length && leg.fareProducts.length > 0)\n // Get the leg cost object of each leg\n .reduce<{ seenIds: string[]; legCosts: AppliedFareProduct[] }>(\n (acc, leg) => {\n // getLegCost handles filtering out duplicate use IDs\n // One fare product can be used on multiple legs,\n // and we don't want to count it more than once.\n // Use an object keyed by productUseId to deduplicate, then extract prices\n const { appliedFareProduct, productUseId } = getLegCost(\n leg,\n mediumId,\n riderCategoryId,\n acc.seenIds\n );\n if (!appliedFareProduct) return acc;\n if (!productUseId) return acc;\n return {\n legCosts: [...acc.legCosts, appliedFareProduct],\n seenIds: [...acc.seenIds, productUseId]\n };\n },\n { seenIds: [], legCosts: [] }\n )\n .legCosts.map(lc => lc.legPrice);\n\n if (legCosts.length === 0) return undefined;\n // Calculate the total\n return legCosts.reduce<Money>(\n (prev, cur) => ({\n amount: prev.amount + cur?.amount || 0,\n currency: prev.currency.code !== \"\" ? prev.currency : cur.currency\n }),\n // eslint-disable-next-line prettier/prettier -- old eslint doesn't know satisfies\n { amount: 0, currency: { code: \"\", digits: 0 } satisfies Currency }\n );\n}\n\nconst pickupDropoffTypeToOtp1 = (otp2Type: string): string | null => {\n switch (otp2Type) {\n case \"COORDINATE_WITH_DRIVER\":\n return \"coordinateWithDriver\";\n case \"CALL_AGENCY\":\n return \"mustPhone\";\n case \"SCHEDULED\":\n return \"scheduled\";\n case \"NONE\":\n return \"none\";\n default:\n return null;\n }\n};\n\nexport const convertGraphQLResponseToLegacy = (leg: any): Leg => ({\n ...leg,\n agencyBrandingUrl: leg.agency?.url,\n agencyId: leg.agency?.id,\n agencyName: leg.agency?.name,\n agencyUrl: leg.agency?.url,\n alightRule: pickupDropoffTypeToOtp1(leg.dropoffType),\n boardRule: pickupDropoffTypeToOtp1(leg.pickupType),\n bookingRuleInfo: {\n dropOff: leg?.dropOffBookingInfo || {},\n pickUp: leg?.pickupBookingInfo || {}\n },\n dropOffBookingInfo: {\n latestBookingTime: leg.dropOffBookingInfo\n },\n from: {\n ...leg.from,\n stopCode: leg.from.stop?.code,\n stopId: leg.from.stop?.gtfsId\n },\n route: leg.route?.shortName,\n routeColor: leg.route?.color,\n routeId: leg.route?.gtfsId,\n routeLongName: leg.route?.longName,\n routeShortName: leg.route?.shortName,\n routeTextColor: leg.route?.textColor,\n to: {\n ...leg.to,\n stopCode: leg.to.stop?.code,\n stopId: leg.to.stop?.gtfsId\n },\n tripHeadsign: leg.trip?.tripHeadsign,\n tripId: leg.trip?.gtfsId\n});\n\n/** Extracts the route number for a leg returned from OTP1 or OTP2. */\nexport const getLegRouteShortName = (\n leg: Pick<Leg, \"route\" | \"routeShortName\">\n): string | null => {\n const { route, routeShortName } = leg;\n // typeof route === \"object\" denotes newer OTP2 responses. routeShortName and route as string is OTP1.\n return typeof route === \"object\"\n ? route?.shortName\n : routeShortName || (route as string);\n};\n\n/** Extract the route long name for a leg returned from OTP1 or OTP2. */\nexport const getLegRouteLongName = (\n leg: Pick<Leg, \"route\" | \"routeLongName\">\n): string | undefined => {\n const { route, routeLongName } = leg;\n // typeof route === \"object\" denotes newer OTP2 responses. routeLongName is OTP1.\n return typeof route === \"object\" ? route?.longName : routeLongName;\n};\n\n/**\n * Returns the route short name, or the route long name if no short name is provided.\n * This is happens with Seattle area streetcars and ferries.\n */\nexport const getLegRouteName = (\n leg: Pick<Leg, \"route\" | \"routeLongName\" | \"routeShortName\">\n): string | undefined => {\n return getLegRouteShortName(leg) || getLegRouteLongName(leg);\n};\n"],"mappings":";;;;;;AAAA,OAAOA,QAAQ,MAAM,kBAAkB;AAoBvC,OAAOC,SAAS,MAAM,aAAa;;AAEnC;AACA,OAAO,IAAMC,YAAY,GAAG,CAC1B,MAAM,EACN,YAAY,EACZ,KAAK,EACL,QAAQ,EACR,OAAO,EACP,MAAM,EACN,SAAS,CACV;;AAED;AACA;AACA;AACA;;AAEA,OAAO,SAASC,eAAeA,CAACC,MAAc,EAAY;EACxD,IAAI,CAACA,MAAM,IAAI,CAACA,MAAM,CAACC,KAAK,IAAI,CAACD,MAAM,CAACC,KAAK,CAACH,YAAY,EACxD,OAAOA,YAAY;EAErB,OAAOE,MAAM,CAACC,KAAK,CAACH,YAAY,CAACI,GAAG,CAAC,UAAAC,EAAE;IAAA,OACrC,OAAOA,EAAE,KAAK,QAAQ,GAAGA,EAAE,CAACC,IAAI,GAAGD,EAAE;EAAA,CACvC,CAAC;AACH;AAEA,OAAO,SAASE,YAAYA,CAACC,GAAQ,EAAW;EAC9C,OAAOA,GAAG,CAACC,UAAU;AACvB;AAEA,OAAO,SAASC,SAASA,CAACJ,IAAY,EAAW;EAC/C,OAAON,YAAY,CAACW,QAAQ,CAACL,IAAI,CAAC,IAAIA,IAAI,KAAK,SAAS;AAC1D;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASM,qBAAqBA,CAACJ,GAAQ,EAAW;EACvD,OAAO,CAAAA,GAAG,aAAHA,GAAG,uBAAHA,GAAG,CAAEK,SAAS,MAAK,WAAW,IAAI,CAAAL,GAAG,aAAHA,GAAG,uBAAHA,GAAG,CAAEM,UAAU,MAAK,WAAW;AAC1E;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAsBA,CAACP,GAAQ,EAAW;EACxD,OACE,CAAAA,GAAG,aAA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