@opentripplanner/core-utils 4.11.4 → 5.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 (81) hide show
  1. package/esm/deprecated-with-types.js +47 -0
  2. package/esm/deprecated-with-types.js.map +1 -0
  3. package/esm/deprecated.js +7 -0
  4. package/esm/deprecated.js.map +1 -1
  5. package/esm/index.js +0 -4
  6. package/esm/index.js.map +1 -1
  7. package/esm/itinerary.js +3 -9
  8. package/esm/itinerary.js.map +1 -1
  9. package/esm/map.js +2 -1
  10. package/esm/map.js.map +1 -1
  11. package/esm/query-params.js +5 -12
  12. package/esm/query-params.js.map +1 -1
  13. package/esm/route.js +5 -3
  14. package/esm/route.js.map +1 -1
  15. package/esm/storage.js +1 -0
  16. package/esm/storage.js.map +1 -1
  17. package/esm/time.js +6 -36
  18. package/esm/time.js.map +1 -1
  19. package/esm/ui.js +1 -1
  20. package/esm/ui.js.map +1 -1
  21. package/lib/deprecated-with-types.d.ts +23 -0
  22. package/lib/deprecated-with-types.d.ts.map +1 -0
  23. package/lib/deprecated-with-types.js +61 -0
  24. package/lib/deprecated-with-types.js.map +1 -0
  25. package/lib/deprecated.js +9 -0
  26. package/lib/deprecated.js.map +1 -1
  27. package/lib/index.d.ts +19 -0
  28. package/lib/index.d.ts.map +1 -0
  29. package/lib/index.js +0 -6
  30. package/lib/index.js.map +1 -1
  31. package/lib/itinerary.d.ts +113 -0
  32. package/lib/itinerary.d.ts.map +1 -0
  33. package/lib/itinerary.js +8 -9
  34. package/lib/itinerary.js.map +1 -1
  35. package/lib/map.d.ts +30 -0
  36. package/lib/map.d.ts.map +1 -0
  37. package/lib/map.js +1 -0
  38. package/lib/map.js.map +1 -1
  39. package/lib/query-params.js +4 -11
  40. package/lib/query-params.js.map +1 -1
  41. package/lib/route.d.ts +98 -0
  42. package/lib/route.d.ts.map +1 -0
  43. package/lib/route.js +5 -3
  44. package/lib/route.js.map +1 -1
  45. package/lib/storage.d.ts +19 -0
  46. package/lib/storage.d.ts.map +1 -0
  47. package/lib/storage.js +2 -0
  48. package/lib/storage.js.map +1 -1
  49. package/lib/time.d.ts +65 -0
  50. package/lib/time.d.ts.map +1 -0
  51. package/lib/time.js +22 -39
  52. package/lib/time.js.map +1 -1
  53. package/lib/ui.d.ts +13 -0
  54. package/lib/ui.d.ts.map +1 -0
  55. package/lib/ui.js +1 -1
  56. package/lib/ui.js.map +1 -1
  57. package/package.json +4 -1
  58. package/src/__tests__/__snapshots__/query.js.snap +0 -8
  59. package/src/__tests__/__snapshots__/route.js.snap +30 -30
  60. package/src/deprecated-with-types.ts +62 -0
  61. package/src/deprecated.js +16 -0
  62. package/src/{index.js → index.ts} +0 -4
  63. package/src/{itinerary.js → itinerary.ts} +72 -50
  64. package/src/{map.js → map.ts} +41 -20
  65. package/src/query-params.js +3 -11
  66. package/src/{route.js → route.ts} +52 -28
  67. package/src/{storage.js → storage.ts} +6 -5
  68. package/src/{time.js → time.ts} +28 -46
  69. package/src/{ui.js → ui.ts} +8 -8
  70. package/tsconfig.json +15 -0
  71. package/tsconfig.tsbuildinfo +4921 -0
  72. package/esm/messages.js +0 -25
  73. package/esm/messages.js.map +0 -1
  74. package/esm/types.js +0 -560
  75. package/esm/types.js.map +0 -1
  76. package/lib/messages.js +0 -29
  77. package/lib/messages.js.map +0 -1
  78. package/lib/types.js +0 -661
  79. package/lib/types.js.map +0 -1
  80. package/src/messages.js +0 -20
  81. package/src/types.js +0 -605
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deprecated-with-types.d.ts","sourceRoot":"","sources":["../src/deprecated-with-types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAYrD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,MAAM,CAOnE;AAED;;;;;GAKG;AAEH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAOtE;AAED;;;;;GAKG;AAEH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,MAAM,CAOR"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.formatTime = formatTime;
7
+ exports.formatDuration = formatDuration;
8
+ exports.formatDurationWithSeconds = formatDurationWithSeconds;
9
+
10
+ var _dateFns = require("date-fns");
11
+
12
+ var _deprecated = require("./deprecated");
13
+
14
+ var _time = require("./time");
15
+
16
+ /* eslint-disable import/no-cycle */
17
+ // time.ts
18
+
19
+ /**
20
+ * Formats a time value for display in narrative
21
+ * TODO: internationalization/timezone
22
+ * @param {number} ms epoch time value in milliseconds
23
+ * @returns {string} formatted text representation
24
+ */
25
+ function formatTime(ms, options) {
26
+ (0, _deprecated.logDeprecationWarning)("formatTime", "formatjs");
27
+ return (0, _dateFns.format)((0, _time.offsetTime)(ms, options), (options === null || options === void 0 ? void 0 : options.format) || _time.OTP_API_TIME_FORMAT);
28
+ }
29
+ /**
30
+ * Formats an elapsed time duration for display in narrative.
31
+ * TODO: internationalization
32
+ * @param {number} seconds duration in seconds
33
+ * @returns {string} formatted text representation
34
+ */
35
+ // TS TODO: region as type?
36
+
37
+
38
+ function formatDuration(seconds, region) {
39
+ (0, _deprecated.logDeprecationWarning)("formatDuration", "formatjs");
40
+ return (0, _time.formatDurationLikeMoment)(seconds, false, {
41
+ enabled: true,
42
+ code: region
43
+ });
44
+ }
45
+ /**
46
+ * Formats an elapsed time in seconds, minutes, hours duration for display in narrative
47
+ * @param {number} seconds duration in seconds
48
+ * @param {object} region an object that allows internationalization of the time
49
+ * @returns {string} formatted text representation
50
+ */
51
+ // TS TODO: region as type?
52
+
53
+
54
+ function formatDurationWithSeconds(seconds, region) {
55
+ (0, _deprecated.logDeprecationWarning)("formatDurationWithSeconds", "formatjs");
56
+ return (0, _time.formatDurationLikeMoment)(seconds, true, {
57
+ enabled: true,
58
+ code: region
59
+ });
60
+ }
61
+ //# sourceMappingURL=deprecated-with-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/deprecated-with-types.ts"],"names":["formatTime","ms","options","format","OTP_API_TIME_FORMAT","formatDuration","seconds","region","enabled","code","formatDurationWithSeconds"],"mappings":";;;;;;;;;AAEA;;AAEA;;AACA;;AALA;AAWA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,UAAT,CAAoBC,EAApB,EAAgCC,OAAhC,EAA8D;AACnE,yCAAsB,YAAtB,EAAoC,UAApC;AAEA,SAAO,qBACL,sBAAWD,EAAX,EAAeC,OAAf,CADK,EAEL,CAAAA,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEC,MAAT,KAAmBC,yBAFd,CAAP;AAID;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,cAAT,CAAwBC,OAAxB,EAAyCC,MAAzC,EAAiE;AACtE,yCAAsB,gBAAtB,EAAwC,UAAxC;AAEA,SAAO,oCAAyBD,OAAzB,EAAkC,KAAlC,EAAyC;AAC9CE,IAAAA,OAAO,EAAE,IADqC;AAE9CC,IAAAA,IAAI,EAAEF;AAFwC,GAAzC,CAAP;AAID;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASG,yBAAT,CACLJ,OADK,EAELC,MAFK,EAGG;AACR,yCAAsB,2BAAtB,EAAmD,UAAnD;AAEA,SAAO,oCAAyBD,OAAzB,EAAkC,IAAlC,EAAwC;AAC7CE,IAAAA,OAAO,EAAE,IADoC;AAE7CC,IAAAA,IAAI,EAAEF;AAFuC,GAAxC,CAAP;AAID","sourcesContent":["/* eslint-disable import/no-cycle */\nimport { TimeOptions } from \"@opentripplanner/types\";\nimport { format } from \"date-fns\";\n\nimport { logDeprecationWarning } from \"./deprecated\";\nimport {\n formatDurationLikeMoment,\n offsetTime,\n OTP_API_TIME_FORMAT\n} from \"./time\";\n\n// time.ts\n\n/**\n * Formats a time value for display in narrative\n * TODO: internationalization/timezone\n * @param {number} ms epoch time value in milliseconds\n * @returns {string} formatted text representation\n */\nexport function formatTime(ms: number, options: TimeOptions): string {\n logDeprecationWarning(\"formatTime\", \"formatjs\");\n\n return format(\n offsetTime(ms, options),\n options?.format || OTP_API_TIME_FORMAT\n );\n}\n\n/**\n * Formats an elapsed time duration for display in narrative.\n * TODO: internationalization\n * @param {number} seconds duration in seconds\n * @returns {string} formatted text representation\n */\n// TS TODO: region as type?\nexport function formatDuration(seconds: number, region: string): string {\n logDeprecationWarning(\"formatDuration\", \"formatjs\");\n\n return formatDurationLikeMoment(seconds, false, {\n enabled: true,\n code: region\n });\n}\n\n/**\n * Formats an elapsed time in seconds, minutes, hours duration for display in narrative\n * @param {number} seconds duration in seconds\n * @param {object} region an object that allows internationalization of the time\n * @returns {string} formatted text representation\n */\n// TS TODO: region as type?\nexport function formatDurationWithSeconds(\n seconds: number,\n region: string\n): string {\n logDeprecationWarning(\"formatDurationWithSeconds\", \"formatjs\");\n\n return formatDurationLikeMoment(seconds, true, {\n enabled: true,\n code: region\n });\n}\n"],"file":"deprecated-with-types.js"}
package/lib/deprecated.js CHANGED
@@ -18,6 +18,7 @@ exports.latlngToString = latlngToString;
18
18
  exports.coordsToString = coordsToString;
