@opentripplanner/core-utils 12.0.0-alpha.8 → 12.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.
- package/esm/__tests__/__mocks__/bike-rental-itinerary.json +863 -0
- package/esm/__tests__/__mocks__/config.json +54 -0
- package/esm/__tests__/__mocks__/fare-products-itinerary.json +1299 -0
- package/esm/__tests__/__mocks__/routes.json +107 -0
- package/esm/__tests__/__mocks__/tnc-itinerary.json +1726 -0
- package/esm/bike-rental-itinerary.json +863 -0
- package/esm/config.json +54 -0
- package/esm/fare-products-itinerary.json +1299 -0
- package/esm/index.js +2 -0
- package/esm/index.js.map +1 -1
- package/esm/itinerary.js +46 -21
- package/esm/itinerary.js.map +1 -1
- package/esm/otpSchema.json +13373 -0
- package/esm/planQuery.graphql +281 -0
- package/esm/profile.js +1 -1
- package/esm/profile.js.map +1 -1
- package/esm/query-gen.js +8 -5
- package/esm/query-gen.js.map +1 -1
- package/esm/query.js +1 -5
- package/esm/query.js.map +1 -1
- package/esm/routes.json +107 -0
- package/esm/storage.js +2 -6
- package/esm/storage.js.map +1 -1
- package/esm/suspense.js +13 -0
- package/esm/suspense.js.map +1 -0
- package/esm/tnc-itinerary.json +1726 -0
- package/lib/__tests__/__mocks__/bike-rental-itinerary.json +863 -0
- package/lib/__tests__/__mocks__/config.json +54 -0
- package/lib/__tests__/__mocks__/fare-products-itinerary.json +1299 -0
- package/lib/__tests__/__mocks__/routes.json +107 -0
- package/lib/__tests__/__mocks__/tnc-itinerary.json +1726 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +10 -0
- package/lib/index.js.map +1 -1
- package/lib/itinerary.d.ts +13 -4
- package/lib/itinerary.d.ts.map +1 -1
- package/lib/itinerary.js +59 -22
- package/lib/itinerary.js.map +1 -1
- package/lib/otpSchema.json +13373 -0
- package/lib/planQuery.graphql +281 -0
- package/lib/profile.js +1 -1
- package/lib/profile.js.map +1 -1
- package/lib/query-gen.d.ts +3 -1
- package/lib/query-gen.d.ts.map +1 -1
- package/lib/query-gen.js +8 -5
- package/lib/query-gen.js.map +1 -1
- package/lib/query.js +1 -5
- package/lib/query.js.map +1 -1
- package/lib/storage.d.ts.map +1 -1
- package/lib/storage.js +2 -6
- package/lib/storage.js.map +1 -1
- package/lib/suspense.d.ts +8 -0
- package/lib/suspense.d.ts.map +1 -0
- package/lib/suspense.js +26 -0
- package/lib/suspense.js.map +1 -0
- package/package.json +3 -3
- package/src/__tests__/itinerary.ts +36 -1
- package/src/core-utils.story.tsx +1 -1
- package/src/index.ts +2 -0
- package/src/itinerary.ts +68 -26
- package/src/otpSchema.json +0 -12
- package/src/planQuery.graphql +27 -0
- package/src/profile.js +1 -1
- package/src/query-gen.ts +8 -4
- package/src/query.js +1 -4
- package/src/storage.ts +5 -9
- package/src/suspense.tsx +19 -0
- package/tsconfig.json +1 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/core-utils.story.d.ts +0 -22
- package/lib/core-utils.story.d.ts.map +0 -1
- package/lib/core-utils.story.js +0 -69
- package/lib/core-utils.story.js.map +0 -1
package/lib/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import * as storage from "./storage";
|
|
|
5
5
|
import * as time from "./time";
|
|
6
6
|
import * as ui from "./ui";
|
|
7
7
|
import * as queryGen from "./query-gen";
|
|
8
|
+
import SafeSuspense from "./suspense";
|
|
8
9
|
declare const core: {
|
|
9
10
|
itinerary: typeof itinerary;
|
|
10
11
|
map: typeof map;
|
|
@@ -17,5 +18,6 @@ declare const core: {
|
|
|
17
18
|
time: typeof time;
|
|
18
19
|
ui: typeof ui;
|
|
19
20
|
};
|
|
21
|
+
export { SafeSuspense };
|
|
20
22
|
export default core;
|
|
21
23
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAI7B,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,EAAE,MAAM,MAAM,CAAC;AAC3B,OAAO,KAAK,QAAQ,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAI7B,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,EAAE,MAAM,MAAM,CAAC;AAC3B,OAAO,KAAK,QAAQ,MAAM,aAAa,CAAC;AACxC,OAAO,YAAY,MAAM,YAAY,CAAC;AAEtC,QAAA,MAAM,IAAI;;;;;;;;;;;CAWT,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,CAAC;AACxB,eAAe,IAAI,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
8
|
+
Object.defineProperty(exports, "SafeSuspense", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () {
|
|
11
|
+
return _suspense.default;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
6
14
|
exports.default = void 0;
|
|
7
15
|
|
|
8
16
|
var itinerary = _interopRequireWildcard(require("./itinerary"));
|
|
@@ -25,6 +33,8 @@ var ui = _interopRequireWildcard(require("./ui"));
|
|
|
25
33
|
|
|
26
34
|
var queryGen = _interopRequireWildcard(require("./query-gen"));
|
|
27
35
|
|
|
36
|
+
var _suspense = _interopRequireDefault(require("./suspense"));
|
|
37
|
+
|
|
28
38
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
29
39
|
|
|
30
40
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":["core","itinerary","map","profile","query","queryGen","queryParams","route","storage","time","ui"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["core","itinerary","map","profile","query","queryGen","queryParams","route","storage","time","ui"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,MAAMA,IAAI,GAAG;AACXC,EAAAA,SADW;AAEXC,EAAAA,GAFW;AAGXC,EAAAA,OAHW;AAIXC,EAAAA,KAJW;AAKXC,EAAAA,QALW;AAMXC,EAAAA,WANW;AAOXC,EAAAA,KAPW;AAQXC,EAAAA,OARW;AASXC,EAAAA,IATW;AAUXC,EAAAA;AAVW,CAAb;eAceV,I","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"],"file":"index.js"}
|
package/lib/itinerary.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { Company, Config, ElevationProfile, FlexBookingInfo, ItineraryOnlyLegsRequired, LatLngArray, Leg, MassUnitOption, Money, Place, Step, Stop, TncFare } from "@opentripplanner/types";
|
|
1
|
+
import { Company, Config, ElevationProfile, ElevationProfileComponent, FlexBookingInfo, ItineraryOnlyLegsRequired, LatLngArray, Leg, MassUnitOption, Money, Place, Step, Stop, TncFare } from "@opentripplanner/types";
|
|
2
2
|
export declare const transitModes: string[];
|
|
3
3
|
/**
|
|
4
4
|
* @param {config} config OTP-RR configuration object
|
|
5
5
|
* @return {Array} List of all transit modes defined in config; otherwise default mode list
|
|
6
6
|
*/
|
|
7
7
|
export declare function getTransitModes(config: Config): string[];
|
|
8
|
+
export declare function isTransitLeg(leg: Leg): boolean;
|
|
8
9
|
export declare function isTransit(mode: string): boolean;
|
|
9
10
|
/**
|
|
10
11
|
* Returns true if the leg pickup rules enabled which require
|
|
@@ -18,13 +19,17 @@ export declare function isReservationRequired(leg: Leg): boolean;
|
|
|
18
19
|
* "coordinateWithDriver" in board/alight rule encodes this info.
|
|
19
20
|
*/
|
|
20
21
|
export declare function isCoordinationRequired(leg: Leg): boolean;
|
|
22
|
+
export declare function containsGeometry(place: Place): boolean;
|
|
23
|
+
export declare function endsWithGeometry(leg: Leg): boolean;
|
|
24
|
+
export declare function startsWithGeometry(leg: Leg): boolean;
|
|
25
|
+
export declare function legContainsGeometry(leg: Leg): boolean;
|
|
26
|
+
export declare function isAdvanceBookingRequired(info: FlexBookingInfo): boolean;
|
|
27
|
+
export declare function legDropoffRequiresAdvanceBooking(leg: Leg): boolean;
|
|
21
28
|
/**
|
|
22
29
|
* The two rules checked by the above two functions are the only values
|
|
23
30
|
* returned by OTP when a leg is a flex leg.
|
|
24
31
|
*/
|
|
25
32
|
export declare function isFlex(leg: Leg): boolean;
|
|
26
|
-
export declare function isAdvanceBookingRequired(info: FlexBookingInfo): boolean;
|
|
27
|
-
export declare function legDropoffRequiresAdvanceBooking(leg: Leg): boolean;
|
|
28
33
|
export declare function isRideshareLeg(leg: Leg): boolean;
|
|
29
34
|
export declare function isWalk(mode: string): boolean;
|
|
30
35
|
export declare function isBicycle(mode: string): boolean;
|
|
@@ -75,6 +80,10 @@ export declare function getItineraryBounds(itinerary: ItineraryOnlyLegsRequired)
|
|
|
75
80
|
export declare function getLegBounds(leg: Leg): number[][];
|
|
76
81
|
export declare function legLocationAtDistance(leg: Leg, distance: number): number[];
|
|
77
82
|
export declare function legElevationAtDistance(points: number[][], distance: number): number;
|
|
83
|
+
export declare function mapOldElevationComponentToNew(oldElev: {
|
|
84
|
+
first: number;
|
|
85
|
+
second: number;
|
|
86
|
+
}): ElevationProfileComponent;
|
|
78
87
|
export declare function getElevationProfile(steps: Step[], unitConversion?: number): ElevationProfile;
|
|
79
88
|
/**
|
|
80
89
|
* Uses canvas.measureText to compute and return the width of the given text of given font in pixels.
|
|
@@ -97,7 +106,7 @@ export declare function getCompanyForNetwork(networkString: string, companies?:
|
|
|
97
106
|
* @param {Array<object>} [companies=[]] An optional list of the companies config.
|
|
98
107
|
* @return {string} A label for use in presentation on a website.
|
|
99
108
|
*/
|
|
100
|
-
export declare function getCompaniesLabelFromNetworks(networks: string | string
|
|
109
|
+
export declare function getCompaniesLabelFromNetworks(networks: string[] | string, companies?: Company[]): string;
|
|
101
110
|
export declare function getTNCLocation(leg: Leg, type: string): string;
|
|
102
111
|
export declare function calculatePhysicalActivity(itinerary: ItineraryOnlyLegsRequired): {
|
|
103
112
|
bikeDuration: number;
|
package/lib/itinerary.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"itinerary.d.ts","sourceRoot":"","sources":["../src/itinerary.ts"],"names":[],"mappings":"AACA,OAAO,EACL,OAAO,EACP,MAAM,EACN,gBAAgB,EAChB,eAAe,EACf,yBAAyB,EACzB,WAAW,EACX,GAAG,EACH,cAAc,EACd,KAAK,EACL,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,OAAO,EACR,MAAM,wBAAwB,CAAC;AAIhC,eAAO,MAAM,YAAY,UAQxB,CAAC;AAEF;;;GAGG;AAEH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAOxD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE/C;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAEvD;AACD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAKxD;AACD
|
|
1
|
+
{"version":3,"file":"itinerary.d.ts","sourceRoot":"","sources":["../src/itinerary.ts"],"names":[],"mappings":"AACA,OAAO,EACL,OAAO,EACP,MAAM,EACN,gBAAgB,EAChB,yBAAyB,EACzB,eAAe,EACf,yBAAyB,EACzB,WAAW,EACX,GAAG,EACH,cAAc,EACd,KAAK,EACL,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,OAAO,EACR,MAAM,wBAAwB,CAAC;AAIhC,eAAO,MAAM,YAAY,UAQxB,CAAC;A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BA;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,GAAG,EAAE,EACX,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,eAAe,EAAE,MAAM,GAAG,IAAI,GAC7B,KAAK,GAAG,SAAS,CA2BnB;AAiBD,eAAO,MAAM,8BAA8B,QAAS,GAAG,KAAG,GA6BxD,CAAC;AAEH,sEAAsE;AACtE,eAAO,MAAM,oBAAoB,QAC1B,KAAK,GAAG,EAAE,OAAO,GAAG,gBAAgB,CAAC,KACzC,MAAM,GAAG,IAMX,CAAC;AAEF,wEAAwE;AACxE,eAAO,MAAM,mBAAmB,QACzB,KAAK,GAAG,EAAE,OAAO,GAAG,eAAe,CAAC,KACxC,MAAM,GAAG,IAIX,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,QACrB,KAAK,GAAG,EAAE,OAAO,GAAG,eAAe,GAAG,gBAAgB,CAAC,KAC3D,MAEF,CAAC"}
|
package/lib/itinerary.js
CHANGED
|
@@ -6,12 +6,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.getTransitModes = getTransitModes;
|
|
9
|
+
exports.isTransitLeg = isTransitLeg;
|
|
9
10
|
exports.isTransit = isTransit;
|
|
10
11
|
exports.isReservationRequired = isReservationRequired;
|
|
11
12
|
exports.isCoordinationRequired = isCoordinationRequired;
|
|
12
|
-
exports.
|
|
13
|
+
exports.containsGeometry = containsGeometry;
|
|
14
|
+
exports.endsWithGeometry = endsWithGeometry;
|
|
15
|
+
exports.startsWithGeometry = startsWithGeometry;
|
|
16
|
+
exports.legContainsGeometry = legContainsGeometry;
|
|
13
17
|
exports.isAdvanceBookingRequired = isAdvanceBookingRequired;
|
|
14
18
|
exports.legDropoffRequiresAdvanceBooking = legDropoffRequiresAdvanceBooking;
|
|
19
|
+
exports.isFlex = isFlex;
|
|
15
20
|
exports.isRideshareLeg = isRideshareLeg;
|
|
16
21
|
exports.isWalk = isWalk;
|
|
17
22
|
exports.isBicycle = isBicycle;
|
|
@@ -32,6 +37,7 @@ exports.getItineraryBounds = getItineraryBounds;
|
|
|
32
37
|
exports.getLegBounds = getLegBounds;
|
|
33
38
|
exports.legLocationAtDistance = legLocationAtDistance;
|
|
34
39
|
exports.legElevationAtDistance = legElevationAtDistance;
|
|
40
|
+
exports.mapOldElevationComponentToNew = mapOldElevationComponentToNew;
|
|
35
41
|
exports.getElevationProfile = getElevationProfile;
|
|
36
42
|
exports.getTextWidth = getTextWidth;
|
|
37
43
|
exports.getCompanyForNetwork = getCompanyForNetwork;
|
|
@@ -63,6 +69,10 @@ function getTransitModes(config) {
|
|
|
63
69
|
return config.modes.transitModes.map(tm => typeof tm !== "string" ? tm.mode : tm);
|
|
64
70
|
}
|
|
65
71
|
|
|
72
|
+
function isTransitLeg(leg) {
|
|
73
|
+
return leg.transitLeg;
|
|
74
|
+
}
|
|
75
|
+
|
|
66
76
|
function isTransit(mode) {
|
|
67
77
|
return transitModes.includes(mode) || mode === "TRANSIT";
|
|
68
78
|
}
|
|
@@ -74,7 +84,7 @@ function isTransit(mode) {
|
|
|
74
84
|
|
|
75
85
|
|
|
76
86
|
function isReservationRequired(leg) {
|
|
77
|
-
return leg.boardRule === "mustPhone" || leg.alightRule === "mustPhone";
|
|
87
|
+
return (leg === null || leg === void 0 ? void 0 : leg.boardRule) === "mustPhone" || (leg === null || leg === void 0 ? void 0 : leg.alightRule) === "mustPhone";
|
|
78
88
|
}
|
|
79
89
|
/**
|
|
80
90
|
* Returns true if a user must ask the driver to let the user off
|
|
@@ -84,16 +94,25 @@ function isReservationRequired(leg) {
|
|
|
84
94
|
|
|
85
95
|
|
|
86
96
|
function isCoordinationRequired(leg) {
|
|
87
|
-
return leg.boardRule === "coordinateWithDriver" || leg.alightRule === "coordinateWithDriver";
|
|
97
|
+
return (leg === null || leg === void 0 ? void 0 : leg.boardRule) === "coordinateWithDriver" || (leg === null || leg === void 0 ? void 0 : leg.alightRule) === "coordinateWithDriver";
|
|
88
98
|
}
|
|
89
|
-
/**
|
|
90
|
-
* The two rules checked by the above two functions are the only values
|
|
91
|
-
* returned by OTP when a leg is a flex leg.
|
|
92
|
-
*/
|
|
93
99
|
|
|
100
|
+
function containsGeometry(place) {
|
|
101
|
+
var _place$stop, _place$stop2;
|
|
94
102
|
|
|
95
|
-
|
|
96
|
-
|
|
103
|
+
return (place === null || place === void 0 ? void 0 : (_place$stop = place.stop) === null || _place$stop === void 0 ? void 0 : _place$stop.geometries) !== null && (place === null || place === void 0 ? void 0 : (_place$stop2 = place.stop) === null || _place$stop2 === void 0 ? void 0 : _place$stop2.geometries) !== undefined;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function endsWithGeometry(leg) {
|
|
107
|
+
return containsGeometry(leg === null || leg === void 0 ? void 0 : leg.to);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function startsWithGeometry(leg) {
|
|
111
|
+
return containsGeometry(leg === null || leg === void 0 ? void 0 : leg.from);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function legContainsGeometry(leg) {
|
|
115
|
+
return endsWithGeometry(leg) || startsWithGeometry(leg);
|
|
97
116
|
}
|
|
98
117
|
|
|
99
118
|
function isAdvanceBookingRequired(info) {
|
|
@@ -103,9 +122,17 @@ function isAdvanceBookingRequired(info) {
|
|
|
103
122
|
}
|
|
104
123
|
|
|
105
124
|
function legDropoffRequiresAdvanceBooking(leg) {
|
|
106
|
-
return isAdvanceBookingRequired(leg.dropOffBookingInfo);
|
|
107
|
-
}
|
|
125
|
+
return isAdvanceBookingRequired(leg === null || leg === void 0 ? void 0 : leg.dropOffBookingInfo);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* The two rules checked by the above two functions are the only values
|
|
129
|
+
* returned by OTP when a leg is a flex leg.
|
|
130
|
+
*/
|
|
131
|
+
|
|
108
132
|
|
|
133
|
+
function isFlex(leg) {
|
|
134
|
+
return isReservationRequired(leg) || isCoordinationRequired(leg) || legDropoffRequiresAdvanceBooking(leg) || isAdvanceBookingRequired(leg === null || leg === void 0 ? void 0 : leg.pickupBookingInfo) || legContainsGeometry(leg);
|
|
135
|
+
}
|
|
109
136
|
|
|
110
137
|
function isRideshareLeg(leg) {
|
|
111
138
|
var _leg$rideHailingEstim, _leg$rideHailingEstim2;
|
|
@@ -339,6 +366,13 @@ function legElevationAtDistance(points, distance) {
|
|
|
339
366
|
|
|
340
367
|
console.warn("Elevation value does not exist for distance.", distance, traversed);
|
|
341
368
|
return null;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
function mapOldElevationComponentToNew(oldElev) {
|
|
372
|
+
return {
|
|
373
|
+
distance: oldElev.first,
|
|
374
|
+
elevation: oldElev.second
|
|
375
|
+
};
|
|
342
376
|
} // Iterate through the steps, building the array of elevation points and
|
|
343
377
|
// keeping track of the minimum and maximum elevations reached
|
|
344
378
|
|
|
@@ -352,29 +386,34 @@ function getElevationProfile(steps, unitConversion = 1) {
|
|
|
352
386
|
let previous = null;
|
|
353
387
|
const points = [];
|
|
354
388
|
steps.forEach(step => {
|
|
355
|
-
|
|
389
|
+
var _step$elevation;
|
|
390
|
+
|
|
391
|
+
// Support for old REST response data (in step.elevation)
|
|
392
|
+
const stepElevationProfile = step.elevationProfile || Array.isArray(step.elevation) && ((_step$elevation = step.elevation) === null || _step$elevation === void 0 ? void 0 : _step$elevation.map(mapOldElevationComponentToNew));
|
|
393
|
+
|
|
394
|
+
if (!stepElevationProfile || stepElevationProfile.length === 0) {
|
|
356
395
|
traversed += step.distance;
|
|
357
396
|
return;
|
|
358
397
|
}
|
|
359
398
|
|
|
360
|
-
for (let i = 0; i <
|
|
361
|
-
const elev =
|
|
399
|
+
for (let i = 0; i < stepElevationProfile.length; i++) {
|
|
400
|
+
const elev = stepElevationProfile[i];
|
|
362
401
|
|
|
363
402
|
if (previous) {
|
|
364
|
-
const diff = (elev.
|
|
403
|
+
const diff = (elev.elevation - previous.elevation) * unitConversion;
|
|
365
404
|
if (diff > 0) gain += diff;else loss += diff;
|
|
366
405
|
}
|
|
367
406
|
|
|
368
|
-
if (i === 0 && elev.
|
|
407
|
+
if (i === 0 && elev.distance !== 0) {// console.warn(`No elevation data available for step ${stepIndex}-${i} at beginning of segment`, elev)
|
|
369
408
|
}
|
|
370
409
|
|
|
371
|
-
const convertedElevation = elev.
|
|
410
|
+
const convertedElevation = elev.elevation * unitConversion;
|
|
372
411
|
if (convertedElevation < minElev) minElev = convertedElevation;
|
|
373
412
|
if (convertedElevation > maxElev) maxElev = convertedElevation;
|
|
374
|
-
points.push([traversed + elev.
|
|
413
|
+
points.push([traversed + elev.distance, elev.elevation]); // Insert "filler" point if the last point in elevation profile does not
|
|
375
414
|
// reach the full distance of the step.
|
|
376
415
|
|
|
377
|
-
if (i ===
|
|
416
|
+
if (i === stepElevationProfile.length - 1 && elev.distance !== step.distance) {// points.push([traversed + step.distance, elev.second])
|
|
378
417
|
}
|
|
379
418
|
|
|
380
419
|
previous = elev;
|
|
@@ -435,9 +474,7 @@ function getCompanyForNetwork(networkString, companies = []) {
|
|
|
435
474
|
|
|
436
475
|
|
|
437
476
|
function getCompaniesLabelFromNetworks(networks, companies = []) {
|
|
438
|
-
|
|
439
|
-
if (typeof networks === "string") networksArray = [networks];
|
|
440
|
-
return networksArray.map(network => getCompanyForNetwork(network, companies)).filter(co => !!co).map(co => co.label).join("/");
|
|
477
|
+
return (Array.isArray(networks) ? networks : [networks]).map(network => getCompanyForNetwork(network, companies)).filter(co => !!co).map(co => co.label).join("/");
|
|
441
478
|
}
|
|
442
479
|
|
|
443
480
|
function getTNCLocation(leg, type) {
|
package/lib/itinerary.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/itinerary.ts"],"names":["transitModes","getTransitModes","config","modes","map","tm","mode","isTransit","includes","isReservationRequired","leg","boardRule","alightRule","isCoordinationRequired","isFlex","isAdvanceBookingRequired","info","latestBookingTime","daysPrior","legDropoffRequiresAdvanceBooking","dropOffBookingInfo","isRideshareLeg","rideHailingEstimate","provider","id","isWalk","isBicycle","isBicycleRent","isCar","startsWith","isMicromobility","isAccessMode","hasTransit","modesStr","split","some","hasCar","hasBike","hasMicromobility","hasHail","indexOf","hasRental","getMapColor","get","toSentenceCase","str","String","charAt","toUpperCase","substr","toLowerCase","getCompanyFromLeg","from","rentedBike","rentedCar","rentedVehicle","networks","rentalVehicle","network","getItineraryBounds","itinerary","coords","legs","forEach","legCoords","polyline","toGeoJSON","legGeometry","points","coordinates","c","getLegBounds","length","push","lat","lon","to","legLocationAtDistance","distance","line","pt","units","geometry","e","legElevationAtDistance","traversed","unshift","i","start","elevDistanceSpan","console","warn","pct","elevSpan","getElevationProfile","steps","unitConversion","minElev","maxElev","gain","loss","previous","step","elevation","elev","diff","second","first","convertedElevation","getTextWidth","text","font","canvas","document","createElement","context","getContext","metrics","measureText","width","getCompanyForNetwork","networkString","companies","company","find","co","getCompaniesLabelFromNetworks","networksArray","filter","label","join","getTNCLocation","type","location","toFixed","calculatePhysicalActivity","walkDuration","bikeDuration","duration","caloriesBurned","calculateTncFares","reduce","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","carbonIntensity","carbonIntensityWithDefaults","totalCarbon","total","getDisplayedStopId","placeOrStop","stopId","stopCode","getLegCost","mediumId","riderCategoryId","fareProducts","price","undefined","relevantFareProducts","product","riderCategory","medium","totalCostProduct","fp","name","transferFareProduct","transferAmount","productUseId","getItineraryCost","legCosts","cost","prev","cur","p","productUse","pickupDropoffTypeToOtp1","otp2Type","convertGraphQLResponseToLegacy","agencyBrandingUrl","agency","url","agencyId","agencyName","agencyUrl","dropoffType","pickupType","stop","gtfsId","route","shortName","routeColor","color","routeId","routeLongName","longName","routeShortName","routeTextColor","textColor","tripHeadsign","trip","tripId","getLegRouteShortName","getLegRouteLongName","getLegRouteName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAgBA;;AAEA;AACO,MAAMA,YAAY,GAAG,CAC1B,MAD0B,EAE1B,YAF0B,EAG1B,KAH0B,EAI1B,QAJ0B,EAK1B,OAL0B,EAM1B,MAN0B,EAO1B,SAP0B,CAArB;AAUP;AACA;AACA;AACA;;;;AAEO,SAASC,eAAT,CAAyBC,MAAzB,EAAmD;AACxD,MAAI,CAACA,MAAD,IAAW,CAACA,MAAM,CAACC,KAAnB,IAA4B,CAACD,MAAM,CAACC,KAAP,CAAaH,YAA9C,EACE,OAAOA,YAAP;AAEF,SAAOE,MAAM,CAACC,KAAP,CAAaH,YAAb,CAA0BI,GAA1B,CAA8BC,EAAE,IACrC,OAAOA,EAAP,KAAc,QAAd,GAAyBA,EAAE,CAACC,IAA5B,GAAmCD,EAD9B,CAAP;AAGD;;AAEM,SAASE,SAAT,CAAmBD,IAAnB,EAA0C;AAC/C,SAAON,YAAY,CAACQ,QAAb,CAAsBF,IAAtB,KAA+BA,IAAI,KAAK,SAA/C;AACD;AAED;AACA;AACA;AACA;AACA;;;AACO,SAASG,qBAAT,CAA+BC,GAA/B,EAAkD;AACvD,SAAOA,GAAG,CAACC,SAAJ,KAAkB,WAAlB,IAAiCD,GAAG,CAACE,UAAJ,KAAmB,WAA3D;AACD;AACD;AACA;AACA;AACA;AACA;;;AACO,SAASC,sBAAT,CAAgCH,GAAhC,EAAmD;AACxD,SACEA,GAAG,CAACC,SAAJ,KAAkB,sBAAlB,IACAD,GAAG,CAACE,UAAJ,KAAmB,sBAFrB;AAID;AACD;AACA;AACA;AACA;;;AACO,SAASE,MAAT,CAAgBJ,GAAhB,EAAmC;AACxC,SAAOD,qBAAqB,CAACC,GAAD,CAArB,IAA8BG,sBAAsB,CAACH,GAAD,CAA3D;AACD;;AAEM,SAASK,wBAAT,CAAkCC,IAAlC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IAAAA;AAAT,MAA2B/M,GAAjC,CADkB,CAElB;;AACA,SAAO,OAAO0M,KAAP,KAAiB,QAAjB,GAA4BA,KAA5B,aAA4BA,KAA5B,uBAA4BA,KAAK,CAAEM,QAAnC,GAA8CD,aAArD;AACD,CANM;AAQP;AACA;AACA;AACA;;;;;AACO,MAAMU,eAAe,GAC1BzN,GAD6B,IAElB;AACX,SAAOuN,oBAAoB,CAACvN,GAAD,CAApB,IAA6BwN,mBAAmB,CAACxN,GAAD,CAAvD;AACD,CAJM","sourcesContent":["import polyline from \"@mapbox/polyline\";\nimport {\n Company,\n Config,\n ElevationProfile,\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 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/**\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 isReservationRequired(leg) || isCoordinationRequired(leg);\n}\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// alpha-only comment\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 (\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\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 = null;\n const points = [];\n steps.forEach(step => {\n if (!step.elevation || step.elevation.length === 0) {\n traversed += step.distance;\n return;\n }\n for (let i = 0; i < step.elevation.length; i++) {\n const elev = step.elevation[i];\n if (previous) {\n const diff = (elev.second - previous.second) * unitConversion;\n if (diff > 0) gain += diff;\n else loss += diff;\n }\n if (i === 0 && elev.first !== 0) {\n // console.warn(`No elevation data available for step ${stepIndex}-${i} at beginning of segment`, elev)\n }\n const convertedElevation = elev.second * unitConversion;\n if (convertedElevation < minElev) minElev = convertedElevation;\n if (convertedElevation > maxElev) maxElev = convertedElevation;\n points.push([traversed + elev.first, elev.second]);\n // Insert \"filler\" point if the last point in elevation profile does not\n // reach the full distance of the step.\n if (i === step.elevation.length - 1 && elev.first !== step.distance) {\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.\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 let networksArray = networks;\n if (typeof networks === \"string\") networksArray = [networks];\n\n return (networksArray as string[])\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 id to display for a stop or place, using the following priority:\n * 1. stop code,\n * 2. stop id without the agency id portion, if stop id contains an agency portion,\n * 3. stop id, whether null or not (this is the fallback case).\n */\nexport function getDisplayedStopId(placeOrStop: Place | Stop): string {\n let stopId;\n let stopCode;\n if (\"stopId\" in placeOrStop) {\n ({ stopCode, stopId } = placeOrStop);\n } else if (\"id\" in placeOrStop) {\n ({ code: stopCode, id: stopId } = placeOrStop);\n }\n return stopCode || stopId?.split(\":\")[1] || stopId;\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 fare products (must have used getLegsWithFares)\n * @param category Rider category\n * @param container Fare container (cash, electronic)\n * @returns Object containing price as well as the transfer discount amount, if a transfer was used.\n */\nexport function getLegCost(\n leg: Leg,\n mediumId: string | null,\n riderCategoryId: string | null\n): {\n price?: Money;\n transferAmount?: Money | undefined;\n productUseId?: string;\n} {\n if (!leg.fareProducts) return { price: undefined };\n const relevantFareProducts = leg.fareProducts.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 return (\n (product.riderCategory === null ? null : product.riderCategory.id) ===\n riderCategoryId &&\n (product.medium === null ? null : product.medium.id) === mediumId\n );\n });\n\n // Custom fare models return \"rideCost\", generic GTFS fares return \"regular\"\n const totalCostProduct = relevantFareProducts.find(\n fp => fp.product.name === \"rideCost\" || fp.product.name === \"regular\"\n );\n const transferFareProduct = relevantFareProducts.find(\n fp => fp.product.name === \"transfer\"\n );\n\n return {\n price: totalCostProduct?.product.price,\n transferAmount: transferFareProduct?.product.price,\n productUseId: totalCostProduct?.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 * @returns Money object for the total itinerary cost.\n */\nexport function getItineraryCost(\n legs: Leg[],\n mediumId: string | null,\n riderCategoryId: string | null\n): Money | undefined {\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 .map(leg => getLegCost(leg, mediumId, riderCategoryId))\n .filter(cost => cost.price !== undefined)\n // Filter 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 .reduce<{ productUseId: string; price: Money }[]>((prev, cur) => {\n if (!prev.some(p => p.productUseId === cur.productUseId)) {\n prev.push({ productUseId: cur.productUseId, price: cur.price });\n }\n return prev;\n }, [])\n .map(productUse => productUse.price);\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 => {\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 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"],"file":"itinerary.js"}
|
|
1
|
+
{"version":3,"sources":["../src/itinerary.ts"],"names":["transitModes","getTransitModes","config","modes","map","tm","mode","isTransitLeg","leg","transitLeg","isTransit","includes","isReservationRequired","boardRule","alightRule","isCoordinationRequired","containsGeometry","place","stop","geometries","undefined","endsWithGeometry","to","startsWithGeometry","from","legContainsGeometry","isAdvanceBookingRequired","info","latestBookingTime","daysPrior","legDropoffRequiresAdvanceBooking","dropOffBookingInfo","isFlex","pickupBookingInfo","isRideshareLeg","rideHailingEstimate","provider","id","isWalk","isBicycle","isBicycleRent","isCar","startsWith","isMicromobility","isAccessMode","hasTransit","modesStr","split","some","hasCar","hasBike","hasMicromobility","hasHail","indexOf","hasRental","getMapColor","get","toSentenceCase","str","String","charAt","toUpperCase","substr","toLowerCase","getCompanyFromLeg","rentedBike","rentedCar","rentedVehicle","networks","rentalVehicle","network","getItineraryBounds","itinerary","coords","legs","forEach","legCoords","polyline","toGeoJSON","legGeometry","points","coordinates","c","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","minElev","maxElev","gain","loss","previous","step","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","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","carbonIntensity","carbonIntensityWithDefaults","totalCarbon","total","getDisplayedStopId","placeOrStop","stopId","stopCode","getLegCost","mediumId","riderCategoryId","fareProducts","price","relevantFareProducts","product","riderCategory","medium","totalCostProduct","fp","name","transferFareProduct","transferAmount","productUseId","getItineraryCost","legCosts","cost","prev","cur","p","productUse","pickupDropoffTypeToOtp1","otp2Type","convertGraphQLResponseToLegacy","agencyBrandingUrl","agency","url","agencyId","agencyName","agencyUrl","dropoffType","pickupType","gtfsId","route","shortName","routeColor","color","routeId","routeLongName","longName","routeShortName","routeTextColor","textColor","tripHeadsign","trip","tripId","getLegRouteShortName","getLegRouteLongName","getLegRouteName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AA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KAAF;AAASK,IAAAA;AAAT,MAA2B/N,GAAjC,CADkB,CAElB;;AACA,SAAO,OAAO0N,KAAP,KAAiB,QAAjB,GAA4BA,KAA5B,aAA4BA,KAA5B,uBAA4BA,KAAK,CAAEM,QAAnC,GAA8CD,aAArD;AACD,CANM;AAQP;AACA;AACA;AACA;;;;;AACO,MAAMU,eAAe,GAC1BzO,GAD6B,IAElB;AACX,SAAOuO,oBAAoB,CAACvO,GAAD,CAApB,IAA6BwO,mBAAmB,CAACxO,GAAD,CAAvD;AACD,CAJM","sourcesContent":["import polyline from \"@mapbox/polyline\";\nimport {\n Company,\n Config,\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 isReservationRequired(leg) ||\n isCoordinationRequired(leg) ||\n legDropoffRequiresAdvanceBooking(leg) ||\n isAdvanceBookingRequired(leg?.pickupBookingInfo) ||\n legContainsGeometry(leg)\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 (\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.\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 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 id to display for a stop or place, using the following priority:\n * 1. stop code,\n * 2. stop id without the agency id portion, if stop id contains an agency portion,\n * 3. stop id, whether null or not (this is the fallback case).\n */\nexport function getDisplayedStopId(placeOrStop: Place | Stop): string {\n let stopId;\n let stopCode;\n if (\"stopId\" in placeOrStop) {\n ({ stopCode, stopId } = placeOrStop);\n } else if (\"id\" in placeOrStop) {\n ({ code: stopCode, id: stopId } = placeOrStop);\n }\n return stopCode || stopId?.split(\":\")[1] || stopId;\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 fare products (must have used getLegsWithFares)\n * @param category Rider category\n * @param container Fare container (cash, electronic)\n * @returns Object containing price as well as the transfer discount amount, if a transfer was used.\n */\nexport function getLegCost(\n leg: Leg,\n mediumId: string | null,\n riderCategoryId: string | null\n): {\n price?: Money;\n transferAmount?: Money | undefined;\n productUseId?: string;\n} {\n if (!leg.fareProducts) return { price: undefined };\n const relevantFareProducts = leg.fareProducts.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 return (\n (product.riderCategory === null ? null : product.riderCategory.id) ===\n riderCategoryId &&\n (product.medium === null ? null : product.medium.id) === mediumId\n );\n });\n\n // Custom fare models return \"rideCost\", generic GTFS fares return \"regular\"\n const totalCostProduct = relevantFareProducts.find(\n fp => fp.product.name === \"rideCost\" || fp.product.name === \"regular\"\n );\n const transferFareProduct = relevantFareProducts.find(\n fp => fp.product.name === \"transfer\"\n );\n\n return {\n price: totalCostProduct?.product.price,\n transferAmount: transferFareProduct?.product.price,\n productUseId: totalCostProduct?.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 * @returns Money object for the total itinerary cost.\n */\nexport function getItineraryCost(\n legs: Leg[],\n mediumId: string | null,\n riderCategoryId: string | null\n): Money | undefined {\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 .map(leg => getLegCost(leg, mediumId, riderCategoryId))\n .filter(cost => cost.price !== undefined)\n // Filter 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 .reduce<{ productUseId: string; price: Money }[]>((prev, cur) => {\n if (!prev.some(p => p.productUseId === cur.productUseId)) {\n prev.push({ productUseId: cur.productUseId, price: cur.price });\n }\n return prev;\n }, [])\n .map(productUse => productUse.price);\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 => {\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 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"],"file":"itinerary.js"}
|