@opentripplanner/core-utils 13.0.0-alpha.4 → 14.0.0-alpha.1
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/__mocks__/fake-route-data.story.json +5425 -0
- package/esm/__mocks__/fake-transit-operators.story.json +97 -0
- package/esm/__tests__/__mocks__/routes.json +234 -105
- package/esm/query-gen.js +1 -3
- package/esm/query-gen.js.map +1 -1
- package/esm/route.js +36 -21
- package/esm/route.js.map +1 -1
- package/esm/routes.json +234 -105
- package/esm/time.js +10 -0
- package/esm/time.js.map +1 -1
- package/lib/__mocks__/fake-route-data.story.json +5425 -0
- package/lib/__mocks__/fake-transit-operators.story.json +97 -0
- package/lib/__tests__/__mocks__/routes.json +234 -105
- package/lib/query-gen.js +1 -1
- package/lib/query-gen.js.map +1 -1
- package/lib/route.d.ts +35 -1
- package/lib/route.d.ts.map +1 -1
- package/lib/route.js +38 -17
- package/lib/route.js.map +1 -1
- package/lib/time.d.ts +7 -0
- package/lib/time.d.ts.map +1 -1
- package/lib/time.js +10 -1
- package/lib/time.js.map +1 -1
- package/package.json +2 -2
- package/src/__mocks__/fake-route-data.story.json +5425 -0
- package/src/__mocks__/fake-transit-operators.story.json +97 -0
- package/src/__snapshots__/core-utils.story.tsx.snap +8382 -0
- package/src/__tests__/__mocks__/routes.json +234 -105
- package/src/__tests__/__snapshots__/route.js.snap +285 -95
- package/src/__tests__/route.js +27 -55
- package/src/core-utils.story.tsx +200 -1
- package/src/query-gen.ts +1 -1
- package/src/route.ts +41 -21
- package/src/time.ts +9 -0
- package/tsconfig.tsbuildinfo +1 -1
package/esm/route.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/typeof";
|
|
1
2
|
import chroma from "chroma-js";
|
|
2
3
|
/**
|
|
3
4
|
* Returns the transit operator (if an exact match is found) from the transit
|
|
@@ -46,10 +47,10 @@ export function getTransitOperatorFromOtpRoute(route, transitOperators) {
|
|
|
46
47
|
var feedId = route.id.split(":")[0];
|
|
47
48
|
var agencyId;
|
|
48
49
|
if (route.agency) {
|
|
49
|
-
// This is returned in
|
|
50
|
+
// This is returned in OTP2
|
|
50
51
|
agencyId = route.agency.id;
|
|
51
52
|
} else if (route.agencyId) {
|
|
52
|
-
// This is returned in
|
|
53
|
+
// This is returned in OTP1
|
|
53
54
|
agencyId = route.agencyId;
|
|
54
55
|
} else {
|
|
55
56
|
return null;
|
|
@@ -86,9 +87,9 @@ function getTransitOperatorComparatorValue(route, transitOperators) {
|
|
|
86
87
|
// if the transitOperators is undefined or has zero length, use the route's
|
|
87
88
|
// agency name as the comparator value
|
|
88
89
|
if (!transitOperators || transitOperators.length === 0) {
|
|
89
|
-
//
|
|
90
|
+
// OTP2 Route
|
|
90
91
|
if (route.agency) return route.agency.name;
|
|
91
|
-
//
|
|
92
|
+
// OTP1 Route
|
|
92
93
|
if (route.agencyName) return route.agencyName;
|
|
93
94
|
// shouldn't happen as agency names will be defined
|
|
94
95
|
return "zzz";
|
|
@@ -109,7 +110,7 @@ function getTransitOperatorComparatorValue(route, transitOperators) {
|
|
|
109
110
|
* Calculates the sort comparator value given two routes based off of the
|
|
110
111
|
* route's agency and provided transitOperators config data.
|
|
111
112
|
*/
|
|
112
|
-
function makeTransitOperatorComparator(transitOperators) {
|
|
113
|
+
export function makeTransitOperatorComparator(transitOperators) {
|
|
113
114
|
return function (a, b) {
|
|
114
115
|
var aVal = getTransitOperatorComparatorValue(a, transitOperators);
|
|
115
116
|
var bVal = getTransitOperatorComparatorValue(b, transitOperators);
|
|
@@ -215,7 +216,7 @@ function getRouteTypeComparatorValue(route) {
|
|
|
215
216
|
* Calculates the sort comparator value given two routes based off of route type
|
|
216
217
|
* (OTP mode).
|
|
217
218
|
*/
|
|
218
|
-
function routeTypeComparator(a, b) {
|
|
219
|
+
export function routeTypeComparator(a, b) {
|
|
219
220
|
return getRouteTypeComparatorValue(a) - getRouteTypeComparatorValue(b);
|
|
220
221
|
}
|
|
221
222
|
|
|
@@ -236,7 +237,7 @@ function startsWithAlphabeticCharacter(val) {
|
|
|
236
237
|
* character. Routes with shortn that do start with an alphabetic character will
|
|
237
238
|
* be prioritized over those that don't.
|
|
238
239
|
*/
|
|
239
|
-
function alphabeticShortNameComparator(a, b) {
|
|
240
|
+
export function alphabeticShortNameComparator(a, b) {
|
|
240
241
|
var aStartsWithAlphabeticCharacter = startsWithAlphabeticCharacter(a.shortName);
|
|
241
242
|
var bStartsWithAlphabeticCharacter = startsWithAlphabeticCharacter(b.shortName);
|
|
242
243
|
if (aStartsWithAlphabeticCharacter && bStartsWithAlphabeticCharacter) {
|
|
@@ -251,7 +252,13 @@ function alphabeticShortNameComparator(a, b) {
|
|
|
251
252
|
// Return equivalence
|
|
252
253
|
return 0;
|
|
253
254
|
}
|
|
254
|
-
|
|
255
|
+
var isNullOrNaN = function isNullOrNaN(val) {
|
|
256
|
+
// isNaN(null) returns false so we have to check for null explicitly.
|
|
257
|
+
// Note: Using the global version of isNaN (the Number version behaves differently.
|
|
258
|
+
// eslint-disable-next-line no-restricted-globals
|
|
259
|
+
if (_typeof(val) === null || isNaN(val)) return true;
|
|
260
|
+
return typeof val !== "number";
|
|
261
|
+
};
|
|
255
262
|
/**
|
|
256
263
|
* Checks whether an appropriate comparison of numeric values can be made for
|
|
257
264
|
* sorting purposes. If both values are not valid numbers according to the
|
|
@@ -272,21 +279,23 @@ function alphabeticShortNameComparator(a, b) {
|
|
|
272
279
|
* comparison value from the comparator function arguments
|
|
273
280
|
*/
|
|
274
281
|
export function makeNumericValueComparator(objGetterFn) {
|
|
275
|
-
/* Note: Using the global version of isNaN (the Number version behaves differently. */
|
|
276
|
-
/* eslint-disable no-restricted-globals */
|
|
277
282
|
return function (a, b) {
|
|
278
283
|
var _getSortValues = getSortValues(objGetterFn, a, b),
|
|
279
284
|
aVal = _getSortValues.aVal,
|
|
280
285
|
bVal = _getSortValues.bVal;
|
|
281
|
-
if (typeof aVal !== "number" || typeof bVal !== "number") return 0;
|
|
282
286
|
|
|
283
287
|
// if both values aren't valid numbers, use the next sort criteria
|
|
284
|
-
if (
|
|
288
|
+
if (isNullOrNaN(aVal) && isNullOrNaN(bVal)) {
|
|
289
|
+
return 0;
|
|
290
|
+
}
|
|
285
291
|
// b is a valid number, b gets priority
|
|
286
|
-
if (
|
|
292
|
+
if (isNullOrNaN(aVal)) return 1;
|
|
293
|
+
|
|
287
294
|
// a is a valid number, a gets priority
|
|
288
|
-
if (
|
|
295
|
+
if (isNullOrNaN(bVal)) return -1;
|
|
296
|
+
|
|
289
297
|
// a and b are valid numbers, return the sort value
|
|
298
|
+
// @ts-expect-error We know from the checks above that both aVal and bVal are valid numbers.
|
|
290
299
|
return aVal - bVal;
|
|
291
300
|
};
|
|
292
301
|
}
|
|
@@ -320,15 +329,21 @@ export function makeStringValueComparator(objGetterFn) {
|
|
|
320
329
|
}
|
|
321
330
|
|
|
322
331
|
/**
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
332
|
+
* OTP1 sets the routeSortOrder to -999 by default. If we're encountering that value in OTP1,
|
|
333
|
+
* assume that it actually means that the route sortOrder is not set in the GTFS. If we encounter
|
|
334
|
+
* it in OTP2, it's a valid value, so we should return it.
|
|
326
335
|
*
|
|
327
336
|
* See https://github.com/opentripplanner/OpenTripPlanner/issues/2938
|
|
328
337
|
* Also see https://github.com/opentripplanner/otp-react-redux/issues/122
|
|
338
|
+
* This was updated in OTP2 TO be empty by default. https://docs.opentripplanner.org/en/v2.3.0/OTP2-MigrationGuide/#:~:text=the%20Alerts-,Changes%20to%20the%20Index%20API,-Error%20handling%20is
|
|
329
339
|
*/
|
|
330
|
-
function getRouteSortOrderValue(
|
|
331
|
-
|
|
340
|
+
export function getRouteSortOrderValue(route) {
|
|
341
|
+
var isOTP1 = !!route.agencyId;
|
|
342
|
+
var sortOrder = route.sortOrder;
|
|
343
|
+
if (isOTP1 && sortOrder === -999 || sortOrder === undefined) {
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
346
|
+
return sortOrder;
|
|
332
347
|
}
|
|
333
348
|
|
|
334
349
|
/**
|
|
@@ -338,7 +353,7 @@ function getRouteSortOrderValue(val) {
|
|
|
338
353
|
* returned. If all comparison functions return equivalence, then the values
|
|
339
354
|
* are assumed to be equivalent.
|
|
340
355
|
*/
|
|
341
|
-
function makeMultiCriteriaSort() {
|
|
356
|
+
export function makeMultiCriteriaSort() {
|
|
342
357
|
for (var _len = arguments.length, criteria = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
343
358
|
criteria[_key] = arguments[_key];
|
|
344
359
|
}
|
|
@@ -388,7 +403,7 @@ function makeMultiCriteriaSort() {
|
|
|
388
403
|
*/
|
|
389
404
|
export function makeRouteComparator(transitOperators) {
|
|
390
405
|
return makeMultiCriteriaSort(makeTransitOperatorComparator(transitOperators), makeNumericValueComparator(function (obj) {
|
|
391
|
-
return getRouteSortOrderValue(obj
|
|
406
|
+
return getRouteSortOrderValue(obj);
|
|
392
407
|
}), routeTypeComparator, alphabeticShortNameComparator, makeNumericValueComparator(function (obj) {
|
|
393
408
|
return parseInt(obj.shortName, 10);
|
|
394
409
|
}), makeStringValueComparator(function (obj) {
|
package/esm/route.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.js","names":["chroma","getTransitOperatorFromFeedIdAndAgencyId","feedId","agencyId","transitOperators","find","transitOperator","getTransitOperatorFromLeg","leg","routeId","split","getTransitOperatorFromOtpRoute","route","id","agency","END_OF_LIST_COMPARATOR_VALUE","getTransitOperatorComparatorValue","length","name","agencyName","order","makeTransitOperatorComparator","a","b","aVal","bVal","getSortValues","getterFn","modeComparatorValue","SUBWAY","TRAM","TROLLEYBUS","RAIL","GONDOLA","FERRY","CABLE_CAR","FUNICULAR","BUS","routeTypeComparatorValue","getRouteTypeComparatorValue","Error","concat","mode","type","console","warn","routeTypeComparator","startsWithAlphabeticCharacter","val","firstCharCode","charCodeAt","alphabeticShortNameComparator","aStartsWithAlphabeticCharacter","shortName","bStartsWithAlphabeticCharacter","makeNumericValueComparator","objGetterFn","_getSortValues","isNaN","makeStringValueComparator","_getSortValues2","getRouteSortOrderValue","undefined","makeMultiCriteriaSort","_len","arguments","criteria","Array","_key","i","curCriteriaComparatorValue","makeRouteComparator","obj","sortOrder","parseInt","longName","getMostReadableTextColor","backgroundColor","proposedTextColor","startsWith","fgLuminance","luminance","bgLuminance","Math","abs"],"sources":["../src/route.ts"],"sourcesContent":["import { Leg, Route, TransitOperator } from \"@opentripplanner/types\";\nimport chroma from \"chroma-js\";\n/**\n * Returns the transit operator (if an exact match is found) from the transit\n * operators config value. It is critical to use both the feedId and agencyId in\n * this method because it is possible in OTP for there to be a duplicate\n * agencyId in separate feeds.\n *\n * @param {string} feedId The feedId that this transit agency belongs to\n * @param {string} agencyId The agencyId of the transit agency\n * @param {array} transitOperators The transitOperators list from the config\n * @return {object} The transitOperator if a match was found or null if no match\n * was found\n */\nexport function getTransitOperatorFromFeedIdAndAgencyId(\n feedId: string,\n agencyId: string | number,\n transitOperators: TransitOperator[]\n): TransitOperator {\n return (\n transitOperators.find(\n transitOperator =>\n transitOperator.feedId === feedId &&\n transitOperator.agencyId === agencyId\n ) || null\n );\n}\n\n/**\n * Looks up an operator from the provided leg.\n *\n * @param {object} leg The Itinerary Leg from which to find the transit\n * operator\n * @param {object} transitOperators transitOperators from config.\n * @return {object} the operator if one was found or null if no match was found\n */\nexport function getTransitOperatorFromLeg(\n leg: Leg,\n transitOperators: TransitOperator[]\n): TransitOperator {\n if (!leg.routeId || !leg.agencyId) return null;\n const feedId = leg.routeId.split(\":\")[0];\n return getTransitOperatorFromFeedIdAndAgencyId(\n feedId,\n leg.agencyId,\n transitOperators\n );\n}\n\n/**\n * Looks up an operator from the provided configuration given an OTP route.\n * NOTE: this assumes the use of the OTP Route model or a modified OTP\n * RouteShort model (such as the one found in the IBI fork of OTP) that also\n * returns the agencyId.\n *\n * @param {object} route Either an OTP Route or RouteShort model\n * @param {array} transitOperators transitOperators from config\n * @return {object} the operator if one was found or null if no match was found\n */\nexport function getTransitOperatorFromOtpRoute(\n route: Route,\n transitOperators: TransitOperator[]\n): TransitOperator {\n if (!route.id) return null;\n const feedId = route.id.split(\":\")[0];\n let agencyId: string | number;\n if (route.agency) {\n // This is returned in the OTP Route model\n agencyId = route.agency.id;\n } else if (route.agencyId) {\n // This is returned in the OTP RouteShort model (such as in the IBI fork)\n agencyId = route.agencyId;\n } else {\n return null;\n }\n return getTransitOperatorFromFeedIdAndAgencyId(\n feedId,\n agencyId,\n transitOperators\n );\n}\n\n// The functions below are for enhanced route sorting functions for the route\n// viewer on OTP-react-redux.\n// They address route ordering issues discussed in\n// https://github.com/opentripplanner/otp-react-redux/pull/123 and\n// https://github.com/opentripplanner/otp-react-redux/pull/124.\n\n/**\n * A large comparator value that can safely be used in mathematical sort\n * comparisons to place things at the end of lists\n */\nconst END_OF_LIST_COMPARATOR_VALUE = 999999999999;\n\n/**\n * Returns a transit operator comparator value given a route and an optional\n * transitOperators config value. This function will do its best to handle all\n * kinds of input data as certain deployments of an implementing webapp may have\n * incomplete data and certain versions of OTP might not have a modified\n * implementation of the RouteShort model.\n *\n * @param {object} route Either an OTP Route or RouteShort model\n * @param {array} transitOperators transitOperators from config\n * @return {mixed} this could return a string value (the route's agency name) if\n * the transitOperators value is not defined. Otherwise an integer will be\n * returned.\n */\nfunction getTransitOperatorComparatorValue(\n route: Route,\n transitOperators: TransitOperator[]\n): number | string {\n // if the transitOperators is undefined or has zero length, use the route's\n // agency name as the comparator value\n if (!transitOperators || transitOperators.length === 0) {\n // OTP Route\n if (route.agency) return route.agency.name;\n // OTP RouteShort (base OTP repo or IBI fork)\n if (route.agencyName) return route.agencyName;\n // shouldn't happen as agency names will be defined\n return \"zzz\";\n }\n\n // find operator associated with route\n const transitOperator = getTransitOperatorFromOtpRoute(\n route,\n transitOperators\n );\n\n // if transit operator not found, return infinity\n if (!transitOperator) return END_OF_LIST_COMPARATOR_VALUE;\n\n // return the transit operator's sort value or END_OF_LIST_COMPARATOR_VALUE if\n // the sort value is not a number\n return typeof transitOperator.order === \"number\"\n ? transitOperator.order\n : END_OF_LIST_COMPARATOR_VALUE;\n}\n\n/**\n * Calculates the sort comparator value given two routes based off of the\n * route's agency and provided transitOperators config data.\n */\nfunction makeTransitOperatorComparator(transitOperators: TransitOperator[]) {\n return (a: Route, b: Route) => {\n const aVal = getTransitOperatorComparatorValue(a, transitOperators);\n const bVal = getTransitOperatorComparatorValue(b, transitOperators);\n if (typeof aVal === \"string\") {\n // happens when transitOperators is undefined. Both aVal are guaranteed to\n // be strings. Make a string comparison.\n if (aVal < bVal) return -1;\n if (aVal > bVal) return 1;\n return 0;\n }\n // @ts-expect-error transitOperators are defined and therefore a numeric value is guaranteed\n // to be returned\n return aVal - bVal;\n };\n}\n\n/**\n * Gets the desired sort values according to an optional getter function. If the\n * getter function is not defined, the original sort values are returned.\n */\nfunction getSortValues(\n getterFn: (item: unknown) => unknown,\n a: unknown,\n b: unknown\n) {\n let aVal: unknown;\n let bVal: unknown;\n if (typeof getterFn === \"function\") {\n aVal = getterFn(a);\n bVal = getterFn(b);\n } else {\n aVal = a;\n bVal = b;\n }\n return { aVal, bVal };\n}\n\n// Lookup for the sort values associated with various OTP modes.\n// Note: JSDoc format not used to avoid bug in documentationjs.\n// https://github.com/documentationjs/documentation/issues/372\nconst modeComparatorValue = {\n SUBWAY: 1,\n TRAM: 2,\n TROLLEYBUS: 9,\n RAIL: 3,\n GONDOLA: 4,\n FERRY: 5,\n CABLE_CAR: 6,\n FUNICULAR: 7,\n BUS: 8\n};\n\n// Lookup that maps route types to the OTP mode sort values.\n// Note: JSDoc format not used to avoid bug in documentationjs.\n// https://github.com/documentationjs/documentation/issues/372\nconst routeTypeComparatorValue = {\n 0: modeComparatorValue.TRAM, // - Tram, Streetcar, Light rail.\n 1: modeComparatorValue.SUBWAY, // - Subway, Metro.\n 2: modeComparatorValue.RAIL, // - Rail. Used for intercity or long-distance travel.\n 3: modeComparatorValue.BUS, // - Bus.\n 4: modeComparatorValue.FERRY, // - Ferry.\n 5: modeComparatorValue.CABLE_CAR, // - Cable tram.\n 6: modeComparatorValue.GONDOLA, // - Gondola, etc.\n 7: modeComparatorValue.FUNICULAR, // - Funicular.\n // TODO: 11 and 12 are not a part of OTP as of 2019-02-14, but for now just\n // associate them with bus/rail.\n 11: modeComparatorValue.BUS, // - Trolleybus.\n 12: modeComparatorValue.RAIL, // - Monorail.\n 13: modeComparatorValue.TROLLEYBUS\n};\n\n// Gets a comparator value for a given route's type (OTP mode).\n// Note: JSDoc format not used to avoid bug in documentationjs.\n// ttps://github.com/documentationjs/documentation/issues/372\nfunction getRouteTypeComparatorValue(route: Route): number {\n // For some strange reason, the short route response in OTP returns the\n // string-based modes, but the long route response returns the\n // integer route type. This attempts to account for both of those cases.\n if (!route) throw new Error(`Route is undefined. ${route}`);\n if (typeof modeComparatorValue[route.mode] !== \"undefined\") {\n return modeComparatorValue[route.mode];\n }\n if (typeof routeTypeComparatorValue[route.type] !== \"undefined\") {\n return routeTypeComparatorValue[route.type];\n }\n // Default the comparator value to a large number (placing the route at the\n // end of the list).\n // eslint-disable-next-line no-console\n console.warn(\"no mode/route type found for route\", route);\n return END_OF_LIST_COMPARATOR_VALUE;\n}\n\n/**\n * Calculates the sort comparator value given two routes based off of route type\n * (OTP mode).\n */\nfunction routeTypeComparator(a: Route, b: Route): number {\n return getRouteTypeComparatorValue(a) - getRouteTypeComparatorValue(b);\n}\n\n/**\n * Determines whether a value is a string that starts with an alphabetic\n * ascii character.\n */\nfunction startsWithAlphabeticCharacter(val: unknown): boolean {\n if (typeof val === \"string\" && val.length > 0) {\n const firstCharCode = val.charCodeAt(0);\n return (\n (firstCharCode >= 65 && firstCharCode <= 90) ||\n (firstCharCode >= 97 && firstCharCode <= 122)\n );\n }\n return false;\n}\n\n/**\n * Sorts routes based off of whether the shortName begins with an alphabetic\n * character. Routes with shortn that do start with an alphabetic character will\n * be prioritized over those that don't.\n */\nfunction alphabeticShortNameComparator(a: Route, b: Route): number {\n const aStartsWithAlphabeticCharacter = startsWithAlphabeticCharacter(\n a.shortName\n );\n const bStartsWithAlphabeticCharacter = startsWithAlphabeticCharacter(\n b.shortName\n );\n\n if (aStartsWithAlphabeticCharacter && bStartsWithAlphabeticCharacter) {\n // both start with an alphabetic character, return equivalence\n return 0;\n }\n // a does start with an alphabetic character, but b does not. Prioritize a\n if (aStartsWithAlphabeticCharacter) return -1;\n // b does start with an alphabetic character, but a does not. Prioritize b\n if (bStartsWithAlphabeticCharacter) return 1;\n // neither route has a shortName that starts with an alphabetic character.\n // Return equivalence\n return 0;\n}\n\n/**\n * Checks whether an appropriate comparison of numeric values can be made for\n * sorting purposes. If both values are not valid numbers according to the\n * isNaN check, then this function returns undefined which indicates that a\n * secondary sorting criteria should be used instead. If one value is valid and\n * the other is not, then the valid value will be given sorting priority. If\n * both values are valid numbers, the difference is obtained as the sort value.\n *\n * An optional argument can be provided which will be used to obtain the\n * comparison value from the comparison function arguments.\n *\n * IMPORTANT: the comparison values must be numeric values or at least be\n * attempted to be converted to numeric values! If one of the arguments is\n * something crazy like an empty string, unexpected behavior will occur because\n * JavaScript.\n *\n * @param {function} [objGetterFn] An optional function to obtain the\n * comparison value from the comparator function arguments\n */\nexport function makeNumericValueComparator(\n objGetterFn?: (item: Route) => number\n) {\n /* Note: Using the global version of isNaN (the Number version behaves differently. */\n /* eslint-disable no-restricted-globals */\n return (a: number, b: number): number => {\n const { aVal, bVal } = getSortValues(objGetterFn, a, b);\n if (typeof aVal !== \"number\" || typeof bVal !== \"number\") return 0;\n\n // if both values aren't valid numbers, use the next sort criteria\n if (isNaN(aVal) && isNaN(bVal)) return 0;\n // b is a valid number, b gets priority\n if (isNaN(aVal)) return 1;\n // a is a valid number, a gets priority\n if (isNaN(bVal)) return -1;\n // a and b are valid numbers, return the sort value\n return aVal - bVal;\n };\n}\n\n/**\n * Create a comparator function that compares string values. The comparison\n * values feed to the sort comparator function are assumed to be objects that\n * will have either undefined, null or string values at the given key. If one\n * object has undefined, null or an empty string, but the other does have a\n * string with length > 0, then that string will get priority.\n *\n * @param {function} [objGetterFn] An optional function to obtain the\n * comparison value from the comparator function arguments\n */\nexport function makeStringValueComparator(\n objGetterFn?: (item: Route) => string\n) {\n return (a: string, b: string): number => {\n const { aVal, bVal } = getSortValues(objGetterFn, a, b);\n // both a and b are uncomparable strings, return equivalent value\n if (!aVal && !bVal) return 0;\n // a is not a comparable string, b gets priority\n if (!aVal) return 1;\n // b is not a comparable string, a gets priority\n if (!bVal) return -1;\n // a and b are comparable strings, return the sort value\n if (aVal < bVal) return -1;\n if (aVal > bVal) return 1;\n return 0;\n };\n}\n\n/**\n * OpenTripPlanner sets the routeSortOrder to -999 by default. So, if that value\n * is encountered, assume that it actually means that the routeSortOrder is not\n * set in the GTFS.\n *\n * See https://github.com/opentripplanner/OpenTripPlanner/issues/2938\n * Also see https://github.com/opentripplanner/otp-react-redux/issues/122\n */\nfunction getRouteSortOrderValue(val: number): number {\n return val === -999 ? undefined : val;\n}\n\n/**\n * Create a multi-criteria sort comparator function composed of other sort\n * comparator functions. Each comparator function will be ran in the order given\n * until a non-zero comparison value is obtained which is then immediately\n * returned. If all comparison functions return equivalence, then the values\n * are assumed to be equivalent.\n */\nfunction makeMultiCriteriaSort(\n ...criteria: ((a: unknown, b: unknown) => number)[]\n) {\n return (a: number, b: number): number => {\n for (let i = 0; i < criteria.length; i++) {\n const curCriteriaComparatorValue = criteria[i](a, b);\n // if the comparison objects are not equivalent, return the value obtained\n // in this current criteria comparison\n if (curCriteriaComparatorValue !== 0) {\n return curCriteriaComparatorValue;\n }\n }\n return 0;\n };\n}\n\n/**\n * Creates a sort comparator function to compares routes for the purposes of\n * sorting and displaying in a user interface. This takes in a single optional\n * argument which should be a list of transitOperators as defined in the config\n * file. Due to GTFS feeds having varying levels of data quality, a multi-\n * criteria sort is needed to account for various differences. The criteria\n * included here are each applied to the routes in the order listed. If a given\n * sort criterion yields equivalence (e.g., two routes have the short name\n * \"20\"), the comparator falls back onto the next sort criterion (e.g., long\n * name). The sort operates on the following values (in order):\n *\n * 1. Transit Operator. The transit operator will be attempted to be obtained\n * for each route. If no argument is provided when creating this comparator\n * function, then routes will be sorted by their agency's name. If an\n * argument is provided and a match is found based off of the route's feed_id\n * and agency_id and a transitOperator's feed_id and agency_id, then the\n * field transitOperator.order will be used as the comparator value as long\n * as it is numeric. If it is not numeric, a value is returned indicating\n * that this transit operator should be placed at the end of the list.\n * 2. sortOrder. Routes that do not have a valid sortOrder will be placed\n * beneath those that do.\n * 3. route type (OTP mode). See routeTypeComparator code for prioritization of\n * route types.\n * 4. shortNames that begin with alphabetic characters. shortNames that do not\n * start with alphabetic characters will be place beneath those that do.\n * 5. shortName as integer. shortNames that cannot be parsed as integers will\n * be placed beneath those that are valid.\n * 6. shortName as string. Routes without shortNames will be placed beneath\n * those with shortNames.\n * 7. longName as string.\n */\nexport function makeRouteComparator(\n transitOperators: TransitOperator[]\n): (a: number, b: number) => number {\n return makeMultiCriteriaSort(\n makeTransitOperatorComparator(transitOperators),\n makeNumericValueComparator(obj => getRouteSortOrderValue(obj.sortOrder)),\n routeTypeComparator,\n alphabeticShortNameComparator,\n makeNumericValueComparator(obj => parseInt(obj.shortName, 10)),\n makeStringValueComparator(obj => obj.shortName),\n makeStringValueComparator(obj => obj.longName)\n );\n}\n\n/**\n * Tests if a pair of colors is readable. If it is, that readable color is returned.\n * If it is not, a more appropriate alternative is returned.\n *\n * Uses algorithm based on combined luminance. Values have been derived from\n * looking at real agency color pairings. These pairings are difficult to\n * generate for, as some colors see both white and black used by different agencies.\n *\n * This method therefore can accept multiple colors (including black and white) for the same background color.\n *\n * @param backgroundColor A hex string, usually the \"routeColor\"\n * @param proposedTextColor A hex string, usually the \"routeTextColor\"\n */\nexport function getMostReadableTextColor(\n backgroundColor: string,\n proposedTextColor?: string\n): string {\n // Sometimes input will defy the method signature. Therefore we need extra fallbacks\n if (!backgroundColor) backgroundColor = \"#333333\";\n if (!proposedTextColor) proposedTextColor = \"#ffffff\";\n\n if (!backgroundColor.startsWith(\"#\")) {\n backgroundColor = `#${backgroundColor}`;\n }\n if (!proposedTextColor.startsWith(\"#\")) {\n proposedTextColor = `#${proposedTextColor}`;\n }\n\n // Check if proposed color is readable\n // Luminance thresholds have been selected based on actual transit agency colors\n const fgLuminance = chroma(proposedTextColor).luminance();\n const bgLuminance = chroma(backgroundColor).luminance();\n if (\n bgLuminance + fgLuminance < 1.41 &&\n bgLuminance + fgLuminance > 0.25 &&\n Math.abs(bgLuminance - fgLuminance) > 0.2\n ) {\n return proposedTextColor;\n }\n\n // Return black or white based on luminance of background color\n // When generating colors, white is preferred.\n return chroma(backgroundColor).luminance() < 0.4 ? \"#ffffff\" : \"#000000\";\n}\n"],"mappings":"AACA,OAAOA,MAAM,MAAM,WAAW;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,uCAAuCA,CACrDC,MAAc,EACdC,QAAyB,EACzBC,gBAAmC,EAClB;EACjB,OACEA,gBAAgB,CAACC,IAAI,CACnB,UAAAC,eAAe;IAAA,OACbA,eAAe,CAACJ,MAAM,KAAKA,MAAM,IACjCI,eAAe,CAACH,QAAQ,KAAKA,QAAQ;EAAA,CACzC,CAAC,IAAI,IAAI;AAEb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,yBAAyBA,CACvCC,GAAQ,EACRJ,gBAAmC,EAClB;EACjB,IAAI,CAACI,GAAG,CAACC,OAAO,IAAI,CAACD,GAAG,CAACL,QAAQ,EAAE,OAAO,IAAI;EAC9C,IAAMD,MAAM,GAAGM,GAAG,CAACC,OAAO,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;EACxC,OAAOT,uCAAuC,CAC5CC,MAAM,EACNM,GAAG,CAACL,QAAQ,EACZC,gBACF,CAAC;AACH;;AAEA;AACA;AACA;AAC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BA,CACtCC,eAAuB,EACvBC,iBAA0B,EAClB;EACR;EACA,IAAI,CAACD,eAAe,EAAEA,eAAe,GAAG,SAAS;EACjD,IAAI,CAACC,iBAAiB,EAAEA,iBAAiB,GAAG,SAAS;EAErD,IAAI,CAACD,eAAe,CAACE,UAAU,CAAC,GAAG,CAAC,EAAE;IACpCF,eAAe,OAAApC,MAAA,CAAOoC,eAAe,CAAE;EACzC;EACA,IAAI,CAACC,iBAAiB,CAACC,UAAU,CAAC,GAAG,CAAC,EAAE;IACtCD,iBAAiB,OAAArC,MAAA,CAAOqC,iBAAiB,CAAE;EAC7C;;EAEA;EACA;EACA,IAAME,WAAW,GAAGhF,MAAM,CAAC8E,iBAAiB,CAAC,CAACG,SAAS,CAAC,CAAC;EACzD,IAAMC,WAAW,GAAGlF,MAAM,CAAC6E,eAAe,CAAC,CAACI,SAAS,CAAC,CAAC;EACvD,IACEC,WAAW,GAAGF,WAAW,GAAG,IAAI,IAChCE,WAAW,GAAGF,WAAW,GAAG,IAAI,IAChCG,IAAI,CAACC,GAAG,CAACF,WAAW,GAAGF,WAAW,CAAC,GAAG,GAAG,EACzC;IACA,OAAOF,iBAAiB;EAC1B;;EAEA;EACA;EACA,OAAO9E,MAAM,CAAC6E,eAAe,CAAC,CAACI,SAAS,CAAC,CAAC,GAAG,GAAG,GAAG,SAAS,GAAG,SAAS;AAC1E","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"route.js","names":["chroma","getTransitOperatorFromFeedIdAndAgencyId","feedId","agencyId","transitOperators","find","transitOperator","getTransitOperatorFromLeg","leg","routeId","split","getTransitOperatorFromOtpRoute","route","id","agency","END_OF_LIST_COMPARATOR_VALUE","getTransitOperatorComparatorValue","length","name","agencyName","order","makeTransitOperatorComparator","a","b","aVal","bVal","getSortValues","getterFn","modeComparatorValue","SUBWAY","TRAM","TROLLEYBUS","RAIL","GONDOLA","FERRY","CABLE_CAR","FUNICULAR","BUS","routeTypeComparatorValue","getRouteTypeComparatorValue","Error","concat","mode","type","console","warn","routeTypeComparator","startsWithAlphabeticCharacter","val","firstCharCode","charCodeAt","alphabeticShortNameComparator","aStartsWithAlphabeticCharacter","shortName","bStartsWithAlphabeticCharacter","isNullOrNaN","_typeof","isNaN","makeNumericValueComparator","objGetterFn","_getSortValues","makeStringValueComparator","_getSortValues2","getRouteSortOrderValue","isOTP1","sortOrder","undefined","makeMultiCriteriaSort","_len","arguments","criteria","Array","_key","i","curCriteriaComparatorValue","makeRouteComparator","obj","parseInt","longName","getMostReadableTextColor","backgroundColor","proposedTextColor","startsWith","fgLuminance","luminance","bgLuminance","Math","abs"],"sources":["../src/route.ts"],"sourcesContent":["import { Leg, Route, TransitOperator } from \"@opentripplanner/types\";\nimport chroma from \"chroma-js\";\n/**\n * Returns the transit operator (if an exact match is found) from the transit\n * operators config value. It is critical to use both the feedId and agencyId in\n * this method because it is possible in OTP for there to be a duplicate\n * agencyId in separate feeds.\n *\n * @param {string} feedId The feedId that this transit agency belongs to\n * @param {string} agencyId The agencyId of the transit agency\n * @param {array} transitOperators The transitOperators list from the config\n * @return {object} The transitOperator if a match was found or null if no match\n * was found\n */\nexport function getTransitOperatorFromFeedIdAndAgencyId(\n feedId: string,\n agencyId: string | number,\n transitOperators: TransitOperator[]\n): TransitOperator {\n return (\n transitOperators.find(\n transitOperator =>\n transitOperator.feedId === feedId &&\n transitOperator.agencyId === agencyId\n ) || null\n );\n}\n\n/**\n * Looks up an operator from the provided leg.\n *\n * @param {object} leg The Itinerary Leg from which to find the transit\n * operator\n * @param {object} transitOperators transitOperators from config.\n * @return {object} the operator if one was found or null if no match was found\n */\nexport function getTransitOperatorFromLeg(\n leg: Leg,\n transitOperators: TransitOperator[]\n): TransitOperator {\n if (!leg.routeId || !leg.agencyId) return null;\n const feedId = leg.routeId.split(\":\")[0];\n return getTransitOperatorFromFeedIdAndAgencyId(\n feedId,\n leg.agencyId,\n transitOperators\n );\n}\n\n/**\n * Looks up an operator from the provided configuration given an OTP route.\n * NOTE: this assumes the use of the OTP Route model or a modified OTP\n * RouteShort model (such as the one found in the IBI fork of OTP) that also\n * returns the agencyId.\n *\n * @param {object} route Either an OTP Route or RouteShort model\n * @param {array} transitOperators transitOperators from config\n * @return {object} the operator if one was found or null if no match was found\n */\nexport function getTransitOperatorFromOtpRoute(\n route: Route,\n transitOperators: TransitOperator[]\n): TransitOperator {\n if (!route.id) return null;\n const feedId = route.id.split(\":\")[0];\n let agencyId: string | number;\n if (route.agency) {\n // This is returned in OTP2\n agencyId = route.agency.id;\n } else if (route.agencyId) {\n // This is returned in OTP1\n agencyId = route.agencyId;\n } else {\n return null;\n }\n return getTransitOperatorFromFeedIdAndAgencyId(\n feedId,\n agencyId,\n transitOperators\n );\n}\n\n// The functions below are for enhanced route sorting functions for the route\n// viewer on OTP-react-redux.\n// They address route ordering issues discussed in\n// https://github.com/opentripplanner/otp-react-redux/pull/123 and\n// https://github.com/opentripplanner/otp-react-redux/pull/124.\n\n/**\n * A large comparator value that can safely be used in mathematical sort\n * comparisons to place things at the end of lists\n */\nconst END_OF_LIST_COMPARATOR_VALUE = 999999999999;\n\n/**\n * Returns a transit operator comparator value given a route and an optional\n * transitOperators config value. This function will do its best to handle all\n * kinds of input data as certain deployments of an implementing webapp may have\n * incomplete data and certain versions of OTP might not have a modified\n * implementation of the RouteShort model.\n *\n * @param {object} route Either an OTP Route or RouteShort model\n * @param {array} transitOperators transitOperators from config\n * @return {mixed} this could return a string value (the route's agency name) if\n * the transitOperators value is not defined. Otherwise an integer will be\n * returned.\n */\nfunction getTransitOperatorComparatorValue(\n route: Route,\n transitOperators: TransitOperator[]\n): number | string {\n // if the transitOperators is undefined or has zero length, use the route's\n // agency name as the comparator value\n if (!transitOperators || transitOperators.length === 0) {\n // OTP2 Route\n if (route.agency) return route.agency.name;\n // OTP1 Route\n if (route.agencyName) return route.agencyName;\n // shouldn't happen as agency names will be defined\n return \"zzz\";\n }\n\n // find operator associated with route\n const transitOperator = getTransitOperatorFromOtpRoute(\n route,\n transitOperators\n );\n\n // if transit operator not found, return infinity\n if (!transitOperator) return END_OF_LIST_COMPARATOR_VALUE;\n\n // return the transit operator's sort value or END_OF_LIST_COMPARATOR_VALUE if\n // the sort value is not a number\n return typeof transitOperator.order === \"number\"\n ? transitOperator.order\n : END_OF_LIST_COMPARATOR_VALUE;\n}\n\n/**\n * Calculates the sort comparator value given two routes based off of the\n * route's agency and provided transitOperators config data.\n */\nexport function makeTransitOperatorComparator(\n transitOperators: TransitOperator[]\n) {\n return (a: Route, b: Route) => {\n const aVal = getTransitOperatorComparatorValue(a, transitOperators);\n const bVal = getTransitOperatorComparatorValue(b, transitOperators);\n if (typeof aVal === \"string\") {\n // happens when transitOperators is undefined. Both aVal are guaranteed to\n // be strings. Make a string comparison.\n if (aVal < bVal) return -1;\n if (aVal > bVal) return 1;\n return 0;\n }\n // @ts-expect-error transitOperators are defined and therefore a numeric value is guaranteed\n // to be returned\n return aVal - bVal;\n };\n}\n\n/**\n * Gets the desired sort values according to an optional getter function. If the\n * getter function is not defined, the original sort values are returned.\n */\nfunction getSortValues(\n getterFn: (item: unknown) => unknown,\n a: unknown,\n b: unknown\n) {\n let aVal: unknown;\n let bVal: unknown;\n if (typeof getterFn === \"function\") {\n aVal = getterFn(a);\n bVal = getterFn(b);\n } else {\n aVal = a;\n bVal = b;\n }\n return { aVal, bVal };\n}\n\n// Lookup for the sort values associated with various OTP modes.\n// Note: JSDoc format not used to avoid bug in documentationjs.\n// https://github.com/documentationjs/documentation/issues/372\nconst modeComparatorValue = {\n SUBWAY: 1,\n TRAM: 2,\n TROLLEYBUS: 9,\n RAIL: 3,\n GONDOLA: 4,\n FERRY: 5,\n CABLE_CAR: 6,\n FUNICULAR: 7,\n BUS: 8\n};\n\n// Lookup that maps route types to the OTP mode sort values.\n// Note: JSDoc format not used to avoid bug in documentationjs.\n// https://github.com/documentationjs/documentation/issues/372\nconst routeTypeComparatorValue = {\n 0: modeComparatorValue.TRAM, // - Tram, Streetcar, Light rail.\n 1: modeComparatorValue.SUBWAY, // - Subway, Metro.\n 2: modeComparatorValue.RAIL, // - Rail. Used for intercity or long-distance travel.\n 3: modeComparatorValue.BUS, // - Bus.\n 4: modeComparatorValue.FERRY, // - Ferry.\n 5: modeComparatorValue.CABLE_CAR, // - Cable tram.\n 6: modeComparatorValue.GONDOLA, // - Gondola, etc.\n 7: modeComparatorValue.FUNICULAR, // - Funicular.\n // TODO: 11 and 12 are not a part of OTP as of 2019-02-14, but for now just\n // associate them with bus/rail.\n 11: modeComparatorValue.BUS, // - Trolleybus.\n 12: modeComparatorValue.RAIL, // - Monorail.\n 13: modeComparatorValue.TROLLEYBUS\n};\n\n// Gets a comparator value for a given route's type (OTP mode).\n// Note: JSDoc format not used to avoid bug in documentationjs.\n// ttps://github.com/documentationjs/documentation/issues/372\nfunction getRouteTypeComparatorValue(route: Route): number {\n // For some strange reason, the short route response in OTP returns the\n // string-based modes, but the long route response returns the\n // integer route type. This attempts to account for both of those cases.\n if (!route) throw new Error(`Route is undefined. ${route}`);\n if (typeof modeComparatorValue[route.mode] !== \"undefined\") {\n return modeComparatorValue[route.mode];\n }\n if (typeof routeTypeComparatorValue[route.type] !== \"undefined\") {\n return routeTypeComparatorValue[route.type];\n }\n // Default the comparator value to a large number (placing the route at the\n // end of the list).\n // eslint-disable-next-line no-console\n console.warn(\"no mode/route type found for route\", route);\n return END_OF_LIST_COMPARATOR_VALUE;\n}\n\n/**\n * Calculates the sort comparator value given two routes based off of route type\n * (OTP mode).\n */\nexport function routeTypeComparator(a: Route, b: Route): number {\n return getRouteTypeComparatorValue(a) - getRouteTypeComparatorValue(b);\n}\n\n/**\n * Determines whether a value is a string that starts with an alphabetic\n * ascii character.\n */\nfunction startsWithAlphabeticCharacter(val: unknown): boolean {\n if (typeof val === \"string\" && val.length > 0) {\n const firstCharCode = val.charCodeAt(0);\n return (\n (firstCharCode >= 65 && firstCharCode <= 90) ||\n (firstCharCode >= 97 && firstCharCode <= 122)\n );\n }\n return false;\n}\n\n/**\n * Sorts routes based off of whether the shortName begins with an alphabetic\n * character. Routes with shortn that do start with an alphabetic character will\n * be prioritized over those that don't.\n */\nexport function alphabeticShortNameComparator(a: Route, b: Route): number {\n const aStartsWithAlphabeticCharacter = startsWithAlphabeticCharacter(\n a.shortName\n );\n const bStartsWithAlphabeticCharacter = startsWithAlphabeticCharacter(\n b.shortName\n );\n\n if (aStartsWithAlphabeticCharacter && bStartsWithAlphabeticCharacter) {\n // both start with an alphabetic character, return equivalence\n return 0;\n }\n // a does start with an alphabetic character, but b does not. Prioritize a\n if (aStartsWithAlphabeticCharacter) return -1;\n // b does start with an alphabetic character, but a does not. Prioritize b\n if (bStartsWithAlphabeticCharacter) return 1;\n // neither route has a shortName that starts with an alphabetic character.\n // Return equivalence\n return 0;\n}\n\nconst isNullOrNaN = (val: any): boolean => {\n // isNaN(null) returns false so we have to check for null explicitly.\n // Note: Using the global version of isNaN (the Number version behaves differently.\n // eslint-disable-next-line no-restricted-globals\n if (typeof val === null || isNaN(val)) return true;\n\n return typeof val !== \"number\";\n};\n/**\n * Checks whether an appropriate comparison of numeric values can be made for\n * sorting purposes. If both values are not valid numbers according to the\n * isNaN check, then this function returns undefined which indicates that a\n * secondary sorting criteria should be used instead. If one value is valid and\n * the other is not, then the valid value will be given sorting priority. If\n * both values are valid numbers, the difference is obtained as the sort value.\n *\n * An optional argument can be provided which will be used to obtain the\n * comparison value from the comparison function arguments.\n *\n * IMPORTANT: the comparison values must be numeric values or at least be\n * attempted to be converted to numeric values! If one of the arguments is\n * something crazy like an empty string, unexpected behavior will occur because\n * JavaScript.\n *\n * @param {function} [objGetterFn] An optional function to obtain the\n * comparison value from the comparator function arguments\n */\nexport function makeNumericValueComparator(\n objGetterFn?: (item: Route) => number\n) {\n return (a: number, b: number): number | null => {\n const { aVal, bVal } = getSortValues(objGetterFn, a, b);\n\n // if both values aren't valid numbers, use the next sort criteria\n if (isNullOrNaN(aVal) && isNullOrNaN(bVal)) {\n return 0;\n }\n // b is a valid number, b gets priority\n if (isNullOrNaN(aVal)) return 1;\n\n // a is a valid number, a gets priority\n if (isNullOrNaN(bVal)) return -1;\n\n // a and b are valid numbers, return the sort value\n // @ts-expect-error We know from the checks above that both aVal and bVal are valid numbers.\n return aVal - bVal;\n };\n}\n\n/**\n * Create a comparator function that compares string values. The comparison\n * values feed to the sort comparator function are assumed to be objects that\n * will have either undefined, null or string values at the given key. If one\n * object has undefined, null or an empty string, but the other does have a\n * string with length > 0, then that string will get priority.\n *\n * @param {function} [objGetterFn] An optional function to obtain the\n * comparison value from the comparator function arguments\n */\nexport function makeStringValueComparator(\n objGetterFn?: (item: Route) => string\n) {\n return (a: string, b: string): number => {\n const { aVal, bVal } = getSortValues(objGetterFn, a, b);\n // both a and b are uncomparable strings, return equivalent value\n if (!aVal && !bVal) return 0;\n // a is not a comparable string, b gets priority\n if (!aVal) return 1;\n // b is not a comparable string, a gets priority\n if (!bVal) return -1;\n // a and b are comparable strings, return the sort value\n if (aVal < bVal) return -1;\n if (aVal > bVal) return 1;\n return 0;\n };\n}\n\n/**\n * OTP1 sets the routeSortOrder to -999 by default. If we're encountering that value in OTP1,\n * assume that it actually means that the route sortOrder is not set in the GTFS. If we encounter\n * it in OTP2, it's a valid value, so we should return it.\n *\n * See https://github.com/opentripplanner/OpenTripPlanner/issues/2938\n * Also see https://github.com/opentripplanner/otp-react-redux/issues/122\n * This was updated in OTP2 TO be empty by default. https://docs.opentripplanner.org/en/v2.3.0/OTP2-MigrationGuide/#:~:text=the%20Alerts-,Changes%20to%20the%20Index%20API,-Error%20handling%20is\n */\nexport function getRouteSortOrderValue(route: Route): number {\n const isOTP1 = !!route.agencyId;\n const { sortOrder } = route;\n\n if ((isOTP1 && sortOrder === -999) || sortOrder === undefined) {\n return null;\n }\n\n return sortOrder;\n}\n\n/**\n * Create a multi-criteria sort comparator function composed of other sort\n * comparator functions. Each comparator function will be ran in the order given\n * until a non-zero comparison value is obtained which is then immediately\n * returned. If all comparison functions return equivalence, then the values\n * are assumed to be equivalent.\n */\nexport function makeMultiCriteriaSort(\n ...criteria: ((a: unknown, b: unknown) => number)[]\n) {\n return (a: number, b: number): number => {\n for (let i = 0; i < criteria.length; i++) {\n const curCriteriaComparatorValue = criteria[i](a, b);\n // if the comparison objects are not equivalent, return the value obtained\n // in this current criteria comparison\n if (curCriteriaComparatorValue !== 0) {\n return curCriteriaComparatorValue;\n }\n }\n return 0;\n };\n}\n\n/**\n * Creates a sort comparator function to compares routes for the purposes of\n * sorting and displaying in a user interface. This takes in a single optional\n * argument which should be a list of transitOperators as defined in the config\n * file. Due to GTFS feeds having varying levels of data quality, a multi-\n * criteria sort is needed to account for various differences. The criteria\n * included here are each applied to the routes in the order listed. If a given\n * sort criterion yields equivalence (e.g., two routes have the short name\n * \"20\"), the comparator falls back onto the next sort criterion (e.g., long\n * name). The sort operates on the following values (in order):\n *\n * 1. Transit Operator. The transit operator will be attempted to be obtained\n * for each route. If no argument is provided when creating this comparator\n * function, then routes will be sorted by their agency's name. If an\n * argument is provided and a match is found based off of the route's feed_id\n * and agency_id and a transitOperator's feed_id and agency_id, then the\n * field transitOperator.order will be used as the comparator value as long\n * as it is numeric. If it is not numeric, a value is returned indicating\n * that this transit operator should be placed at the end of the list.\n * 2. sortOrder. Routes that do not have a valid sortOrder will be placed\n * beneath those that do.\n * 3. route type (OTP mode). See routeTypeComparator code for prioritization of\n * route types.\n * 4. shortNames that begin with alphabetic characters. shortNames that do not\n * start with alphabetic characters will be place beneath those that do.\n * 5. shortName as integer. shortNames that cannot be parsed as integers will\n * be placed beneath those that are valid.\n * 6. shortName as string. Routes without shortNames will be placed beneath\n * those with shortNames.\n * 7. longName as string.\n */\nexport function makeRouteComparator(\n transitOperators: TransitOperator[]\n): (a: number, b: number) => number {\n return makeMultiCriteriaSort(\n makeTransitOperatorComparator(transitOperators),\n makeNumericValueComparator(obj => getRouteSortOrderValue(obj)),\n routeTypeComparator,\n alphabeticShortNameComparator,\n makeNumericValueComparator(obj => parseInt(obj.shortName, 10)),\n makeStringValueComparator(obj => obj.shortName),\n makeStringValueComparator(obj => obj.longName)\n );\n}\n\n/**\n * Tests if a pair of colors is readable. If it is, that readable color is returned.\n * If it is not, a more appropriate alternative is returned.\n *\n * Uses algorithm based on combined luminance. Values have been derived from\n * looking at real agency color pairings. These pairings are difficult to\n * generate for, as some colors see both white and black used by different agencies.\n *\n * This method therefore can accept multiple colors (including black and white) for the same background color.\n *\n * @param backgroundColor A hex string, usually the \"routeColor\"\n * @param proposedTextColor A hex string, usually the \"routeTextColor\"\n */\nexport function getMostReadableTextColor(\n backgroundColor: string,\n proposedTextColor?: string\n): string {\n // Sometimes input will defy the method signature. Therefore we need extra fallbacks\n if (!backgroundColor) backgroundColor = \"#333333\";\n if (!proposedTextColor) proposedTextColor = \"#ffffff\";\n\n if (!backgroundColor.startsWith(\"#\")) {\n backgroundColor = `#${backgroundColor}`;\n }\n if (!proposedTextColor.startsWith(\"#\")) {\n proposedTextColor = `#${proposedTextColor}`;\n }\n\n // Check if proposed color is readable\n // Luminance thresholds have been selected based on actual transit agency colors\n const fgLuminance = chroma(proposedTextColor).luminance();\n const bgLuminance = chroma(backgroundColor).luminance();\n if (\n bgLuminance + fgLuminance < 1.41 &&\n bgLuminance + fgLuminance > 0.25 &&\n Math.abs(bgLuminance - fgLuminance) > 0.2\n ) {\n return proposedTextColor;\n }\n\n // Return black or white based on luminance of background color\n // When generating colors, white is preferred.\n return chroma(backgroundColor).luminance() < 0.4 ? \"#ffffff\" : \"#000000\";\n}\n"],"mappings":";AACA,OAAOA,MAAM,MAAM,WAAW;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,uCAAuCA,CACrDC,MAAc,EACdC,QAAyB,EACzBC,gBAAmC,EAClB;EACjB,OACEA,gBAAgB,CAACC,IAAI,CACnB,UAAAC,eAAe;IAAA,OACbA,eAAe,CAACJ,MAAM,KAAKA,MAAM,IACjCI,eAAe,CAACH,QAAQ,KAAKA,QAA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
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
2
|
+
"otp1Routes": [
|
|
3
|
+
{
|
|
4
|
+
"agencyId": "bcd",
|
|
5
|
+
"longName": "Across town",
|
|
6
|
+
"mode": "BUS",
|
|
7
|
+
"shortName": "10",
|
|
8
|
+
"sortOrder": 10
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"agencyId": "bcd",
|
|
12
|
+
"longName": "Around town",
|
|
13
|
+
"mode": "BUS",
|
|
14
|
+
"shortName": "20",
|
|
15
|
+
"sortOrder": 2
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"agencyId": "bcd",
|
|
19
|
+
"longName": "Around another town",
|
|
20
|
+
"shortName": "3",
|
|
21
|
+
"sortOrder": -999,
|
|
22
|
+
"type": 3
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"agencyId": "bcd",
|
|
26
|
+
"longName": "Loop route",
|
|
27
|
+
"mode": "BUS",
|
|
28
|
+
"shortName": "2",
|
|
29
|
+
"sortOrder": -999
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"agencyId": "bcd",
|
|
33
|
+
"longName": "A-line",
|
|
34
|
+
"mode": "BUS",
|
|
35
|
+
"shortName": "A",
|
|
36
|
+
"sortOrder": -999
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"agencyId": "bcd",
|
|
40
|
+
"longName": "B-line",
|
|
41
|
+
"mode": "BUS",
|
|
42
|
+
"shortName": "B",
|
|
43
|
+
"sortOrder": -999
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"agencyId": "bcd",
|
|
47
|
+
"longName": "A meandering route",
|
|
48
|
+
"mode": "BUS",
|
|
49
|
+
"sortOrder": -999
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"agencyId": "bcd",
|
|
53
|
+
"longName": "Zig-zagging route",
|
|
54
|
+
"mode": "BUS",
|
|
55
|
+
"shortName": "30",
|
|
56
|
+
"sortOrder": 2
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"agencyId": "bcd",
|
|
60
|
+
"longName": "Express route",
|
|
61
|
+
"mode": "BUS",
|
|
62
|
+
"shortName": "30",
|
|
63
|
+
"sortOrder": 2
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"agencyId": "bcd",
|
|
67
|
+
"longName": "Variation of express route",
|
|
68
|
+
"mode": "BUS",
|
|
69
|
+
"shortName": "30",
|
|
70
|
+
"sortOrder": 2
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"agencyId": "bcd",
|
|
74
|
+
"longName": "Local route",
|
|
75
|
+
"mode": "BUS",
|
|
76
|
+
"shortName": "6",
|
|
77
|
+
"sortOrder": 2
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"agencyId": "bcd",
|
|
81
|
+
"longName": "Intercity Train",
|
|
82
|
+
"mode": "RAIL",
|
|
83
|
+
"shortName": "IC",
|
|
84
|
+
"sortOrder": 2
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"agencyId": "bcd",
|
|
88
|
+
"longName": "Yellow line Subway",
|
|
89
|
+
"mode": "SUBWAY",
|
|
90
|
+
"shortName": "Yellow",
|
|
91
|
+
"sortOrder": 2
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"agencyId": "bcd",
|
|
95
|
+
"longName": "Xpress route C",
|
|
96
|
+
"mode": "BUS",
|
|
97
|
+
"shortName": "30C",
|
|
98
|
+
"sortOrder": 2
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"agencyId": "bcd",
|
|
102
|
+
"longName": "Express route X",
|
|
103
|
+
"mode": "BUS",
|
|
104
|
+
"shortName": "30X"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"agencyId": "abc",
|
|
108
|
+
"agencyName": "Agency 1",
|
|
109
|
+
"longName": "Intercity Train 2",
|
|
110
|
+
"mode": "RAIL",
|
|
111
|
+
"routeId": "1:it2",
|
|
112
|
+
"shortName": "IC",
|
|
113
|
+
"sortOrder": 10
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"agencyId": "abc",
|
|
117
|
+
"agencyName": "Acclaimed agency 1",
|
|
118
|
+
"longName": "Express route X",
|
|
119
|
+
"mode": "BUS",
|
|
120
|
+
"routeId": "2:erx",
|
|
121
|
+
"shortName": "30X",
|
|
122
|
+
"sortOrder": 10
|
|
123
|
+
}
|
|
124
|
+
],
|
|
125
|
+
"otp2Routes": [
|
|
126
|
+
{
|
|
127
|
+
"longName": "Across town",
|
|
128
|
+
"mode": "BUS",
|
|
129
|
+
"shortName": "10",
|
|
130
|
+
"sortOrder": 10
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"longName": "Around town",
|
|
134
|
+
"mode": "BUS",
|
|
135
|
+
"shortName": "20",
|
|
136
|
+
"sortOrder": 2
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"longName": "Around another town",
|
|
140
|
+
"shortName": "3",
|
|
141
|
+
"sortOrder": null,
|
|
142
|
+
"type": 3
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"longName": "Loop route",
|
|
146
|
+
"mode": "BUS",
|
|
147
|
+
"shortName": "2",
|
|
148
|
+
"sortOrder": -999
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"longName": "A-line",
|
|
152
|
+
"mode": "BUS",
|
|
153
|
+
"shortName": "A",
|
|
154
|
+
"sortOrder": -999
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"longName": "B-line",
|
|
158
|
+
"mode": "BUS",
|
|
159
|
+
"shortName": "B"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"longName": "A meandering route",
|
|
163
|
+
"mode": "BUS"
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"longName": "Zig-zagging route",
|
|
167
|
+
"mode": "BUS",
|
|
168
|
+
"shortName": "30",
|
|
169
|
+
"sortOrder": 2
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"longName": "Express route",
|
|
173
|
+
"mode": "BUS",
|
|
174
|
+
"shortName": "30",
|
|
175
|
+
"sortOrder": 2
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"longName": "Variation of express route",
|
|
179
|
+
"mode": "BUS",
|
|
180
|
+
"shortName": "30",
|
|
181
|
+
"sortOrder": 2
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"longName": "Local route",
|
|
185
|
+
"mode": "BUS",
|
|
186
|
+
"shortName": "6",
|
|
187
|
+
"sortOrder": 2
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
"longName": "Intercity Train",
|
|
191
|
+
"mode": "RAIL",
|
|
192
|
+
"shortName": "IC",
|
|
193
|
+
"sortOrder": 2
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
"longName": "Yellow line Subway",
|
|
197
|
+
"mode": "SUBWAY",
|
|
198
|
+
"shortName": "Yellow",
|
|
199
|
+
"sortOrder": 2
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
"longName": "Xpress route C",
|
|
203
|
+
"mode": "BUS",
|
|
204
|
+
"shortName": "30C",
|
|
205
|
+
"sortOrder": 2
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
"longName": "Express route X",
|
|
209
|
+
"mode": "BUS",
|
|
210
|
+
"shortName": "30X",
|
|
211
|
+
"sortOrder": 2
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
"agency": {
|
|
215
|
+
"name": "Agency 1",
|
|
216
|
+
"id": "abc"
|
|
217
|
+
},
|
|
218
|
+
"longName": "Intercity Train 2",
|
|
219
|
+
"mode": "RAIL",
|
|
220
|
+
"routeId": "1:it2",
|
|
221
|
+
"shortName": "IC",
|
|
222
|
+
"sortOrder": 2
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
"agency": {
|
|
226
|
+
"name": "Acclaimed agency 1",
|
|
227
|
+
"id": "abc"
|
|
228
|
+
},
|
|
229
|
+
"longName": "Express route X",
|
|
230
|
+
"mode": "BUS",
|
|
231
|
+
"routeId": "2:erx",
|
|
232
|
+
"shortName": "30X",
|
|
233
|
+
"sortOrder": 2
|
|
234
|
+
}
|
|
235
|
+
]
|
|
107
236
|
}
|
package/esm/time.js
CHANGED
|
@@ -19,6 +19,16 @@ export function toHoursMinutesSeconds(seconds) {
|
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* If a duration is less than 60 seconds, round it to one minute, to avoid a duration
|
|
24
|
+
* of 0 minutes on a leg.
|
|
25
|
+
* @param {number} duration The leg or trip duration in seconds
|
|
26
|
+
* @returns a duration in seconds of at least 60 seconds.
|
|
27
|
+
*/
|
|
28
|
+
export var ensureAtLeastOneMinute = function ensureAtLeastOneMinute(duration) {
|
|
29
|
+
return duration < 60 ? 60 : duration;
|
|
30
|
+
};
|
|
31
|
+
|
|
22
32
|
/**
|
|
23
33
|
* @param {[type]} config the OTP config object found in store
|
|
24
34
|
* @return {string} the config-defined time formatter or HH:mm (24-hr time)
|