19
19
  exports.getDetailText = getDetailText;
20
20
  exports.summarizeQuery = summarizeQuery;
21
+ exports.getTimeZoneOffset = getTimeZoneOffset;
21
22
 
22
23
  var _moment = _interopRequireDefault(require("moment"));
23
24
 
@@ -343,4 +344,12 @@ function summarizeQuery(query, locations = []) {
343
344
  const mode = require("./itinerary").hasTransit(query.mode) ? "Transit" : require("./itinerary").toSentenceCase(query.mode);
344
345
  return `${mode} from ${from} to ${to}`;
345
346
  }
347
+
348
+ function getTimeZoneOffset(itinerary) {
349
+ logDeprecationWarning("getTimeZoneOffset");
350
+ if (!itinerary.legs || !itinerary.legs.length) return 0; // Determine if there is a DST offset between now and the itinerary start date
351
+
352
+ const dstOffset = new Date(itinerary.startTime).getTimezoneOffset() - new Date().getTimezoneOffset();
353
+ return itinerary.legs[0].agencyTimeZoneOffset + (new Date().getTimezoneOffset() + dstOffset) * 60000;
354
+ }
346
355
  //# sourceMappingURL=deprecated.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/deprecated.js"],"names":["logDeprecationWarning","method","alternative","console","warn","getStepDirection","step","relativeDirection","absoluteDirection","toLowerCase","getStepInstructions","conjunction","streetName","getStepStreetName","getLegModeLabel","leg","mode","hailedCar","routeLongName","indexOf","require","toSentenceCase","getModeForPlace","place","vertexType","getPlaceName","companies","address","split","networks","company","getCompanyForNetwork","label","name","getTransitFare","fareComponent","digits","transitFare","symbol","currencyCode","defaultFractionDigits","currency","cents","centsToString","dollars","toFixed","dollarsToString","calculateFares","itinerary","multiple","minTNCFare","maxTNCFare","tncCurrencyCode","legs","forEach","tncData","maxCost","minCost","transitFares","fare","Object","keys","fareKey","regular","transitCurrencyCode","latlngToString","latlng","lat","lng","lon","coordsToString","coords","length","map","c","join","getDetailText","location","detailText","type","id","timestamp","fromNow","summarizeQuery","query","locations","findLocationType","ls","types","match","find","l","matchLatLon","from","to","hasTransit"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AAEA;AACA;AACA;AACA;;AACA;;AAEA;AACA;AACA;AACO,SAASA,qBAAT,CAA+BC,MAA/B,EAAuCC,WAAvC,EAAoD;AACzDC,EAAAA,OAAO,CAACC,IAAR,CACG,GAAEH,MAAM,IACP,aAAc;AACpB,UACUC,WAAW,GACN;AACf;AACA,cAAcA,WAAY,+EAHL,GAIP,EACL,EATP;AAWD,C,CAED;;;AAEO,SAASG,gBAAT,CAA0BC,IAA1B,EAAgC;AACrCN,EAAAA,qBAAqB,CAAC,kBAAD,CAArB;;AAEA,UAAQM,IAAI,CAACC,iBAAb;AACE,SAAK,QAAL;AACE,aAAQ,QAAOD,IAAI,CAACE,iBAAL,CAAu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IAA5C,CAFJ;AAGA,SAAQ,GAAEA,IAAK,SAAQ6E,IAAK,OAAMC,EAAG,EAArC;AACD","sourcesContent":["import moment from \"moment\";\n\n/**\n * To disable cyclic dependency resolution we need to require() within methods\n * This is a good reason to disable this eslint-rule\n */\n/* eslint-disable global-require */\n\n/**\n * Generates a warning to tell developer that they are using deprecated methods!\n */\nexport function logDeprecationWarning(method, alternative) {\n console.warn(\n `${method ||\n \"This method\"} is deprecated and will be removed in a future otp-ui release. All language functionality should be handled using react-intl.\n ${\n alternative\n ? `\n\n Use ${alternative} instead, which provides a new interface that doesn't return English strings.`\n : \"\"\n }`\n );\n}\n\n// itinerary.js\n\nexport function getStepDirection(step) {\n logDeprecationWarning(\"getStepDirection\");\n\n switch (step.relativeDirection) {\n case \"DEPART\":\n return `Head ${step.absoluteDirection.toLowerCase()}`;\n case \"LEFT\":\n return \"Left\";\n case \"HARD_LEFT\":\n return \"Hard left\";\n case \"SLIGHTLY_LEFT\":\n return \"Slight left\";\n case \"CONTINUE\":\n return \"Continue\";\n case \"SLIGHTLY_RIGHT\":\n return \"Slight right\";\n case \"RIGHT\":\n return \"Right\";\n case \"HARD_RIGHT\":\n return \"Hard right\";\n case \"CIRCLE_CLOCKWISE\":\n return \"Follow circle clockwise\";\n case \"CIRCLE_COUNTERCLOCKWISE\":\n return \"Follow circle counterclockwise\";\n case \"ELEVATOR\":\n return \"Take elevator\";\n case \"UTURN_LEFT\":\n return \"Left U-turn\";\n case \"UTURN_RIGHT\":\n return \"Right U-turn\";\n default:\n return step.relativeDirection;\n }\n}\n\nexport function getStepInstructions(step) {\n logDeprecationWarning(\"getStepInstructions\");\n\n const conjunction = step.relativeDirection === \"ELEVATOR\" ? \"to\" : \"on\";\n return `${getStepDirection(step)} ${conjunction} ${step.streetName}`;\n}\n\nexport function getStepStreetName(step) {\n logDeprecationWarning(\"getStepStreetName\");\n\n if (step.streetName === \"road\") return \"Unnamed Road\";\n if (step.streetName === \"path\") return \"Unnamed Path\";\n return step.streetName;\n}\n\nexport function getLegModeLabel(leg) {\n logDeprecationWarning(\"getLegModeLabel\");\n\n switch (leg.mode) {\n case \"BICYCLE_RENT\":\n return \"Biketown\";\n case \"CAR\":\n return leg.hailedCar ? \"Ride\" : \"Drive\";\n case \"GONDOLA\":\n return \"Aerial Tram\";\n case \"TRAM\":\n if (leg.routeLongName.toLowerCase().indexOf(\"streetcar\") !== -1)\n return \"Streetcar\";\n return \"Light Rail\";\n case \"MICROMOBILITY\":\n case \"SCOOTER\":\n return \"Ride\";\n default:\n return require(\"./itinerary\").toSentenceCase(leg.mode);\n }\n}\n\n/**\n * Returns mode name by checking the vertex type (VertexType class in OTP) for\n * the provided place. NOTE: this is currently only intended for vehicles at\n * the moment (not transit or walking).\n *\n * @param {string} place place from itinerary leg\n */\nexport function getModeForPlace(place) {\n logDeprecationWarning(\"getModeForPlace\");\n\n switch (place.vertexType) {\n case \"CARSHARE\":\n return \"car\";\n case \"VEHICLERENTAL\":\n return \"E-scooter\";\n // TODO: Should the type change depending on bike vertex type?\n case \"BIKESHARE\":\n case \"BIKEPARK\":\n return \"bike\";\n // If company offers more than one mode, default to `vehicle` string.\n default:\n return \"vehicle\";\n }\n}\n\nexport function getPlaceName(place, companies) {\n logDeprecationWarning(\"getPlaceName\");\n\n // If address is provided (i.e. for carshare station, use it)\n if (place.address) return place.address.split(\",\")[0];\n if (place.networks && place.vertexType === \"VEHICLERENTAL\") {\n // For vehicle rental pick up, do not use the place name. Rather, use\n // company name + vehicle type (e.g., SPIN E-scooter). Place name is often just\n // a UUID that has no relevance to the actual vehicle. For bikeshare, however,\n // there are often hubs or bikes that have relevant names to the user.\n const company = require(\"./itinerary\").getCompanyForNetwork(\n place.networks[0],\n companies\n );\n if (company) {\n return `${company.label} ${getModeForPlace(place)}`;\n }\n }\n // Default to place name\n return place.name;\n}\n\n/**\n * For a given fare component (either total fare or component parts), returns\n * an object with string formatters and the fare value (in cents).\n */\nexport function getTransitFare(fareComponent) {\n logDeprecationWarning(\"getTransitFare\", \"the fare object and getTncFare\");\n\n // Default values (if fare component is not valid).\n let digits = 2;\n let transitFare = 0;\n let symbol = \"$\";\n let currencyCode = \"USD\";\n if (fareComponent) {\n // Assign values without declaration. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#assignment_without_declaration\n ({\n currencyCode,\n defaultFractionDigits: digits,\n symbol\n } = fareComponent.currency);\n transitFare = fareComponent.cents;\n }\n // For cents to string conversion, use digits from fare component.\n const centsToString = cents => {\n const dollars = (cents / 10 ** digits).toFixed(digits);\n return `${symbol}${dollars}`;\n };\n // For dollars to string conversion, assume we're rounding to two digits.\n const dollarsToString = dollars => `${symbol}${dollars.toFixed(2)}`;\n return {\n centsToString,\n currencyCode,\n dollarsToString,\n transitFare\n };\n}\n\n/**\n * For an itinerary, calculates the transit/TNC fares and returns an object with\n * these values, currency info, as well as string formatters.\n * It is assumed that the same currency is used for transit and TNC legs.\n *\n * multiple being set to true will change the output behavior:\n * - dollarsToString and centsToString will be returned as part of each fare\n * - currencyCode will be returned separately for each fare\n * - tnc currency code will be returned separately\n * - each fare type will be returned separately within a new transitFares property\n *\n * FIXME: a new approach to fare calculation must be found:\n * the current approach is not sustainable, as centsToString and DollarsToString\n * must be replaced by i18n anyway.\n *\n * However, the current behavior should ideally be kept to avoid a breaking change.\n * The \"multiple\" mode is helpful, but only prevents tnc fare calculation from being duplicated.\n * This method could be split out into a new one, along with tnc fare calculation.\n * If this is done, the individual fare calculation should also be modified to support\n * a default fare not being called \"regular\". However, this again would be a breaking change.\n * This breaking change is avoided by adding the \"multiple\" parameter.\n *\n * When centsToString and dollarsToString are removed, this method should be split into\n * individual fare calculation on a variable fare key, fare calculation of an entire leg,\n * which will get fares for every fare key in the leg, and a method to calculate the fare of\n * a tnc ride within the leg. This will make typescripting easier, as the types will be cleaner.\n */\nexport function calculateFares(itinerary, multiple = false) {\n logDeprecationWarning(\"calculateFares\", \"the fare object and getTncFare\");\n\n // Process any TNC fares\n let minTNCFare = 0;\n let maxTNCFare = 0;\n let tncCurrencyCode;\n itinerary.legs.forEach(leg => {\n if (leg.mode === \"CAR\" && leg.hailedCar && leg.tncData) {\n const { currency, maxCost, minCost } = leg.tncData;\n // TODO: Support non-USD\n minTNCFare += minCost;\n maxTNCFare += maxCost;\n tncCurrencyCode = currency;\n }\n });\n\n if (multiple) {\n // Return object of fares\n const transitFares = {};\n if (itinerary && itinerary.fare && itinerary.fare.fare) {\n Object.keys(itinerary.fare.fare).forEach(fareKey => {\n const fareComponent = itinerary.fare.fare[fareKey];\n transitFares[fareKey] = getTransitFare(fareComponent);\n });\n }\n\n return {\n maxTNCFare,\n minTNCFare,\n tncCurrencyCode,\n transitFares\n };\n }\n\n // Extract fare total from itinerary fares.\n const fareComponent =\n itinerary.fare && itinerary.fare.fare && itinerary.fare.fare.regular;\n // Get string formatters and itinerary fare.\n const {\n centsToString,\n currencyCode: transitCurrencyCode,\n dollarsToString,\n transitFare\n } = getTransitFare(fareComponent);\n\n return {\n centsToString,\n currencyCode: transitCurrencyCode || tncCurrencyCode,\n dollarsToString,\n maxTNCFare,\n minTNCFare,\n transitFare\n };\n}\n\n// map.js\n\nexport function latlngToString(latlng) {\n logDeprecationWarning(\"latlngToString\", \"the latlng object\");\n\n return (\n latlng &&\n `${latlng.lat.toFixed(5)}, ${(latlng.lng || latlng.lon).toFixed(5)}`\n );\n}\n\nexport function coordsToString(coords) {\n logDeprecationWarning(\"coordsToString\", \"the coords object\");\n\n return coords.length && coords.map(c => (+c).toFixed(5)).join(\", \");\n}\n\nexport function getDetailText(location) {\n let detailText;\n if (location.type === \"home\" || location.type === \"work\") {\n detailText = location.name;\n }\n if (location.type === \"stop\") {\n detailText = location.id;\n } else if (location.type === \"recent\" && location.timestamp) {\n detailText = moment(location.timestamp).fromNow();\n }\n return detailText;\n}\n\n// query.js\n\nexport function summarizeQuery(query, locations = []) {\n logDeprecationWarning(\"summarizeQuery\");\n\n function findLocationType(\n location,\n ls = [],\n types = [\"home\", \"work\", \"suggested\"]\n ) {\n const match = ls.find(l => require(\"./map\").matchLatLon(l, location));\n return match && types.indexOf(match.type) !== -1 ? match.type : null;\n }\n\n const from =\n findLocationType(query.from, locations) || query.from.name.split(\",\")[0];\n const to =\n findLocationType(query.to, locations) || query.to.name.split(\",\")[0];\n const mode = require(\"./itinerary\").hasTransit(query.mode)\n ? \"Transit\"\n : require(\"./itinerary\").toSentenceCase(query.mode);\n return `${mode} from ${from} to ${to}`;\n}\n"],"file":"deprecated.js"}
