@opentripplanner/core-utils 4.8.1-alpha → 4.10.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.
@@ -0,0 +1,310 @@
1
+ import moment from "moment";
2
+
3
+ // Need to avoid cyclic dependency resolution
4
+ /* eslint-disable global-require */
5
+ export function logDeprecationWarning(method, alternative) {
6
+ console.warn(
7
+ `${method ||
8
+ "This method"} is deprecated and will be removed in a future otp-ui release. All language functionality should be handled using react-intl.
9
+ ${
10
+ alternative
11
+ ? `
12
+
13
+ Use ${alternative} instead, which provides a new interface that doesn't return English strings.`
14
+ : ""
15
+ }`
16
+ );
17
+ }
18
+
19
+ // itinerary.js
20
+
21
+ export function getStepDirection(step) {
22
+ logDeprecationWarning("getStepDirection");
23
+
24
+ switch (step.relativeDirection) {
25
+ case "DEPART":
26
+ return `Head ${step.absoluteDirection.toLowerCase()}`;
27
+ case "LEFT":
28
+ return "Left";
29
+ case "HARD_LEFT":
30
+ return "Hard left";
31
+ case "SLIGHTLY_LEFT":
32
+ return "Slight left";
33
+ case "CONTINUE":
34
+ return "Continue";
35
+ case "SLIGHTLY_RIGHT":
36
+ return "Slight right";
37
+ case "RIGHT":
38
+ return "Right";
39
+ case "HARD_RIGHT":
40
+ return "Hard right";
41
+ case "CIRCLE_CLOCKWISE":
42
+ return "Follow circle clockwise";
43
+ case "CIRCLE_COUNTERCLOCKWISE":
44
+ return "Follow circle counterclockwise";
45
+ case "ELEVATOR":
46
+ return "Take elevator";
47
+ case "UTURN_LEFT":
48
+ return "Left U-turn";
49
+ case "UTURN_RIGHT":
50
+ return "Right U-turn";
51
+ default:
52
+ return step.relativeDirection;
53
+ }
54
+ }
55
+
56
+ export function getStepInstructions(step) {
57
+ logDeprecationWarning("getStepInstructions");
58
+
59
+ const conjunction = step.relativeDirection === "ELEVATOR" ? "to" : "on";
60
+ return `${getStepDirection(step)} ${conjunction} ${step.streetName}`;
61
+ }
62
+
63
+ export function getStepStreetName(step) {
64
+ logDeprecationWarning("getStepStreetName");
65
+
66
+ if (step.streetName === "road") return "Unnamed Road";
67
+ if (step.streetName === "path") return "Unnamed Path";
68
+ return step.streetName;
69
+ }
70
+
71
+ export function getLegModeLabel(leg) {
72
+ logDeprecationWarning("getLegModeLabel");
73
+
74
+ switch (leg.mode) {
75
+ case "BICYCLE_RENT":
76
+ return "Biketown";
77
+ case "CAR":
78
+ return leg.hailedCar ? "Ride" : "Drive";
79
+ case "GONDOLA":
80
+ return "Aerial Tram";
81
+ case "TRAM":
82
+ if (leg.routeLongName.toLowerCase().indexOf("streetcar") !== -1)
83
+ return "Streetcar";
84
+ return "Light Rail";
85
+ case "MICROMOBILITY":
86
+ return "Ride";
87
+ default:
88
+ return require("./itinerary").toSentenceCase(leg.mode);
89
+ }
90
+ }
91
+
92
+ /**
93
+ * Returns mode name by checking the vertex type (VertexType class in OTP) for
94
+ * the provided place. NOTE: this is currently only intended for vehicles at
95
+ * the moment (not transit or walking).
96
+ *
97
+ * @param {string} place place from itinerary leg
98
+ */
99
+ export function getModeForPlace(place) {
100
+ logDeprecationWarning("getModeForPlace");
101
+
102
+ switch (place.vertexType) {
103
+ case "CARSHARE":
104
+ return "car";
105
+ case "VEHICLERENTAL":
106
+ return "E-scooter";
107
+ // TODO: Should the type change depending on bike vertex type?
108
+ case "BIKESHARE":
109
+ case "BIKEPARK":
110
+ return "bike";
111
+ // If company offers more than one mode, default to `vehicle` string.
112
+ default:
113
+ return "vehicle";
114
+ }
115
+ }
116
+
117
+ export function getPlaceName(place, companies) {
118
+ logDeprecationWarning("getPlaceName");
119
+
120
+ // If address is provided (i.e. for carshare station, use it)
121
+ if (place.address) return place.address.split(",")[0];
122
+ if (place.networks && place.vertexType === "VEHICLERENTAL") {
123
+ // For vehicle rental pick up, do not use the place name. Rather, use
124
+ // company name + vehicle type (e.g., SPIN E-scooter). Place name is often just
125
+ // a UUID that has no relevance to the actual vehicle. For bikeshare, however,
126
+ // there are often hubs or bikes that have relevant names to the user.
127
+ const company = require("./itinerary").getCompanyForNetwork(
128
+ place.networks[0],
129
+ companies
130
+ );
131
+ if (company) {
132
+ return `${company.label} ${getModeForPlace(place)}`;
133
+ }
134
+ }
135
+ // Default to place name
136
+ return place.name;
137
+ }
138
+
139
+ /**
140
+ * For a given fare component (either total fare or component parts), returns
141
+ * an object with string formatters and the fare value (in cents).
142
+ */
143
+ export function getTransitFare(fareComponent) {
144
+ logDeprecationWarning("getTransitFare", "the fare object and getTncFare");
145
+
146
+ // Default values (if fare component is not valid).
147
+ let digits = 2;
148
+ let transitFare = 0;
149
+ let symbol = "$";
150
+ let currencyCode = "USD";
151
+ if (fareComponent) {
152
+ // Assign values without declaration. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#assignment_without_declaration
153
+ ({
154
+ currencyCode,
155
+ defaultFractionDigits: digits,
156
+ symbol
157
+ } = fareComponent.currency);
158
+ transitFare = fareComponent.cents;
159
+ }
160
+ // For cents to string conversion, use digits from fare component.
161
+ const centsToString = cents => {
162
+ const dollars = (cents / 10 ** digits).toFixed(digits);
163
+ return `${symbol}${dollars}`;
164
+ };
165
+ // For dollars to string conversion, assume we're rounding to two digits.
166
+ const dollarsToString = dollars => `${symbol}${dollars.toFixed(2)}`;
167
+ return {
168
+ centsToString,
169
+ currencyCode,
170
+ dollarsToString,
171
+ transitFare
172
+ };
173
+ }
174
+
175
+ /**
176
+ * For an itinerary, calculates the transit/TNC fares and returns an object with
177
+ * these values, currency info, as well as string formatters.
178
+ * It is assumed that the same currency is used for transit and TNC legs.
179
+ *
180
+ * multiple being set to true will change the output behavior:
181
+ * - dollarsToString and centsToString will be returned as part of each fare
182
+ * - currencyCode will be returned separately for each fare
183
+ * - tnc currency code will be returned separately
184
+ * - each fare type will be returned separately within a new transitFares property
185
+ *
186
+ * FIXME: a new approach to fare calculation must be found:
187
+ * the current approach is not sustainable, as centsToString and DollarsToString
188
+ * must be replaced by i18n anyway.
189
+ *
190
+ * However, the current behavior should ideally be kept to avoid a breaking change.
191
+ * The "multiple" mode is helpful, but only prevents tnc fare calculation from being duplicated.
192
+ * This method could be split out into a new one, along with tnc fare calculation.
193
+ * If this is done, the individual fare calculation should also be modified to support
194
+ * a default fare not being called "regular". However, this again would be a breaking change.
195
+ * This breaking change is avoided by adding the "multiple" parameter.
196
+ *
197
+ * When centsToString and dollarsToString are removed, this method should be split into
198
+ * individual fare calculation on a variable fare key, fare calculation of an entire leg,
199
+ * which will get fares for every fare key in the leg, and a method to calculate the fare of
200
+ * a tnc ride within the leg. This will make typescripting easier, as the types will be cleaner.
201
+ */
202
+ export function calculateFares(itinerary, multiple = false) {
203
+ logDeprecationWarning("calculateFares", "the fare object and getTncFare");
204
+
205
+ // Process any TNC fares
206
+ let minTNCFare = 0;
207
+ let maxTNCFare = 0;
208
+ let tncCurrencyCode;
209
+ itinerary.legs.forEach(leg => {
210
+ if (leg.mode === "CAR" && leg.hailedCar && leg.tncData) {
211
+ const { currency, maxCost, minCost } = leg.tncData;
212
+ // TODO: Support non-USD
213
+ minTNCFare += minCost;
214
+ maxTNCFare += maxCost;
215
+ tncCurrencyCode = currency;
216
+ }
217
+ });
218
+
219
+ if (multiple) {
220
+ // Return object of fares
221
+ const transitFares = {};
222
+ if (itinerary && itinerary.fare && itinerary.fare.fare) {
223
+ Object.keys(itinerary.fare.fare).forEach(fareKey => {
224
+ const fareComponent = itinerary.fare.fare[fareKey];
225
+ transitFares[fareKey] = getTransitFare(fareComponent);
226
+ });
227
+ }
228
+
229
+ return {
230
+ maxTNCFare,
231
+ minTNCFare,
232
+ tncCurrencyCode,
233
+ transitFares
234
+ };
235
+ }
236
+
237
+ // Extract fare total from itinerary fares.
238
+ const fareComponent =
239
+ itinerary.fare && itinerary.fare.fare && itinerary.fare.fare.regular;
240
+ // Get string formatters and itinerary fare.
241
+ const {
242
+ centsToString,
243
+ currencyCode: transitCurrencyCode,
244
+ dollarsToString,
245
+ transitFare
246
+ } = getTransitFare(fareComponent);
247
+
248
+ return {
249
+ centsToString,
250
+ currencyCode: transitCurrencyCode || tncCurrencyCode,
251
+ dollarsToString,
252
+ maxTNCFare,
253
+ minTNCFare,
254
+ transitFare
255
+ };
256
+ }
257
+
258
+ // map.js
259
+
260
+ export function latlngToString(latlng) {
261
+ logDeprecationWarning("latlngToString", "the latlng object");
262
+
263
+ return (
264
+ latlng &&
265
+ `${latlng.lat.toFixed(5)}, ${(latlng.lng || latlng.lon).toFixed(5)}`
266
+ );
267
+ }
268
+
269
+ export function coordsToString(coords) {
270
+ logDeprecationWarning("coordsToString", "the coords object");
271
+
272
+ return coords.length && coords.map(c => (+c).toFixed(5)).join(", ");
273
+ }
274
+
275
+ export function getDetailText(location) {
276
+ let detailText;
277
+ if (location.type === "home" || location.type === "work") {
278
+ detailText = location.name;
279
+ }
280
+ if (location.type === "stop") {
281
+ detailText = location.id;
282
+ } else if (location.type === "recent" && location.timestamp) {
283
+ detailText = moment(location.timestamp).fromNow();
284
+ }
285
+ return detailText;
286
+ }
287
+
288
+ // query.js
289
+
290
+ export function summarizeQuery(query, locations = []) {
291
+ logDeprecationWarning("summarizeQuery");
292
+
293
+ function findLocationType(
294
+ location,
295
+ ls = [],
296
+ types = ["home", "work", "suggested"]
297
+ ) {
298
+ const match = ls.find(l => require("./map").matchLatLon(l, location));
299
+ return match && types.indexOf(match.type) !== -1 ? match.type : null;
300
+ }
301
+
302
+ const from =
303
+ findLocationType(query.from, locations) || query.from.name.split(",")[0];
304
+ const to =
305
+ findLocationType(query.to, locations) || query.to.name.split(",")[0];
306
+ const mode = require("./itinerary").hasTransit(query.mode)
307
+ ? "Transit"
308
+ : require("./itinerary").toSentenceCase(query.mode);
309
+ return `${mode} from ${from} to ${to}`;
310
+ }
package/src/itinerary.js CHANGED
@@ -1,6 +1,28 @@
1
1
  import polyline from "@mapbox/polyline";
2
2
  import turfAlong from "@turf/along";
3
3
 
4
+ import {
5
+ calculateFares,
6
+ getLegModeLabel,
7
+ getModeForPlace,
8
+ getPlaceName,
9
+ getStepDirection,
10
+ getStepInstructions,
11
+ getStepStreetName,
12
+ getTransitFare
13
+ } from "./deprecated";
14
+
15
+ export {
16
+ calculateFares,
17
+ getLegModeLabel,
18
+ getModeForPlace,
19
+ getPlaceName,
20
+ getStepDirection,
21
+ getStepInstructions,
22
+ getStepStreetName,
23
+ getTransitFare
24
+ };
25
+
4
26
  // All OTP transit modes
5
27
  export const transitModes = [
6
28
  "TRAM",
@@ -159,51 +181,6 @@ export function getMapColor(mode) {
159
181
  return "#aaa";
160
182
  }
161
183
 
162
- // TODO: temporary code; handle via migrated OTP i18n language table
163
- export function getStepDirection(step) {
164
- switch (step.relativeDirection) {
165
- case "DEPART":
166
- return `Head ${step.absoluteDirection.toLowerCase()}`;
167
- case "LEFT":
168
- return "Left";
169
- case "HARD_LEFT":
170
- return "Hard left";
171
- case "SLIGHTLY_LEFT":
172
- return "Slight left";
173
- case "CONTINUE":
174
- return "Continue";
175
- case "SLIGHTLY_RIGHT":
176
- return "Slight right";
177
- case "RIGHT":
178
- return "Right";
179
- case "HARD_RIGHT":
180
- return "Hard right";
181
- case "CIRCLE_CLOCKWISE":
182
- return "Follow circle clockwise";
183
- case "CIRCLE_COUNTERCLOCKWISE":
184
- return "Follow circle counterclockwise";
185
- case "ELEVATOR":
186
- return "Take elevator";
187
- case "UTURN_LEFT":
188
- return "Left U-turn";
189
- case "UTURN_RIGHT":
190
- return "Right U-turn";
191
- default:
192
- return step.relativeDirection;
193
- }
194
- }
195
-
196
- export function getStepInstructions(step) {
197
- const conjunction = step.relativeDirection === "ELEVATOR" ? "to" : "on";
198
- return `${getStepDirection(step)} ${conjunction} ${step.streetName}`;
199
- }
200
-
201
- export function getStepStreetName(step) {
202
- if (step.streetName === "road") return "Unnamed Road";
203
- if (step.streetName === "path") return "Unnamed Path";
204
- return step.streetName;
205
- }
206
-
207
184
  export function toSentenceCase(str) {
208
185
  if (str == null) {
209
186
  return "";
@@ -233,25 +210,6 @@ export function getCompanyFromLeg(leg) {
233
210
  return null;
234
211
  }
235
212
 
236
- export function getLegModeLabel(leg) {
237
- switch (leg.mode) {
238
- case "BICYCLE_RENT":
239
- return "Biketown";
240
- case "CAR":
241
- return leg.hailedCar ? "Ride" : "Drive";
242
- case "GONDOLA":
243
- return "Aerial Tram";
244
- case "TRAM":
245
- if (leg.routeLongName.toLowerCase().indexOf("streetcar") !== -1)
246
- return "Streetcar";
247
- return "Light Rail";
248
- case "MICROMOBILITY":
249
- return "Ride";
250
- default:
251
- return toSentenceCase(leg.mode);
252
- }
253
- }
254
-
255
213
  export function getItineraryBounds(itinerary) {
256
214
  let coords = [];
257
215
  itinerary.legs.forEach(leg => {
@@ -400,7 +358,7 @@ export function getTextWidth(text, font = "22px Arial") {
400
358
  * Get the configured company object for the given network string if the company
401
359
  * has been defined in the provided companies array config.
402
360
  */
403
- function getCompanyForNetwork(networkString, companies = []) {
361
+ export function getCompanyForNetwork(networkString, companies = []) {
404
362
  const company = companies.find(co => co.id === networkString);
405
363
  if (!company) {
406
364
  console.warn(
@@ -426,47 +384,6 @@ export function getCompaniesLabelFromNetworks(networks, companies = []) {
426
384
  .join("/");
427
385
  }
428
386
 
429
- /**
430
- * Returns mode name by checking the vertex type (VertexType class in OTP) for
431
- * the provided place. NOTE: this is currently only intended for vehicles at
432
- * the moment (not transit or walking).
433
- *
434
- * TODO: I18N
435
- * @param {string} place place from itinerary leg
436
- */
437
- export function getModeForPlace(place) {
438
- switch (place.vertexType) {
439
- case "CARSHARE":
440
- return "car";
441
- case "VEHICLERENTAL":
442
- return "E-scooter";
443
- // TODO: Should the type change depending on bike vertex type?
444
- case "BIKESHARE":
445
- case "BIKEPARK":
446
- return "bike";
447
- // If company offers more than one mode, default to `vehicle` string.
448
- default:
449
- return "vehicle";
450
- }
451
- }
452
-
453
- export function getPlaceName(place, companies) {
454
- // If address is provided (i.e. for carshare station, use it)
455
- if (place.address) return place.address.split(",")[0];
456
- if (place.networks && place.vertexType === "VEHICLERENTAL") {
457
- // For vehicle rental pick up, do not use the place name. Rather, use
458
- // company name + vehicle type (e.g., SPIN E-scooter). Place name is often just
459
- // a UUID that has no relevance to the actual vehicle. For bikeshare, however,
460
- // there are often hubs or bikes that have relevant names to the user.
461
- const company = getCompanyForNetwork(place.networks[0], companies);
462
- if (company) {
463
- return `${company.label} ${getModeForPlace(place)}`;
464
- }
465
- }
466
- // Default to place name
467
- return place.name;
468
- }
469
-
470
387
  export function getTNCLocation(leg, type) {
471
388
  const location = leg[type];
472
389
  return `${location.lat.toFixed(5)},${location.lon.toFixed(5)}`;
@@ -488,121 +405,6 @@ export function calculatePhysicalActivity(itinerary) {
488
405
  };
489
406
  }
490
407
 
491
- /**
492
- * For a given fare component (either total fare or component parts), returns
493
- * an object with string formatters and the fare value (in cents).
494
- */
495
- export function getTransitFare(fareComponent) {
496
- // Default values (if fare component is not valid).
497
- let digits = 2;
498
- let transitFare = 0;
499
- let symbol = "$";
500
- let currencyCode = "USD";
501
- if (fareComponent) {
502
- // Assign values without declaration. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#assignment_without_declaration
503
- ({
504
- currencyCode,
505
- defaultFractionDigits: digits,
506
- symbol
507
- } = fareComponent.currency);
508
- transitFare = fareComponent.cents;
509
- }
510
- // For cents to string conversion, use digits from fare component.
511
- const centsToString = cents => {
512
- const dollars = (cents / 10 ** digits).toFixed(digits);
513
- return `${symbol}${dollars}`;
514
- };
515
- // For dollars to string conversion, assume we're rounding to two digits.
516
- const dollarsToString = dollars => `${symbol}${dollars.toFixed(2)}`;
517
- return {
518
- centsToString,
519
- currencyCode,
520
- dollarsToString,
521
- transitFare
522
- };
523
- }
524
-
525
- /**
526
- * For an itinerary, calculates the transit/TNC fares and returns an object with
527
- * these values, currency info, as well as string formatters.
528
- * It is assumed that the same currency is used for transit and TNC legs.
529
- *
530
- * multiple being set to true will change the output behavior:
531
- * - dollarsToString and centsToString will be returned as part of each fare
532
- * - currencyCode will be returned separately for each fare
533
- * - tnc currency code will be returned separately
534
- * - each fare type will be returned separately within a new transitFares property
535
- *
536
- * FIXME: a new approach to fare calculation must be found:
537
- * the current approach is not sustainable, as centsToString and DollarsToString
538
- * must be replaced by i18n anyway.
539
- *
540
- * However, the current behavior should ideally be kept to avoid a breaking change.
541
- * The "multiple" mode is helpful, but only prevents tnc fare calculation from being duplicated.
542
- * This method could be split out into a new one, along with tnc fare calculation.
543
- * If this is done, the individual fare calculation should also be modified to support
544
- * a default fare not being called "regular". However, this again would be a breaking change.
545
- * This breaking change is avoided by adding the "multiple" parameter.
546
- *
547
- * When centsToString and dollarsToString are removed, this method should be split into
548
- * individual fare calculation on a variable fare key, fare calculation of an entire leg,
549
- * which will get fares for every fare key in the leg, and a method to calculate the fare of
550
- * a tnc ride within the leg. This will make typescripting easier, as the types will be cleaner.
551
- */
552
- export function calculateFares(itinerary, multiple = false) {
553
- // Process any TNC fares
554
- let minTNCFare = 0;
555
- let maxTNCFare = 0;
556
- let tncCurrencyCode;
557
- itinerary.legs.forEach(leg => {
558
- if (leg.mode === "CAR" && leg.hailedCar && leg.tncData) {
559
- const { currency, maxCost, minCost } = leg.tncData;
560
- // TODO: Support non-USD
561
- minTNCFare += minCost;
562
- maxTNCFare += maxCost;
563
- tncCurrencyCode = currency;
564
- }
565
- });
566
-
567
- if (multiple) {
568
- // Return object of fares
569
- const transitFares = {};
570
- if (itinerary && itinerary.fare && itinerary.fare.fare) {
571
- Object.keys(itinerary.fare.fare).forEach(fareKey => {
572
- const fareComponent = itinerary.fare.fare[fareKey];
573
- transitFares[fareKey] = getTransitFare(fareComponent);
574
- });
575
- }
576
-
577
- return {
578
- maxTNCFare,
579
- minTNCFare,
580
- tncCurrencyCode,
581
- transitFares
582
- };
583
- }
584
-
585
- // Extract fare total from itinerary fares.
586
- const fareComponent =
587
- itinerary.fare && itinerary.fare.fare && itinerary.fare.fare.regular;
588
- // Get string formatters and itinerary fare.
589
- const {
590
- centsToString,
591
- currencyCode: transitCurrencyCode,
592
- dollarsToString,
593
- transitFare
594
- } = getTransitFare(fareComponent);
595
-
596
- return {
597
- centsToString,
598
- currencyCode: transitCurrencyCode || tncCurrencyCode,
599
- dollarsToString,
600
- maxTNCFare,
601
- minTNCFare,
602
- transitFare
603
- };
604
- }
605
-
606
408
  export function getTimeZoneOffset(itinerary) {
607
409
  if (!itinerary.legs || !itinerary.legs.length) return 0;
608
410
 
@@ -616,3 +418,13 @@ export function getTimeZoneOffset(itinerary) {
616
418
  (new Date().getTimezoneOffset() + dstOffset) * 60000
617
419
  );
618
420
  }
421
+
422
+ export function calculateTncFares(itinerary) {
423
+ // TODO: don't rely on deprecated methods!
424
+ // At the moment this is safe as none of these exported variables contain strings
425
+ const { maxTNCFare, minTNCFare, tncCurrencyCode } = calculateFares(
426
+ itinerary,
427
+ true
428
+ );
429
+ return { maxTNCFare, minTNCFare, tncCurrencyCode };
430
+ }
package/src/map.js CHANGED
@@ -1,17 +1,13 @@
1
- import moment from "moment";
2
-
3
1
  import { getPlaceName, isTransit, isFlex, toSentenceCase } from "./itinerary";
4
2
 
5
- export function latlngToString(latlng) {
6
- return (
7
- latlng &&
8
- `${latlng.lat.toFixed(5)}, ${(latlng.lng || latlng.lon).toFixed(5)}`
9
- );
10
- }
3
+ import {
4
+ coordsToString,
5
+ getDetailText,
6
+ latlngToString,
7
+ logDeprecationWarning
8
+ } from "./deprecated";
11
9
 
12
- export function coordsToString(coords) {
13
- return coords.length && coords.map(c => (+c).toFixed(5)).join(", ");
14
- }
10
+ export { coordsToString, getDetailText, latlngToString };
15
11
 
16
12
  export function currentPositionToLocation(currentPosition) {
17
13
  if (currentPosition.error || !currentPosition.coords) {
@@ -23,7 +19,6 @@ export function currentPositionToLocation(currentPosition) {
23
19
  return {
24
20
  lat: currentPosition.coords.latitude,
25
21
  lon: currentPosition.coords.longitude,
26
- name: "(Current Location)",
27
22
  category: "CURRENT_LOCATION"
28
23
  };
29
24
  }
@@ -34,26 +29,16 @@ export function stringToCoords(str) {
34
29
 
35
30
  export function constructLocation(latlng) {
36
31
  return {
37
- name: latlngToString(latlng),
38
32
  lat: latlng.lat,
39
33
  lon: latlng.lng
40
34
  };
41
35
  }
42
36
 
43
- export function getDetailText(location) {
44
- let detailText;
45
- if (location.type === "home" || location.type === "work") {
46
- detailText = location.name;
47
- }
48
- if (location.type === "stop") {
49
- detailText = location.id;
50
- } else if (location.type === "recent" && location.timestamp) {
51
- detailText = moment(location.timestamp).fromNow();
37
+ export function formatStoredPlaceName(location, withDetails = true) {
38
+ if (withDetails) {
39
+ logDeprecationWarning("the formatStoredPlaceName withDetails parameter");
52
40
  }
53
- return detailText;
54
- }
55
41
 
56
- export function formatStoredPlaceName(location, withDetails = true) {
57
42
  let displayName =
58
43
  location.type === "home" || location.type === "work"
59
44
  ? toSentenceCase(location.type)
@@ -99,6 +84,7 @@ export function itineraryToTransitive(
99
84
 
100
85
  const journey = {
101
86
  journey_id: "itin",
87
+ // This string is not shown in the UI
102
88
  journey_name: "Iterarary-derived Journey",
103
89
  segments: []
104
90
  };
@@ -180,6 +166,7 @@ export function itineraryToTransitive(
180
166
  });
181
167
  tdata.places.push({
182
168
  place_id: toPlaceId,
169
+ // This string is not shown in the UI
183
170
  place_name: getPlaceName(leg.to, companies),
184
171
  place_lat: leg.to.lat,
185
172
  place_lon: leg.to.lon
@@ -205,6 +192,7 @@ export function itineraryToTransitive(
205
192
  const ptnId = `ptn_${patternId}`;
206
193
  const pattern = {
207
194
  pattern_id: ptnId,
195
+ // This string is not shown in the UI
208
196
  pattern_name: `Pattern ${patternId}`,
209
197
  route_id: leg.routeId,
210
198
  stops: []
package/src/messages.js CHANGED
@@ -1,3 +1,5 @@
1
+ // This entire file can be removed once deprecation goes forward
2
+ import { logDeprecationWarning } from "./deprecated";
1
3
  /**
2
4
  * Takes component's default props messages and its instance props messages and
3
5
  * returns the merged messages. The returned object will ensure that the default
@@ -7,6 +9,8 @@
7
9
  */
8
10
  /* eslint-disable import/prefer-default-export */
9
11
  export function mergeMessages(defaultPropsMessages, propsMessages) {
12
+ logDeprecationWarning("mergeMessages");
13
+
10
14
  const defaultMessages = defaultPropsMessages || {};
11
15
  const instanceMessages = propsMessages || {};
12
16
  return {