@opentripplanner/core-utils 7.0.0-alpha.3 → 7.0.0-alpha.4

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/map.js CHANGED
@@ -1,15 +1,3 @@
1
- import { toSentenceCase } from "./itinerary";
2
- /*
3
- import {
4
- // coordsToString,
5
- // getDetailText //,
6
- // latlngToString,
7
- // logDeprecationWarning
8
- } from "./deprecated";
9
-
10
- export { coordsToString, getDetailText , latlngToString };
11
- */
12
-
13
1
  export function currentPositionToLocation(currentPosition) {
14
2
  if (currentPosition.error || !currentPosition.coords) {
15
3
  console.warn("Cannot construct location from current position due to geolocation error or missing coordinates.");
@@ -21,8 +9,8 @@ export function currentPositionToLocation(currentPosition) {
21
9
  lon: currentPosition.coords.longitude,
22
10
  category: "CURRENT_LOCATION"
23
11
  };
24
- } // TRICKY: It is used in query.js and in the context of
25
- // otp-rr actions where the intl context is not available.
12
+ } // TRICKY: This method is used in query.js and in the context of
13
+ // otp-rr actions where the intl context is not available/does not apply.
26
14
 
27
15
  export function coordsToString(coords) {
28
16
  return coords.length && coords.map(function (c) {
@@ -40,9 +28,6 @@ export function constructLocation(latlng) {
40
28
  lon: latlng.lng
41
29
  };
42
30
  }
43
- export function formatStoredPlaceName(location) {
44
- return location.type === "home" || location.type === "work" ? toSentenceCase(location.type) : location.name;
45
- }
46
31
  export function matchLatLon(location1, location2) {
47
32
  if (!location1 || !location2) return location1 === location2;
48
33
  return location1.lat === location2.lat && location1.lon === location2.lon;
package/esm/map.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/map.ts"],"names":["toSentenceCase","currentPositionToLocation","currentPosition","error","coords","console","warn","lat","latitude","lon","longitude","category","coordsToString","length","map","c","toFixed","join","stringToCoords","str","split","constructLocation","latlng","lng","formatStoredPlaceName","location","type","name","matchLatLon","location1","location2","isBikeshareStation","place","place_id","lastIndexOf","isEScooterStation","isCarWalkTransition","isValidLat","Number","isFinite","is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IAGAF,UAAU,CAACE,GAAG,CAAC,CAAD,CAAJ,CAJZ;AAMD","sourcesContent":["import { LatLngArray, Location, UserPosition } from \"@opentripplanner/types\";\nimport { toSentenceCase } from \"./itinerary\";\n\n/*\nimport {\n // coordsToString,\n // getDetailText //,\n // latlngToString,\n // logDeprecationWarning\n} from \"./deprecated\";\n\nexport { coordsToString, getDetailText , latlngToString };\n*/\n\nexport function currentPositionToLocation(\n currentPosition: UserPosition\n): Location {\n if (currentPosition.error || !currentPosition.coords) {\n console.warn(\n \"Cannot construct location from current position due to geolocation error or missing coordinates.\"\n );\n return null;\n }\n return {\n lat: currentPosition.coords.latitude,\n lon: currentPosition.coords.longitude,\n category: \"CURRENT_LOCATION\"\n };\n}\n\n// TRICKY: It is used in query.js and in the context of\n// otp-rr actions where the intl context is not available.\nexport function coordsToString(coords: number[]): string {\n return coords.length && coords.map(c => (+c).toFixed(5)).join(\", \");\n}\n\nexport function stringToCoords(str: string): number[] {\n return (str && str.split(\",\").map(c => +c)) || [];\n}\n\nexport function constructLocation(latlng: {\n lat: number;\n lng: number;\n}): Location {\n return {\n lat: latlng.lat,\n lon: latlng.lng\n };\n}\n\nexport function formatStoredPlaceName(location: Location): string {\n return location.type === \"home\" || location.type === \"work\"\n ? toSentenceCase(location.type)\n : location.name;\n}\n\nexport function matchLatLon(location1: Location, location2: Location): boolean {\n if (!location1 || !location2) return location1 === location2;\n return location1.lat === location2.lat && location1.lon === location2.lon;\n}\n\ntype TransitivePlaceRaw = {\n place_id: string;\n};\nexport function isBikeshareStation(place: TransitivePlaceRaw): boolean {\n return place.place_id.lastIndexOf(\"bicycle_rent_station\") !== -1;\n}\n\nexport function isEScooterStation(place: TransitivePlaceRaw): boolean {\n return place.place_id.lastIndexOf(\"escooter_rent_station\") !== -1;\n}\n\nexport function isCarWalkTransition(place: TransitivePlaceRaw): boolean {\n return place.place_id.lastIndexOf(\"itin_car_\") !== -1;\n}\n\nexport function isValidLat(lat: number): boolean {\n return Number.isFinite(lat) && lat >= -90 && lat <= 90;\n}\n\nexport function isValidLng(lng: number): boolean {\n return Number.isFinite(lng) && lng >= -180 && lng <= 180;\n}\n\nexport function isValidLatLng(arr: LatLngArray): boolean {\n return (\n Array.isArray(arr) &&\n arr.length === 2 &&\n isValidLat(arr[0]) &&\n isValidLng(arr[1])\n );\n}\n"],"file":"map.js"}
1
+ {"version":3,"sources":["../src/map.ts"],"names":["currentPositionToLocation","currentPosition","error","coords","console","warn","lat","latitude","lon","longitude","category","coordsToString","length","map","c","toFixed","join","stringToCoords","str","split","constructLocation","latlng","lng","matchLatLon","location1","location2","isBikeshareStation","place","place_id","lastIndexOf","isEScooterStation","isCarWalkTransition","isValidLat","Number","isFinite","isValidLng","isValidLatLng","arr","Array","isArray"],"mappings":"AAEA,OAAO,SAASA,yBAAT,CACLC,eADK,EAEK;AACV,MAAIA,eAAe,CAACC,KAAhB,IAAyB,CAACD,eAAe,CAACE,MAA9C,EAAsD;AACpDC,IAAAA,OAAO,CAACC,IAAR,CACE,kGADF;AAGA,WAAO,IAAP;AACD;;AACD,SAAO;AACLC,IAAAA,GAAG,EAAEL,eAAe,CAACE,MAAhB,CAAuBI,QADvB;AAELC,IAAAA,GAAG,EAAEP,eAAe,CAACE,MAAhB,CAAuBM,SAFvB;AAGLC,IAAAA,QAAQ,EAAE;AAHL,GAAP;AAKD,C,CAED;AACA;;AACA,OAAO,SAASC,cAAT,CAAwBR,MAAxB,EAAkD;AACvD,SAAOA,MAAM,CAACS,MAAP,IAAiBT,MAAM,CAACU,GAAP,CAAW,UAAAC,CAAC;AAAA,WAAI,CAAC,CAACA,CAAF,EAAKC,OAAL,CAAa,CAAb,CAAJ;AAAA,GAAZ,EAAiCC,IAAjC,CAAsC,IAAtC,CAAxB;AACD;AAED,OAAO,SAASC,cAAT,CAAwBC,GAAxB,EAA+C;AACpD,SAAQA,GAAG,IAAIA,GAAG,CAACC,KAAJ,CAAU,GAAV,EAAeN,GAAf,CAAmB,UAAAC,CAAC;AAAA,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vB,EAAkD;AACvD,SACEC,KAAK,CAACC,OAAN,CAAcF,GAAd,KACAA,GAAG,CAACzB,MAAJ,KAAe,CADf,IAEAoB,UAAU,CAACK,GAAG,CAAC,CAAD,CAAJ,CAFV,IAGAF,UAAU,CAACE,GAAG,CAAC,CAAD,CAAJ,CAJZ;AAMD","sourcesContent":["import { LatLngArray, Location, UserPosition } from \"@opentripplanner/types\";\n\nexport function currentPositionToLocation(\n currentPosition: UserPosition\n): Location {\n if (currentPosition.error || !currentPosition.coords) {\n console.warn(\n \"Cannot construct location from current position due to geolocation error or missing coordinates.\"\n );\n return null;\n }\n return {\n lat: currentPosition.coords.latitude,\n lon: currentPosition.coords.longitude,\n category: \"CURRENT_LOCATION\"\n };\n}\n\n// TRICKY: This method is used in query.js and in the context of\n// otp-rr actions where the intl context is not available/does not apply.\nexport function coordsToString(coords: number[]): string {\n return coords.length && coords.map(c => (+c).toFixed(5)).join(\", \");\n}\n\nexport function stringToCoords(str: string): number[] {\n return (str && str.split(\",\").map(c => +c)) || [];\n}\n\nexport function constructLocation(latlng: {\n lat: number;\n lng: number;\n}): Location {\n return {\n lat: latlng.lat,\n lon: latlng.lng\n };\n}\n\nexport function matchLatLon(location1: Location, location2: Location): boolean {\n if (!location1 || !location2) return location1 === location2;\n return location1.lat === location2.lat && location1.lon === location2.lon;\n}\n\ntype TransitivePlaceRaw = {\n place_id: string;\n};\nexport function isBikeshareStation(place: TransitivePlaceRaw): boolean {\n return place.place_id.lastIndexOf(\"bicycle_rent_station\") !== -1;\n}\n\nexport function isEScooterStation(place: TransitivePlaceRaw): boolean {\n return place.place_id.lastIndexOf(\"escooter_rent_station\") !== -1;\n}\n\nexport function isCarWalkTransition(place: TransitivePlaceRaw): boolean {\n return place.place_id.lastIndexOf(\"itin_car_\") !== -1;\n}\n\nexport function isValidLat(lat: number): boolean {\n return Number.isFinite(lat) && lat >= -90 && lat <= 90;\n}\n\nexport function isValidLng(lng: number): boolean {\n return Number.isFinite(lng) && lng >= -180 && lng <= 180;\n}\n\nexport function isValidLatLng(arr: LatLngArray): boolean {\n return (\n Array.isArray(arr) &&\n arr.length === 2 &&\n isValidLat(arr[0]) &&\n isValidLng(arr[1])\n );\n}\n"],"file":"map.js"}
package/lib/map.d.ts CHANGED
@@ -6,7 +6,6 @@ export declare function constructLocation(latlng: {
6
6
  lat: number;
7
7
  lng: number;
8
8
  }): Location;
9
- export declare function formatStoredPlaceName(location: Location): string;
10
9
  export declare function matchLatLon(location1: Location, location2: Location): boolean;
11
10
  declare type TransitivePlaceRaw = {
12
11
  place_id: string;
package/lib/map.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../src/map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAc7E,wBAAgB,yBAAyB,CACvC,eAAe,EAAE,YAAY,GAC5B,QAAQ,CAYV;AAID,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAEvD;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,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAIhE;AAED,wBAAgB,WAAW,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,GAAG,OAAO,CAG7E;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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AAE,WAAW,GAAG,OAAO,CAOvD"}
package/lib/map.js CHANGED
@@ -7,7 +7,6 @@ exports.currentPositionToLocation = currentPositionToLocation;
7
7
  exports.coordsToString = coordsToString;
8
8
  exports.stringToCoords = stringToCoords;
9
9
  exports.constructLocation = constructLocation;
10
- exports.formatStoredPlaceName = formatStoredPlaceName;
11
10
  exports.matchLatLon = matchLatLon;
12
11
  exports.isBikeshareStation = isBikeshareStation;
13
12
  exports.isEScooterStation = isEScooterStation;
@@ -16,18 +15,6 @@ exports.isValidLat = isValidLat;
16
15
  exports.isValidLng = isValidLng;
17
16
  exports.isValidLatLng = isValidLatLng;
18
17
 
19
- var _itinerary = require("./itinerary");
20
-
21
- /*
22
- import {
23
- // coordsToString,
24
- // getDetailText //,
25
- // latlngToString,
26
- // logDeprecationWarning
27
- } from "./deprecated";
28
-
29
- export { coordsToString, getDetailText , latlngToString };
30
- */
31
18
  function currentPositionToLocation(currentPosition) {
32
19
  if (currentPosition.error || !currentPosition.coords) {
33
20
  console.warn("Cannot construct location from current position due to geolocation error or missing coordinates.");
@@ -39,8 +26,8 @@ function currentPositionToLocation(currentPosition) {
39
26
  lon: currentPosition.coords.longitude,
40
27
  category: "CURRENT_LOCATION"
41
28
  };
42
- } // TRICKY: It is used in query.js and in the context of
43
- // otp-rr actions where the intl context is not available.
29
+ } // TRICKY: This method is used in query.js and in the context of
30
+ // otp-rr actions where the intl context is not available/does not apply.
44
31
 
45
32
 
46
33
  function coordsToString(coords) {
@@ -58,10 +45,6 @@ function constructLocation(latlng) {
58
45
  };
59
46
  }
60
47
 
61
- function formatStoredPlaceName(location) {
62
- return location.type === "home" || location.type === "work" ? (0, _itinerary.toSentenceCase)(location.type) : location.name;
63
- }
64
-
65
48
  function matchLatLon(location1, location2) {
66
49
  if (!location1 || !location2) return location1 === location2;
67
50
  return location1.lat === location2.lat && location1.lon === location2.lon;
package/lib/map.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/map.ts"],"names":["currentPositionToLocation","currentPosition","error","coords","console","warn","lat","latitude","lon","longitude","category","coordsToString","length","map","c","toFixed","join","stringToCoords","str","split","constructLocation","latlng","lng","formatStoredPlaceName","location","type","name","matchLatLon","location1","location2","isBikeshareStation","place","place_id","lastIndexOf","isEScooterStation","isCarWalkTransition","isValidLat","Number","isFinite","isValidLng","isValidLatLng","arr","Array","isArray"],"mappings":";;;;;;;;;;;;;;;;;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEO,SAASA,yBAAT,CACLC,eADK,EAEK;AACV,MAAIA,eAAe,CAACC,KAAhB,IAAyB,CAACD,eAAe,CAACE,MAA9C,EAAsD;AACpDC,IAAAA,OAAO,CAACC,IAAR,CACE,kGADF;AAGA,WAAO,IAAP;AACD;;AACD,SAAO;AACLC,IAAAA,GAAG,EAAEL,eAAe,CAACE,MAAhB,CAAuBI,QADvB;AAELC,IAAAA,GAAG,EAAEP,eAAe,CAACE,MAAhB,CAAuBM,SAFvB;AAGLC,IAAAA,QAAQ,EAAE;AAHL,GAAP;AAKD,C,CAED;AACA;;;AACO,SAASC,cAAT,CAAwBR,MAAxB,EAAkD;AACvD,SAAOA,MAAM,CAACS,MAAP,IAAiBT,MAAM,CAACU,GAAP,CAAWC,CAAC,IAAI,CAAC,CAACA,CAAF,EAAKC,OAAL,CAAa,CAAb,CAAhB,EAAiCC,IAAjC,CAAsC,IAAtC,CAAxB;AACD;;AAEM,SAASC,cAAT,CAAwBC,GAAxB,EAA+C;AACpD,SAAQA,GAAG,IAAIA,GAAG,CAACC,KAAJ,CAAU,GAAV,EAAeN,GAAf,CAAmBC,CAAC,IAAI,CAACA,CAAzB,CAAR,IAAwC,EAA/C;AACD;;AAEM,SAASM,iBAAT,CAA2BC,MAA3B,EAGM;AACX,SAAO;AACLf,IAAAA,GAAG,EAAEe,MAAM,CAACf,GADP;AAELE,IAAAA,GAAG,EAAEa,MAAM,CAACC;AAFP,GAAP;AAID;;AAEM,SAASC,qBAA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Ad,KACAA,GAAG,CAAC7B,MAAJ,KAAe,CADf,IAEAwB,UAAU,CAACK,GAAG,CAAC,CAAD,CAAJ,CAFV,IAGAF,UAAU,CAACE,GAAG,CAAC,CAAD,CAAJ,CAJZ;AAMD","sourcesContent":["import { LatLngArray, Location, UserPosition } from \"@opentripplanner/types\";\nimport { toSentenceCase } from \"./itinerary\";\n\n/*\nimport {\n // coordsToString,\n // getDetailText //,\n // latlngToString,\n // logDeprecationWarning\n} from \"./deprecated\";\n\nexport { coordsToString, getDetailText , latlngToString };\n*/\n\nexport function currentPositionToLocation(\n currentPosition: UserPosition\n): Location {\n if (currentPosition.error || !currentPosition.coords) {\n console.warn(\n \"Cannot construct location from current position due to geolocation error or missing coordinates.\"\n );\n return null;\n }\n return {\n lat: currentPosition.coords.latitude,\n lon: currentPosition.coords.longitude,\n category: \"CURRENT_LOCATION\"\n };\n}\n\n// TRICKY: It is used in query.js and in the context of\n// otp-rr actions where the intl context is not available.\nexport function coordsToString(coords: number[]): string {\n return coords.length && coords.map(c => (+c).toFixed(5)).join(\", \");\n}\n\nexport function stringToCoords(str: string): number[] {\n return (str && str.split(\",\").map(c => +c)) || [];\n}\n\nexport function constructLocation(latlng: {\n lat: number;\n lng: number;\n}): Location {\n return {\n lat: latlng.lat,\n lon: latlng.lng\n };\n}\n\nexport function formatStoredPlaceName(location: Location): string {\n return location.type === \"home\" || location.type === \"work\"\n ? toSentenceCase(location.type)\n : location.name;\n}\n\nexport function matchLatLon(location1: Location, location2: Location): boolean {\n if (!location1 || !location2) return location1 === location2;\n return location1.lat === location2.lat && location1.lon === location2.lon;\n}\n\ntype TransitivePlaceRaw = {\n place_id: string;\n};\nexport function isBikeshareStation(place: TransitivePlaceRaw): boolean {\n return place.place_id.lastIndexOf(\"bicycle_rent_station\") !== -1;\n}\n\nexport function isEScooterStation(place: TransitivePlaceRaw): boolean {\n return place.place_id.lastIndexOf(\"escooter_rent_station\") !== -1;\n}\n\nexport function isCarWalkTransition(place: TransitivePlaceRaw): boolean {\n return place.place_id.lastIndexOf(\"itin_car_\") !== -1;\n}\n\nexport function isValidLat(lat: number): boolean {\n return Number.isFinite(lat) && lat >= -90 && lat <= 90;\n}\n\nexport function isValidLng(lng: number): boolean {\n return Number.isFinite(lng) && lng >= -180 && lng <= 180;\n}\n\nexport function isValidLatLng(arr: LatLngArray): boolean {\n return (\n Array.isArray(arr) &&\n arr.length === 2 &&\n isValidLat(arr[0]) &&\n isValidLng(arr[1])\n );\n}\n"],"file":"map.js"}
1
+ {"version":3,"sources":["../src/map.ts"],"names":["currentPositionToLocation","currentPosition","error","coords","console","warn","lat","latitude","lon","longitude","category","coordsToString","length","map","c","toFixed","join","stringToCoords","str","split","constructLocation","latlng","lng","matchLatLon","location1","location2","isBikeshareStation","place","place_id","lastIndexOf","isEScooterStation","isCarWalkTransition","isValidLat","Number","isFinite","isValidLng","isValidLatLng","arr","Array","isArray"],"mappings":";;;;;;;;;;;;;;;;;AAEO,SAASA,yBAAT,CACLC,eADK,EAEK;AACV,MAAIA,eAAe,CAACC,KAAhB,IAAyB,CAACD,eAAe,CAACE,MAA9C,EAAsD;AACpDC,IAAAA,OAAO,CAACC,IAAR,CACE,kGADF;AAGA,WAAO,IAAP;AACD;;AACD,SAAO;AACLC,IAAAA,GAAG,EAAEL,eAAe,CAACE,MAAhB,CAAuBI,QADvB;AAELC,IAAAA,GAAG,EAAEP,eAAe,CAACE,MAAhB,CAAuBM,SAFvB;AAGLC,IAAAA,QAAQ,EAAE;AAHL,GAAP;AAKD,C,CAED;AACA;;;AACO,SAASC,cAAT,CAAwBR,MAAxB,EAAkD;AACvD,SAAOA,MAAM,CAACS,MAAP,IAAiBT,MAAM,CAACU,GAAP,CAAWC,CAAC,IAAI,CAAC,CAACA,CAAF,EAAKC,OAAL,CAAa,CAAb,CAAhB,EAAiCC,IAAjC,CAAsC,IAAtC,CAAxB;AACD;;AAEM,SAASC,cAAT,CAAwBC,GAAxB,EAA+C;AACpD,SAAQA,GAAG,IAAI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c,aAAT,CAAuBC,GAAvB,EAAkD;AACvD,SACEC,KAAK,CAACC,OAAN,CAAcF,GAAd,KACAA,GAAG,CAACzB,MAAJ,KAAe,CADf,IAEAoB,UAAU,CAACK,GAAG,CAAC,CAAD,CAAJ,CAFV,IAGAF,UAAU,CAACE,GAAG,CAAC,CAAD,CAAJ,CAJZ;AAMD","sourcesContent":["import { LatLngArray, Location, UserPosition } from \"@opentripplanner/types\";\n\nexport function currentPositionToLocation(\n currentPosition: UserPosition\n): Location {\n if (currentPosition.error || !currentPosition.coords) {\n console.warn(\n \"Cannot construct location from current position due to geolocation error or missing coordinates.\"\n );\n return null;\n }\n return {\n lat: currentPosition.coords.latitude,\n lon: currentPosition.coords.longitude,\n category: \"CURRENT_LOCATION\"\n };\n}\n\n// TRICKY: This method is used in query.js and in the context of\n// otp-rr actions where the intl context is not available/does not apply.\nexport function coordsToString(coords: number[]): string {\n return coords.length && coords.map(c => (+c).toFixed(5)).join(\", \");\n}\n\nexport function stringToCoords(str: string): number[] {\n return (str && str.split(\",\").map(c => +c)) || [];\n}\n\nexport function constructLocation(latlng: {\n lat: number;\n lng: number;\n}): Location {\n return {\n lat: latlng.lat,\n lon: latlng.lng\n };\n}\n\nexport function matchLatLon(location1: Location, location2: Location): boolean {\n if (!location1 || !location2) return location1 === location2;\n return location1.lat === location2.lat && location1.lon === location2.lon;\n}\n\ntype TransitivePlaceRaw = {\n place_id: string;\n};\nexport function isBikeshareStation(place: TransitivePlaceRaw): boolean {\n return place.place_id.lastIndexOf(\"bicycle_rent_station\") !== -1;\n}\n\nexport function isEScooterStation(place: TransitivePlaceRaw): boolean {\n return place.place_id.lastIndexOf(\"escooter_rent_station\") !== -1;\n}\n\nexport function isCarWalkTransition(place: TransitivePlaceRaw): boolean {\n return place.place_id.lastIndexOf(\"itin_car_\") !== -1;\n}\n\nexport function isValidLat(lat: number): boolean {\n return Number.isFinite(lat) && lat >= -90 && lat <= 90;\n}\n\nexport function isValidLng(lng: number): boolean {\n return Number.isFinite(lng) && lng >= -180 && lng <= 180;\n}\n\nexport function isValidLatLng(arr: LatLngArray): boolean {\n return (\n Array.isArray(arr) &&\n arr.length === 2 &&\n isValidLat(arr[0]) &&\n isValidLng(arr[1])\n );\n}\n"],"file":"map.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentripplanner/core-utils",
3
- "version": "7.0.0-alpha.3",
3
+ "version": "7.0.0-alpha.4",
4
4
  "description": "Core functionality that is shared among numerous UI components",
5
5
  "engines": {
6
6
  "node": ">=13"
package/src/map.ts CHANGED
@@ -1,16 +1,4 @@
1
1
  import { LatLngArray, Location, UserPosition } from "@opentripplanner/types";
2
- import { toSentenceCase } from "./itinerary";
3
-
4
- /*
5
- import {
6
- // coordsToString,
7
- // getDetailText //,
8
- // latlngToString,
9
- // logDeprecationWarning
10
- } from "./deprecated";
11
-
12
- export { coordsToString, getDetailText , latlngToString };
13
- */
14
2
 
15
3
  export function currentPositionToLocation(
16
4
  currentPosition: UserPosition
@@ -28,8 +16,8 @@ export function currentPositionToLocation(
28
16
  };
29
17
  }
30
18
 
31
- // TRICKY: It is used in query.js and in the context of
32
- // otp-rr actions where the intl context is not available.
19
+ // TRICKY: This method is used in query.js and in the context of
20
+ // otp-rr actions where the intl context is not available/does not apply.
33
21
  export function coordsToString(coords: number[]): string {
34
22
  return coords.length && coords.map(c => (+c).toFixed(5)).join(", ");
35
23
  }
@@ -48,12 +36,6 @@ export function constructLocation(latlng: {
48
36
  };
49
37
  }
50
38
 
51
- export function formatStoredPlaceName(location: Location): string {
52
- return location.type === "home" || location.type === "work"
53
- ? toSentenceCase(location.type)
54
- : location.name;
55
- }
56
-
57
39
  export function matchLatLon(location1: Location, location2: Location): boolean {
58
40
  if (!location1 || !location2) return location1 === location2;
59
41
  return location1.lat === location2.lat && location1.lon === location2.lon;
@@ -207,8 +207,8 @@
207
207
  "affectsGlobalScope": false
208
208
  },
209
209
  "./src/map.ts": {
210
- "version": "796798287eeea529df4241e8368d171c2afc828bab4d9e865a667921522c02ee",
211
- "signature": "273c14d4b44340b3847bac53e24cdb7b16571aa4205b5e82c4c2ec9de337c38a",
210
+ "version": "fd1b798443d912865c1ee180f894c10606e58ace5fa597ef7d08ef6404c6ccfe",
211
+ "signature": "1dd55f033c2cef7bd9d60472df068b2387205ae1cfdce77f07dbda6fae38cbe5",
212
212
  "affectsGlobalScope": false
213
213
  },
214
214
  "./src/route.ts": {
@@ -3057,8 +3057,7 @@
3057
3057
  "./src/map.ts": [
3058
3058
  "../types/lib/index.d.ts",
3059
3059
  "./node_modules/date-fns-tz/typings.d.ts",
3060
- "./node_modules/date-fns/typings.d.ts",
3061
- "./src/itinerary.ts"
3060
+ "./node_modules/date-fns/typings.d.ts"
3062
3061
  ],
3063
3062
  "./src/route.ts": [
3064
3063
  "../types/lib/index.d.ts",