1
+ {"version":3,"sources":["../src/deprecated.js"],"names":["logDeprecationWarning","method","alternative","console","warn","getStepDirection","step","relativeDirection","absoluteDirection","toLowerCase","getStepInstructions","conjunction","streetName","getStepStreetName","getLegModeLabel","leg","mode","hailedCar","routeLongName","indexOf","require","toSentenceCase","getModeForPlace","place","vertexType","getPlaceName","companies","address","split","networks","company","getCompanyForNetwork","label","name","getTransitFare","fareComponent","digits","transitFare","symbol","currencyCode","defaultFractionDigits","currency","cents","centsToString","dollars","toFixed","dollarsToString","calculateFares","itinerary","multiple","minTNCFare","maxTNCFare","tncCurrencyCode","legs","forEach","tncData","maxCost","minCost","transitFares","fare","Object","keys","fareKey","regular","transitCurrencyCode","latlngToString","latlng","lat","lng","lon","coordsToString","coords","length","map","c","join","getDetailText","location","detailText","type","id","timestamp","fromNow","summarizeQuery","query","locations","findLocationType","ls","types","match","find","l","matchLatLon","from","to","hasTransit","getTimeZoneOffset","dstOffset","Date","startTime","getTimezoneOffset","agencyTimeZoneOffset"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;AAEA;AACA;AACA;AACA;;AACA;;AAEA;AACA;AACA;AACO,SAASA,qBAAT,CAA+BC,MAA/B,EAAuCC,WAAvC,EAAoD;AACzDC,EAAAA,OAAO,CAACC,IAAR,CACG,GAAEH,MAAM,IACP,aAAc;AACpB,UACUC,WAAW,GACN;AACf;AACA,cAAcA,WAAY,+EAHL,GAIP,EACL,EATP;AAWD,C,CAED;;;AAEO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EA,QAAMZ,IAAI,GAAGI,OAAO,CAAC,aAAD,CAAP,CAAuB2E,UAAvB,CAAkCX,KAAK,CAACpE,IAAxC,IACT,SADS,GAETI,OAAO,CAAC,aAAD,CAAP,CAAuBC,cAAvB,CAAsC+D,KAAK,CAACpE,IAA5C,CAFJ;AAGA,SAAQ,GAAEA,IAAK,SAAQ6E,IAAK,OAAMC,EAAG,EAArC;AACD;;AAEM,SAASE,iBAAT,CAA2BhD,SAA3B,EAAsC;AAC3ChD,EAAAA,qBAAqB,CAAC,mBAAD,CAArB;AAEA,MAAI,CAACgD,SAAS,CAACK,IAAX,IAAmB,CAACL,SAAS,CAACK,IAAV,CAAemB,MAAvC,EAA+C,OAAO,CAAP,CAHJ,CAK3C;;AACA,QAAMyB,SAAS,GACb,IAAIC,IAAJ,CAASlD,SAAS,CAACmD,SAAnB,EAA8BC,iBAA9B,KACA,IAAIF,IAAJ,GAAWE,iBAAX,EAFF;AAIA,SACEpD,SAAS,CAACK,IAAV,CAAe,CAAf,EAAkBgD,oBAAlB,GACA,CAAC,IAAIH,IAAJ,GAAWE,iBAAX,KAAiCH,SAAlC,IAA+C,KAFjD;AAID","sourcesContent":["import moment from \"moment\";\n\n/**\n * To disable cyclic dependency resolution we need to require() within methods\n * This is a good reason to disable this eslint-rule\n */\n/* eslint-disable global-require */\n\n/**\n * Generates a warning to tell developer that they are using deprecated methods!\n */\nexport function logDeprecationWarning(method, alternative) {\n console.warn(\n `${method ||\n \"This method\"} is deprecated and will be removed in a future otp-ui release. All language functionality should be handled using react-intl.\n ${\n alternative\n ? `\n\n Use ${alternative} instead, which provides a new interface that doesn't return English strings.`\n : \"\"\n }`\n );\n}\n\n// itinerary.js\n\nexport function getStepDirection(step) {\n logDeprecationWarning(\"getStepDirection\");\n\n switch (step.relativeDirection) {\n case \"DEPART\":\n return `Head ${step.absoluteDirection.toLowerCase()}`;\n case \"LEFT\":\n return \"Left\";\n case \"HARD_LEFT\":\n return \"Hard left\";\n case \"SLIGHTLY_LEFT\":\n return \"Slight left\";\n case \"CONTINUE\":\n return \"Continue\";\n case \"SLIGHTLY_RIGHT\":\n return \"Slight right\";\n case \"RIGHT\":\n return \"Right\";\n case \"HARD_RIGHT\":\n return \"Hard right\";\n case \"CIRCLE_CLOCKWISE\":\n return \"Follow circle clockwise\";\n case \"CIRCLE_COUNTERCLOCKWISE\":\n return \"Follow circle counterclockwise\";\n case \"ELEVATOR\":\n return \"Take elevator\";\n case \"UTURN_LEFT\":\n return \"Left U-turn\";\n case \"UTURN_RIGHT\":\n return \"Right U-turn\";\n default:\n return step.relativeDirection;\n }\n}\n\nexport function getStepInstructions(step) {\n logDeprecationWarning(\"getStepInstructions\");\n\n const conjunction = step.relativeDirection === \"ELEVATOR\" ? \"to\" : \"on\";\n return `${getStepDirection(step)} ${conjunction} ${step.streetName}`;\n}\n\nexport function getStepStreetName(step) {\n logDeprecationWarning(\"getStepStreetName\");\n\n if (step.streetName === \"road\") return \"Unnamed Road\";\n if (step.streetName === \"path\") return \"Unnamed Path\";\n return step.streetName;\n}\n\nexport function getLegModeLabel(leg) {\n logDeprecationWarning(\"getLegModeLabel\");\n\n switch (leg.mode) {\n case \"BICYCLE_RENT\":\n return \"Biketown\";\n case \"CAR\":\n return leg.hailedCar ? \"Ride\" : \"Drive\";\n case \"GONDOLA\":\n return \"Aerial Tram\";\n case \"TRAM\":\n if (leg.routeLongName.toLowerCase().indexOf(\"streetcar\") !== -1)\n return \"Streetcar\";\n return \"Light Rail\";\n case \"MICROMOBILITY\":\n case \"SCOOTER\":\n return \"Ride\";\n default:\n return require(\"./itinerary\").toSentenceCase(leg.mode);\n }\n}\n\n/**\n * Returns mode name by checking the vertex type (VertexType class in OTP) for\n * the provided place. NOTE: this is currently only intended for vehicles at\n * the moment (not transit or walking).\n *\n * @param {string} place place from itinerary leg\n */\nexport function getModeForPlace(place) {\n logDeprecationWarning(\"getModeForPlace\");\n\n switch (place.vertexType) {\n case \"CARSHARE\":\n return \"car\";\n case \"VEHICLERENTAL\":\n return \"E-scooter\";\n // TODO: Should the type change depending on bike vertex type?\n case \"BIKESHARE\":\n case \"BIKEPARK\":\n return \"bike\";\n // If company offers more than one mode, default to `vehicle` string.\n default:\n return \"vehicle\";\n }\n}\n\nexport function getPlaceName(place, companies) {\n logDeprecationWarning(\"getPlaceName\");\n\n // If address is provided (i.e. for carshare station, use it)\n if (place.address) return place.address.split(\",\")[0];\n if (place.networks && place.vertexType === \"VEHICLERENTAL\") {\n // For vehicle rental pick up, do not use the place name. Rather, use\n // company name + vehicle type (e.g., SPIN E-scooter). Place name is often just\n // a UUID that has no relevance to the actual vehicle. For bikeshare, however,\n // there are often hubs or bikes that have relevant names to the user.\n const company = require(\"./itinerary\").getCompanyForNetwork(\n place.networks[0],\n companies\n );\n if (company) {\n return `${company.label} ${getModeForPlace(place)}`;\n }\n }\n // Default to place name\n return place.name;\n}\n\n/**\n * For a given fare component (either total fare or component parts), returns\n * an object with string formatters and the fare value (in cents).\n */\nexport function getTransitFare(fareComponent) {\n logDeprecationWarning(\"getTransitFare\", \"the fare object and getTncFare\");\n\n // Default values (if fare component is not valid).\n let digits = 2;\n let transitFare = 0;\n let symbol = \"$\";\n let currencyCode = \"USD\";\n if (fareComponent) {\n // Assign values without declaration. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#assignment_without_declaration\n ({\n currencyCode,\n defaultFractionDigits: digits,\n symbol\n } = fareComponent.currency);\n transitFare = fareComponent.cents;\n }\n // For cents to string conversion, use digits from fare component.\n const centsToString = cents => {\n const dollars = (cents / 10 ** digits).toFixed(digits);\n return `${symbol}${dollars}`;\n };\n // For dollars to string conversion, assume we're rounding to two digits.\n const dollarsToString = dollars => `${symbol}${dollars.toFixed(2)}`;\n return {\n centsToString,\n currencyCode,\n dollarsToString,\n transitFare\n };\n}\n\n/**\n * For an itinerary, calculates the transit/TNC fares and returns an object with\n * these values, currency info, as well as string formatters.\n * It is assumed that the same currency is used for transit and TNC legs.\n *\n * multiple being set to true will change the output behavior:\n * - dollarsToString and centsToString will be returned as part of each fare\n * - currencyCode will be returned separately for each fare\n * - tnc currency code will be returned separately\n * - each fare type will be returned separately within a new transitFares property\n *\n * FIXME: a new approach to fare calculation must be found:\n * the current approach is not sustainable, as centsToString and DollarsToString\n * must be replaced by i18n anyway.\n *\n * However, the current behavior should ideally be kept to avoid a breaking change.\n * The \"multiple\" mode is helpful, but only prevents tnc fare calculation from being duplicated.\n * This method could be split out into a new one, along with tnc fare calculation.\n * If this is done, the individual fare calculation should also be modified to support\n * a default fare not being called \"regular\". However, this again would be a breaking change.\n * This breaking change is avoided by adding the \"multiple\" parameter.\n *\n * When centsToString and dollarsToString are removed, this method should be split into\n * individual fare calculation on a variable fare key, fare calculation of an entire leg,\n * which will get fares for every fare key in the leg, and a method to calculate the fare of\n * a tnc ride within the leg. This will make typescripting easier, as the types will be cleaner.\n */\nexport function calculateFares(itinerary, multiple = false) {\n logDeprecationWarning(\"calculateFares\", \"the fare object and getTncFare\");\n\n // Process any TNC fares\n let minTNCFare = 0;\n let maxTNCFare = 0;\n let tncCurrencyCode;\n itinerary.legs.forEach(leg => {\n if (leg.mode === \"CAR\" && leg.hailedCar && leg.tncData) {\n const { currency, maxCost, minCost } = leg.tncData;\n // TODO: Support non-USD\n minTNCFare += minCost;\n maxTNCFare += maxCost;\n tncCurrencyCode = currency;\n }\n });\n\n if (multiple) {\n // Return object of fares\n const transitFares = {};\n if (itinerary && itinerary.fare && itinerary.fare.fare) {\n Object.keys(itinerary.fare.fare).forEach(fareKey => {\n const fareComponent = itinerary.fare.fare[fareKey];\n transitFares[fareKey] = getTransitFare(fareComponent);\n });\n }\n\n return {\n maxTNCFare,\n minTNCFare,\n tncCurrencyCode,\n transitFares\n };\n }\n\n // Extract fare total from itinerary fares.\n const fareComponent =\n itinerary.fare && itinerary.fare.fare && itinerary.fare.fare.regular;\n // Get string formatters and itinerary fare.\n const {\n centsToString,\n currencyCode: transitCurrencyCode,\n dollarsToString,\n transitFare\n } = getTransitFare(fareComponent);\n\n return {\n centsToString,\n currencyCode: transitCurrencyCode || tncCurrencyCode,\n dollarsToString,\n maxTNCFare,\n minTNCFare,\n transitFare\n };\n}\n\n// map.js\n\nexport function latlngToString(latlng) {\n logDeprecationWarning(\"latlngToString\", \"the latlng object\");\n\n return (\n latlng &&\n `${latlng.lat.toFixed(5)}, ${(latlng.lng || latlng.lon).toFixed(5)}`\n );\n}\n\nexport function coordsToString(coords) {\n logDeprecationWarning(\"coordsToString\", \"the coords object\");\n\n return coords.length && coords.map(c => (+c).toFixed(5)).join(\", \");\n}\n\nexport function getDetailText(location) {\n let detailText;\n if (location.type === \"home\" || location.type === \"work\") {\n detailText = location.name;\n }\n if (location.type === \"stop\") {\n detailText = location.id;\n } else if (location.type === \"recent\" && location.timestamp) {\n detailText = moment(location.timestamp).fromNow();\n }\n return detailText;\n}\n\n// query.js\n\nexport function summarizeQuery(query, locations = []) {\n logDeprecationWarning(\"summarizeQuery\");\n\n function findLocationType(\n location,\n ls = [],\n types = [\"home\", \"work\", \"suggested\"]\n ) {\n const match = ls.find(l => require(\"./map\").matchLatLon(l, location));\n return match && types.indexOf(match.type) !== -1 ? match.type : null;\n }\n\n const from =\n findLocationType(query.from, locations) || query.from.name.split(\",\")[0];\n const to =\n findLocationType(query.to, locations) || query.to.name.split(\",\")[0];\n const mode = require(\"./itinerary\").hasTransit(query.mode)\n ? \"Transit\"\n : require(\"./itinerary\").toSentenceCase(query.mode);\n return `${mode} from ${from} to ${to}`;\n}\n\nexport function getTimeZoneOffset(itinerary) {\n logDeprecationWarning(\"getTimeZoneOffset\");\n\n if (!itinerary.legs || !itinerary.legs.length) return 0;\n\n // Determine if there is a DST offset between now and the itinerary start date\n const dstOffset =\n new Date(itinerary.startTime).getTimezoneOffset() -\n new Date().getTimezoneOffset();\n\n return (\n itinerary.legs[0].agencyTimeZoneOffset +\n (new Date().getTimezoneOffset() + dstOffset) * 60000\n );\n}\n"],"file":"deprecated.js"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ import * as itinerary from "./itinerary";
2
+ import * as map from "./map";
3
+ import * as route from "./route";
4
+ import * as storage from "./storage";
5
+ import * as time from "./time";
6
+ import * as ui from "./ui";
7
+ declare const core: {
8
+ itinerary: typeof itinerary;
9
+ map: typeof map;
10
+ profile: any;
11
+ query: any;
12
+ queryParams: any;
13
+ route: typeof route;
14
+ storage: typeof storage;
15
+ time: typeof time;
16
+ ui: typeof ui;
17
+ };
18
+ export default core;
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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;AAE3B,QAAA,MAAM,IAAI;;;;;;;;;;CAUT,CAAC;AAEF,eAAe,IAAI,CAAC"}
package/lib/index.js CHANGED
@@ -9,8 +9,6 @@ var itinerary = _interopRequireWildcard(require("./itinerary"));
9
9
 
10
10
  var map = _interopRequireWildcard(require("./map"));
11
11
 
12
- var messages = _interopRequireWildcard(require("./messages"));
13
-
14
12
  var profile = _interopRequireWildcard(require("./profile"));
15
13
 
16
14
  var query = _interopRequireWildcard(require("./query"));
@@ -23,8 +21,6 @@ var storage = _interopRequireWildcard(require("./storage"));
23
21
 
24
22
  var time = _interopRequireWildcard(require("./time"));
25
23
 
26
- var types = _interopRequireWildcard(require("./types"));
27
-
28
24
  var ui = _interopRequireWildcard(require("./ui"));
29
25
 
30
26
  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); }
@@ -34,14 +30,12 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
34
30
  const core = {
35
31
  itinerary,
36
32
  map,
37
- messages,
38
33
  profile,
39
34
  query,
40
35
  queryParams,
41
36
  route,
42
37
  storage,
43
38
  time,
44
- types,
45
39
  ui
46
40
  };
47
41
  var _default = core;
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["core","itinerary","map","messages","profile","query","queryParams","route","storage","time","types","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,QAHW;AAIXC,EAAAA,OAJW;AAKXC,EAAAA,KALW;AAMXC,EAAAA,WANW;AAOXC,EAAAA,KAPW;AAQXC,EAAAA,OARW;AASXC,EAAAA,IATW;AAUXC,EAAAA,KAVW;AAWXC,EAAAA;AAXW,CAAb;eAceX,I","sourcesContent":["import * as itinerary from \"./itinerary\";\nimport * as map from \"./map\";\nimport * as messages from \"./messages\";\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 types from \"./types\";\nimport * as ui from \"./ui\";\n\nconst core = {\n itinerary,\n map,\n messages,\n profile,\n query,\n queryParams,\n route,\n storage,\n time,\n types,\n ui\n};\n\nexport default core;\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.ts"],"names":["core","itinerary","map","profile","query","queryParams","route","storage","time","ui"],"mappings":";;;;;;;AAAA;;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,WALW;AAMXC,EAAAA,KANW;AAOXC,EAAAA,OAPW;AAQXC,EAAAA,IARW;AASXC,EAAAA;AATW,CAAb;eAYeT,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\";\n\nconst core = {\n itinerary,\n map,\n profile,\n query,\n queryParams,\n route,\n storage,\n time,\n ui\n};\n\nexport default core;\n"],"file":"index.js"}
@@ -0,0 +1,113 @@
1
+ import { Company, Config, ElevationProfile, FlexBookingInfo, Itinerary, LatLngArray, Leg, Step } from "@opentripplanner/types";
2
+ import { calculateFares, getLegModeLabel, getModeForPlace, getPlaceName, getStepDirection, getStepInstructions, getStepStreetName, getTimeZoneOffset, getTransitFare } from "./deprecated";
3
+ export { calculateFares, getLegModeLabel, getModeForPlace, getPlaceName, getStepDirection, getStepInstructions, getStepStreetName, getTimeZoneOffset, getTransitFare };
4
+ export declare const transitModes: string[];
5
+ /**
6
+ * @param {config} config OTP-RR configuration object
7
+ * @return {Array} List of all transit modes defined in config; otherwise default mode list
8
+ */
9
+ export declare function getTransitModes(config: Config): string[];
10
+ export declare function isTransit(mode: string): boolean;
11
+ /**
12
+ * Returns true if the leg pickup rules enabled which require
13
+ * calling ahead for the service to run. "mustPhone" is the only
14
+ * property of boardRule which encodes this info.
15
+ */
16
+ export declare function isReservationRequired(leg: Leg): boolean;
17
+ /**
18
+ * Returns true if the leg has continuous dropoff enabled which requires
19
+ * asking the driver to let the user off. "coordinateWithDriver" is the only
20
+ * property of alightRule which encodes this info.
21
+ */
22
+ export declare function isContinuousDropoff(leg: Leg): boolean;
23
+ /**
24
+ * The two rules checked by the above two functions are the only values
25
+ * returned by OTP when a leg is a flex leg.
26
+ */
27
+ export declare function isFlex(leg: Leg): boolean;
28
+ export declare function isAdvanceBookingRequired(info: FlexBookingInfo): boolean;
29
+ export declare function legDropoffRequiresAdvanceBooking(leg: Leg): boolean;
30
+ export declare function isWalk(mode: string): boolean;
31
+ export declare function isBicycle(mode: string): boolean;
32
+ export declare function isBicycleRent(mode: string): boolean;
33
+ export declare function isCar(mode: string): boolean;
34
+ export declare function isMicromobility(mode: string): boolean;
35
+ export declare function isAccessMode(mode: string): boolean;
36
+ /**
37
+ * @param {string} modesStr a comma-separated list of OTP modes
38
+ * @return {boolean} whether any of the modes are transit modes
39
+ */
40
+ export declare function hasTransit(modesStr: string): boolean;
41
+ /**
42
+ * @param {string} modesStr a comma-separated list of OTP modes
43
+ * @return {boolean} whether any of the modes are car-based modes
44
+ */
45
+ export declare function hasCar(modesStr: string): boolean;
46
+ /**
47
+ * @param {string} modesStr a comma-separated list of OTP modes
48
+ * @return {boolean} whether any of the modes are bicycle-based modes
49
+ */
50
+ export declare function hasBike(modesStr: string): boolean;
51
+ /**
52
+ * @param {string} modesStr a comma-separated list of OTP modes
53
+ * @return {boolean} whether any of the modes are micromobility-based modes
54
+ */
55
+ export declare function hasMicromobility(modesStr: string): boolean;
56
+ /**
57
+ * @param {string} modesStr a comma-separated list of OTP modes
58
+ * @return {boolean} whether any of the modes is a hailing mode
59
+ */
60
+ export declare function hasHail(modesStr: string): boolean;
61
+ /**
62
+ * @param {string} modesStr a comma-separated list of OTP modes
63
+ * @return {boolean} whether any of the modes is a rental mode
64
+ */
65
+ export declare function hasRental(modesStr: string): boolean;
66
+ export declare function getMapColor(mode: string): string;
67
+ export declare function toSentenceCase(str: string): string;
68
+ /**
69
+ * Derive the company string based on mode and network associated with leg.
70
+ */
71
+ export declare function getCompanyFromLeg(leg: Leg): string;
72
+ export declare function getItineraryBounds(itinerary: Itinerary): LatLngArray[];
73
+ /**
74
+ * Return a coords object that encloses the given leg's geometry.
75
+ */
76
+ export declare function getLegBounds(leg: Leg): number[];
77
+ export declare function legLocationAtDistance(leg: Leg, distance: number): number[];
78
+ export declare function legElevationAtDistance(points: number[][], distance: number): number;
79
+ export declare function getElevationProfile(steps: Step[], unitConversion?: number): ElevationProfile;
80
+ /**
81
+ * Uses canvas.measureText to compute and return the width of the given text of given font in pixels.
82
+ *
83
+ * @param {string} text The text to be rendered.
84
+ * @param {string} font The css font descriptor that text is to be rendered with (e.g. "bold 14px verdana").
85
+ *
86
+ * @see https://stackoverflow.com/questions/118241/calculate-text-width-with-javascript/21015393#21015393
87
+ */
88
+ export declare function getTextWidth(text: string, font?: string): number;
89
+ /**
90
+ * Get the configured company object for the given network string if the company
91
+ * has been defined in the provided companies array config.
92
+ */
93
+ export declare function getCompanyForNetwork(networkString: string, companies?: Company[]): Company;
94
+ /**
95
+ * Get a string label to display from a list of vehicle rental networks.
96
+ *
97
+ * @param {Array<string>} networks A list of network ids.
98
+ * @param {Array<object>} [companies=[]] An optional list of the companies config.
99
+ * @return {string} A label for use in presentation on a website.
100
+ */
101
+ export declare function getCompaniesLabelFromNetworks(networks: string[], companies?: Company[]): string;
102
+ export declare function getTNCLocation(leg: Leg, type: string): string;
103
+ export declare function calculatePhysicalActivity(itinerary: Itinerary): {
104
+ bikeDuration: number;
105
+ caloriesBurned: number;
106
+ walkDuration: number;
107
+ };
108
+ export declare function calculateTncFares(itinerary: any): {
109
+ maxTNCFare: any;
110
+ minTNCFare: any;
111
+ tncCurrencyCode: any;
112
+ };
113
+ //# sourceMappingURL=itinerary.d.ts.map
@@ -0,0 +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,SAAS,EACT,WAAW,EACX,GAAG,EACH,IAAI,EACL,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,cAAc,EACd,eAAe,EACf,eAAe,EAC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AST;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,MAAM,EAAE,EAClB,SAAS,GAAE,OAAO,EAAO,GACxB,MAAM,CAMR;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAG7D;AAED,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,SAAS,GACnB;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB,CAcA;AAED,wBAAgB,iBAAiB,CAAC,SAAS,KAAA;;;;EAQ1C"}
package/lib/itinerary.js CHANGED
@@ -37,7 +37,6 @@ exports.getCompanyForNetwork = getCompanyForNetwork;
37
37
  exports.getCompaniesLabelFromNetworks = getCompaniesLabelFromNetworks;
38
38
  exports.getTNCLocation = getTNCLocation;
39
39
  exports.calculatePhysicalActivity = calculatePhysicalActivity;
40
- exports.getTimeZoneOffset = getTimeZoneOffset;
41
40
  exports.calculateTncFares = calculateTncFares;
42
41
  Object.defineProperty(exports, "calculateFares", {
43
42
  enumerable: true,
@@ -81,6 +80,12 @@ Object.defineProperty(exports, "getStepStreetName", {
81
80
  return _deprecated.getStepStreetName;
82
81
  }
83
82
  });
83
+ Object.defineProperty(exports, "getTimeZoneOffset", {
84
+ enumerable: true,
85
+ get: function () {
86
+ return _deprecated.getTimeZoneOffset;
87
+ }
88
+ });
84
89
  Object.defineProperty(exports, "getTransitFare", {
85
90
  enumerable: true,
86
91
  get: function () {
@@ -106,7 +111,7 @@ exports.transitModes = transitModes;
106
111
 
107
112
  function getTransitModes(config) {
108
113
  if (!config || !config.modes || !config.modes.transitModes) return transitModes;
109
- return config.modes.transitModes.map(tm => tm.mode);
114
+ return config.modes.transitModes.map(tm => typeof tm !== "string" ? tm.mode : tm);
110
115
  }
111
116
 
112
117
  function isTransit(mode) {
@@ -436,6 +441,7 @@ function getElevationProfile(steps, unitConversion = 1) {
436
441
 
437
442
 
438
443
  function getTextWidth(text, font = "22px Arial") {
444
+ // Create custom type for function including re-used canvas object
439
445
  // re-use canvas object for better performance
440
446
  const canvas = getTextWidth.canvas || (getTextWidth.canvas = document.createElement("canvas"));
441
447
  const context = canvas.getContext("2d");
@@ -491,13 +497,6 @@ function calculatePhysicalActivity(itinerary) {
491
497
  };
492
498
  }
493
499
 
494
- function getTimeZoneOffset(itinerary) {
495
- if (!itinerary.legs || !itinerary.legs.length) return 0; // Determine if there is a DST offset between now and the itinerary start date
496
-
497
- const dstOffset = new Date(itinerary.startTime).getTimezoneOffset() - new Date().getTimezoneOffset();
498
- return itinerary.legs[0].agencyTimeZoneOffset + (new Date().getTimezoneOffset() + dstOffset) * 60000;
499
- }
500
-
501
500
  function calculateTncFares(itinerary) {
502
501
  // TODO: don't rely on deprecated methods!
503
502
  // At the moment this is safe as none of these exported variables contain strings
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/itinerary.js"],"names":["transitModes","getTransitModes","config","modes","map","tm","mode","isTransit","includes","isReservationRequired","leg","boardRule","isContinuousDropoff","alightRule","isFlex","isAdvanceBookingRequired","info","latestBookingTime","daysPrior","legDropoffRequiresAdvanceBooking","dropOffBookingInfo","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","tncData","networks","company","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","find","co","id","getCompaniesLabelFromNetworks","network","filter","label","join","getTNCLocation","type","location","toFixed","calculatePhysicalActivity","walkDuration","bikeDuration","duration","caloriesBurned","getTimeZoneOffset","dstOffset","Date","startTime","getTimezoneOffset","agencyTimeZoneOffset","calculateTncFares","maxTNCFare","minTNCFare","tncCurrencyCode"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AAsBA;AACO,MAAMA,YAAY,GAAG,CAC1B,MAD0B,EAE1B,KAF0B,EAG1B,QAH0B,EAI1B,OAJ0B,EAK1B,MAL0B,EAM1B,SAN0B,CAArB;AASP;AACA;AACA;AACA;;;;AAEO,SAASC,eAAT,CAAyBC,MAAzB,EAAiC;AACtC,MAAI,CAACA,MAAD,IAAW,CAACA,MAAM,CAACC,KAAnB,IAA4B,CAACD,MAAM,CAACC,KAAP,CAAaH,YAA9C,EACE,OAAOA,YAAP;AACF,SAAOE,MAAM,CAACC,KAAP,CAAaH,YAAb,CAA0BI,GAA1B,CAA8BC,EAAE,IAAIA,EAAE,CAACC,IAAvC,CAAP;AACD;;AAEM,SAASC,SAAT,CAAmBD,IAAnB,EAAyB;AAC9B,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,EAAoC;AACzC,SAAOA,GAAG,CAACC,SAAJ,KAAkB,WAAzB;AACD;AACD;AACA;AACA;AACA;AACA;;;AACO,SAASC,mBAAT,CAA6BF,GAA7B,EAAkC;AACvC,SAAOA,GAAG,CAACG,UAAJ,KAAmB,sBAA1B;AACD;AACD;AACA;AACA;AACA;;;AACO,SAASC,MAAT,CAAgBJ,GAAhB,EAAqB;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X,KAAiCH,SAAlC,IAA+C,KAFjD;AAID;;AAEM,SAASK,iBAAT,CAA2BtF,SAA3B,EAAsC;AAC3C;AACA;AACA,QAAM;AAAEuF,IAAAA,UAAF;AAAcC,IAAAA,UAAd;AAA0BC,IAAAA;AAA1B,MAA8C,gCAClDzF,SADkD,EAElD,IAFkD,CAApD;AAIA,SAAO;AAAEuF,IAAAA,UAAF;AAAcC,IAAAA,UAAd;AAA0BC,IAAAA;AAA1B,GAAP;AACD","sourcesContent":["import polyline from \"@mapbox/polyline\";\nimport turfAlong from \"@turf/along\";\n\nimport {\n calculateFares,\n getLegModeLabel,\n getModeForPlace,\n getPlaceName,\n getStepDirection,\n getStepInstructions,\n getStepStreetName,\n getTransitFare\n} from \"./deprecated\";\n\nexport {\n calculateFares,\n getLegModeLabel,\n getModeForPlace,\n getPlaceName,\n getStepDirection,\n getStepInstructions,\n getStepStreetName,\n getTransitFare\n};\n\n// All OTP transit modes\nexport const transitModes = [\n \"TRAM\",\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) {\n if (!config || !config.modes || !config.modes.transitModes)\n return transitModes;\n return config.modes.transitModes.map(tm => tm.mode);\n}\n\nexport function isTransit(mode) {\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 of boardRule which encodes this info.\n */\nexport function isReservationRequired(leg) {\n return leg.boardRule === \"mustPhone\";\n}\n/**\n * Returns true if the leg has continuous dropoff enabled which requires\n * asking the driver to let the user off. \"coordinateWithDriver\" is the only\n * property of alightRule which encodes this info.\n */\nexport function isContinuousDropoff(leg) {\n return leg.alightRule === \"coordinateWithDriver\";\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) {\n return isReservationRequired(leg) || isContinuousDropoff(leg);\n}\n\nexport function isAdvanceBookingRequired(info) {\n return info?.latestBookingTime?.daysPrior > 0;\n}\nexport function legDropoffRequiresAdvanceBooking(leg) {\n return isAdvanceBookingRequired(leg.dropOffBookingInfo);\n}\n\nexport function isWalk(mode) {\n if (!mode) return false;\n\n return mode === \"WALK\";\n}\n\nexport function isBicycle(mode) {\n if (!mode) return false;\n\n return mode === \"BICYCLE\";\n}\n\nexport function isBicycleRent(mode) {\n if (!mode) return false;\n\n return mode === \"BICYCLE_RENT\";\n}\n\nexport function isCar(mode) {\n if (!mode) return false;\n return mode.startsWith(\"CAR\");\n}\n\nexport function isMicromobility(mode) {\n if (!mode) return false;\n return mode.startsWith(\"MICROMOBILITY\") || mode.startsWith(\"SCOOTER\");\n}\n\nexport function isAccessMode(mode) {\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) {\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) {\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) {\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) {\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) {\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) {\n return modesStr.split(\",\").some(mode => mode.indexOf(\"_RENT\") > -1);\n}\n\nexport function getMapColor(mode) {\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 === \"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) {\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) {\n if (!leg) return null;\n const { from, mode, rentedBike, rentedCar, rentedVehicle, tncData } = leg;\n if (mode === \"CAR\" && rentedCar) {\n return from.networks[0];\n }\n if (mode === \"CAR\" && tncData) {\n return tncData.company;\n }\n if (mode === \"BICYCLE\" && rentedBike && from.networks) {\n return from.networks[0];\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(itinerary) {\n let coords = [];\n itinerary.legs.forEach(leg => {\n const legCoords = polyline\n .toGeoJSON(leg.legGeometry.points)\n .coordinates.map(c => [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) {\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, distance) {\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(points, distance) {\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 iterpolated 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(steps, unitConversion = 1) {\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, font = \"22px Arial\") {\n // re-use canvas object for better performance\n const canvas =\n getTextWidth.canvas ||\n (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(networkString, companies = []) {\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(networks, companies = []) {\n return networks\n .map(network => getCompanyForNetwork(network, companies))\n .filter(co => !!co)\n .map(co => co.label)\n .join(\"/\");\n}\n\nexport function getTNCLocation(leg, type) {\n const location = leg[type];\n return `${location.lat.toFixed(5)},${location.lon.toFixed(5)}`;\n}\n\nexport function calculatePhysicalActivity(itinerary) {\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\nexport function getTimeZoneOffset(itinerary) {\n if (!itinerary.legs || !itinerary.legs.length) return 0;\n\n // Determine if there is a DST offset between now and the itinerary start date\n const dstOffset =\n new Date(itinerary.startTime).getTimezoneOffset() -\n new Date().getTimezoneOffset();\n\n return (\n itinerary.legs[0].agencyTimeZoneOffset +\n (new Date().getTimezoneOffset() + dstOffset) * 60000\n );\n}\n\nexport function calculateTncFares(itinerary) {\n // TODO: don't rely on deprecated methods!\n // At the moment this is safe as none of these exported variables contain strings\n const { maxTNCFare, minTNCFare, tncCurrencyCode } = calculateFares(\n itinerary,\n true\n );\n return { maxTNCFare, minTNCFare, tncCurrencyCode };\n}\n"],"file":"itinerary.js"}
1
+ {"version":3,"sources":["../src/itinerary.ts"],"names":["transitModes","getTransitModes","config","modes","map","tm","mode","isTransit","includes","isReservationRequired","leg","boardRule","isContinuousDropoff","alightRule","isFlex","isAdvanceBookingRequired","info","latestBookingTime","daysPrior","legDropoffRequiresAdvanceBooking","dropOffBookingInfo","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","tncData","networks","company","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","find","co","id","getCompaniesLabelFromNetworks","network","filter","label","join","getTNCLocation","type","location","toFixed","calculatePhysicalActivity","walkDuration","bikeDuration","duration","caloriesBurned","calculateTncFares","maxTNCFare","minTNCFare","tncCurrencyCode"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAWA;;AAEA;;AAwBA;AACO,MAAMA,YAAY,GAAG,CAC1B,MAD0B,EAE1B,KAF0B,EAG1B,QAH0B,EAI1B,OAJ0B,EAK1B,MAL0B,EAM1B,SAN0B,CAArB;AASP;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,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,CAApD;AAIA,SAAO;AAAEiF,IAAAA,UAAF;AAAcC,IAAAA,UAAd;AAA0BC,IAAAA;AAA1B,GAAP;AACD","sourcesContent":["import polyline from \"@mapbox/polyline\";\nimport {\n Company,\n Config,\n ElevationProfile,\n FlexBookingInfo,\n Itinerary,\n LatLngArray,\n Leg,\n Step\n} from \"@opentripplanner/types\";\nimport turfAlong from \"@turf/along\";\n\nimport {\n calculateFares,\n getLegModeLabel,\n getModeForPlace,\n getPlaceName,\n getStepDirection,\n getStepInstructions,\n getStepStreetName,\n getTimeZoneOffset,\n getTransitFare\n} from \"./deprecated\";\n\nexport {\n calculateFares,\n getLegModeLabel,\n getModeForPlace,\n getPlaceName,\n getStepDirection,\n getStepInstructions,\n getStepStreetName,\n getTimeZoneOffset,\n getTransitFare\n};\n\n// All OTP transit modes\nexport const transitModes = [\n \"TRAM\",\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 of boardRule which encodes this info.\n */\nexport function isReservationRequired(leg: Leg): boolean {\n return leg.boardRule === \"mustPhone\";\n}\n/**\n * Returns true if the leg has continuous dropoff enabled which requires\n * asking the driver to let the user off. \"coordinateWithDriver\" is the only\n * property of alightRule which encodes this info.\n */\nexport function isContinuousDropoff(leg: Leg): boolean {\n return leg.alightRule === \"coordinateWithDriver\";\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) || isContinuousDropoff(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\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 === \"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 { from, mode, rentedBike, rentedCar, rentedVehicle, tncData } = leg;\n if (mode === \"CAR\" && rentedCar) {\n return from.networks[0];\n }\n if (mode === \"CAR\" && tncData) {\n return tncData.company;\n }\n if (mode === \"BICYCLE\" && rentedBike && from.networks) {\n return from.networks[0];\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(itinerary: Itinerary): 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 iterpolated 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 re-used canvas object\n type GetTextWidth = typeof getTextWidth & { canvas: HTMLCanvasElement };\n\n // re-use 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[],\n companies: Company[] = []\n): string {\n return 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: Itinerary\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\nexport function calculateTncFares(itinerary) {\n // TODO: don't rely on deprecated methods!\n // At the moment this is safe as none of these exported variables contain strings\n const { maxTNCFare, minTNCFare, tncCurrencyCode } = calculateFares(\n itinerary,\n true\n );\n return { maxTNCFare, minTNCFare, tncCurrencyCode };\n}\n"],"file":"itinerary.js"}
package/lib/map.d.ts ADDED
@@ -0,0 +1,30 @@
1
+ import { Company, Itinerary, LatLngArray, Leg, Location, TransitiveData, UserPosition } from "@opentripplanner/types";
2
+ import { coordsToString, getDetailText, latlngToString } from "./deprecated";
3
+ export { coordsToString, getDetailText, latlngToString };
4
+ export declare function currentPositionToLocation(currentPosition: UserPosition): Location;
5
+ export declare function stringToCoords(str: string): number[];
6
+ export declare function constructLocation(latlng: {
7
+ lat: number;
8
+ lng: number;
9
+ }): Location;
10
+ export declare function formatStoredPlaceName(location: Location, withDetails?: boolean): string;
11
+ export declare function matchLatLon(location1: Location, location2: Location): boolean;
12
+ /**
13
+ * Converts an OTP itinerary object to a transtive.js itinerary object.
14
+ * @param {*} itin Required OTP itinerary (see @opentripplanner/core-utils/types#itineraryType) to convert.
15
+ * @param {*} companies Optional list of companies, used for labeling vehicle rental locations.
16
+ * @param {*} getRouteLabel Optional function that takes an itinerary leg (see @opentripplanner/core-utils/types#legType)
17
+ * and returns a string representing the route label to display for that leg.
18
+ * @returns An itinerary in the transitive.js format.
19
+ */
20
+ export declare function itineraryToTransitive(itin: Itinerary, companies: Company[], getRouteLabel: (leg: Leg) => string, disableFlexArc: boolean): TransitiveData;
21
+ declare type TransitivePlaceRaw = {
22
+ place_id: string;
23
+ };
24
+ export declare function isBikeshareStation(place: TransitivePlaceRaw): boolean;
25
+ export declare function isEScooterStation(place: TransitivePlaceRaw): boolean;
26
+ export declare function isCarWalkTransition(place: TransitivePlaceRaw): boolean;
27
+ export declare function isValidLat(lat: number): boolean;
28
+ export declare function isValidLng(lng: number): boolean;
29
+ export declare function isValidLatLng(arr: LatLngArray): boolean;
30
+ //# sourceMappingURL=map.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../src/map.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,SAAS,EACT,WAAW,EACX,GAAG,EACH,QAAQ,EACR,cAAc,EACd,YAAY,EACb,MAAM,wBAAwB,CAAC;AAShC,OAAO,EACL,cAAc,EACd,aAAa,EACb,cAAc,EAEf,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,CAAC;AAEzD,wBAAgB,yBAAyB,CACvC,eAAe,EAAE,YAAY,GAC5B,QAAQ,CAYV;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAEpD;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb,GAAG,QAAQ,CAKX;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,QAAQ,EAClB,WAAW,UAAO,GACjB,MAAM,CAcR;AAED,wBAAgB,WAAW,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,GAAG,OAAO,CAG7E;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,OAAO,EAAE,EACpB,aAAa,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM,EACnC,cAAc,EAAE,OAAO,GACtB,cAAc,CA+NhB;AAED,aAAK,kBAAkB,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AACF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAErE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAEpE;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAEtE;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE/C;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE/C;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAOvD"}
package/lib/map.js CHANGED
@@ -150,6 +150,7 @@ function itineraryToTransitive(itin, companies, getRouteLabel, disableFlexArc) {
150
150
  }
151
151
 
152
152
  const segment = {
153
+ arc: false,
153
154
  type: leg.mode,
154
155
  streetEdges: [streetEdgeId],
155
156
  from: {