akeyless-server-commons 1.0.156 → 1.0.157

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.
@@ -9,3 +9,4 @@ export * from "./phone_number_helpers";
9
9
  export * from "./tasks_helpers";
10
10
  export * from "./boards_helpers";
11
11
  export * from "./redis";
12
+ export * from "./location_helpers";
@@ -25,4 +25,5 @@ __exportStar(require("./phone_number_helpers"), exports);
25
25
  __exportStar(require("./tasks_helpers"), exports);
26
26
  __exportStar(require("./boards_helpers"), exports);
27
27
  __exportStar(require("./redis"), exports);
28
+ __exportStar(require("./location_helpers"), exports);
28
29
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,qDAAmC;AACnC,0CAAwB;AACxB,iDAA+B;AAC/B,kDAAgC;AAChC,yDAAuC;AACvC,kDAAgC;AAChC,yDAAuC;AACvC,kDAAgC;AAChC,mDAAiC;AACjC,0CAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,qDAAmC;AACnC,0CAAwB;AACxB,iDAA+B;AAC/B,kDAAgC;AAChC,yDAAuC;AACvC,kDAAgC;AAChC,yDAAuC;AACvC,kDAAgC;AAChC,mDAAiC;AACjC,0CAAwB;AACxB,qDAAmC"}
@@ -0,0 +1,3 @@
1
+ import { Geo } from "akeyless-types-commons";
2
+ export declare const get_distance_in_meters_between_geo_points: (location1: Geo, location2: Geo) => number;
3
+ export declare const get_location_url: (location: Geo) => string;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.get_location_url = exports.get_distance_in_meters_between_geo_points = void 0;
4
+ const get_distance_in_meters_between_geo_points = (location1, location2) => {
5
+ const toRadians = (angle) => angle * (Math.PI / 180);
6
+ const R = 6371e3;
7
+ const φ1 = toRadians(location1.lat);
8
+ const φ2 = toRadians(location2.lat);
9
+ const Δφ = toRadians(location2.lat - location1.lat);
10
+ const Δλ = toRadians(location2.lng - location1.lng);
11
+ const a = Math.sin(Δφ / 2) * Math.sin(Δφ / 2) + Math.cos(φ1) * Math.cos(φ2) * Math.sin(Δλ / 2) * Math.sin(Δλ / 2);
12
+ const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
13
+ // distance in meters
14
+ return R * c;
15
+ };
16
+ exports.get_distance_in_meters_between_geo_points = get_distance_in_meters_between_geo_points;
17
+ const get_location_url = (location) => {
18
+ return `https://www.google.com/maps?q=${location.lat},${location.lng}`;
19
+ };
20
+ exports.get_location_url = get_location_url;
21
+ //# sourceMappingURL=location_helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"location_helpers.js","sourceRoot":"","sources":["../../../src/helpers/location_helpers.ts"],"names":[],"mappings":";;;AAEO,MAAM,yCAAyC,GAAG,CAAC,SAAc,EAAE,SAAc,EAAU,EAAE;IAChG,MAAM,SAAS,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC;IAC7D,MAAM,CAAC,GAAG,MAAM,CAAC;IACjB,MAAM,EAAE,GAAG,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IACpC,MAAM,EAAE,GAAG,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IACpC,MAAM,EAAE,GAAG,SAAS,CAAC,SAAS,CAAC,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;IACpD,MAAM,EAAE,GAAG,SAAS,CAAC,SAAS,CAAC,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;IAEpD,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;IAClH,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACzD,qBAAqB;IACrB,OAAO,CAAC,GAAG,CAAC,CAAC;AACjB,CAAC,CAAC;AAZW,QAAA,yCAAyC,6CAYpD;AAEK,MAAM,gBAAgB,GAAG,CAAC,QAAa,EAAE,EAAE;IAC9C,OAAO,iCAAiC,QAAQ,CAAC,GAAG,IAAI,QAAQ,CAAC,GAAG,EAAE,CAAC;AAC3E,CAAC,CAAC;AAFW,QAAA,gBAAgB,oBAE3B"}
@@ -9,3 +9,4 @@ export * from "./phone_number_helpers";
9
9
  export * from "./tasks_helpers";
10
10
  export * from "./boards_helpers";
11
11
  export * from "./redis";
12
+ export * from "./location_helpers";
@@ -9,4 +9,5 @@ export * from "./phone_number_helpers";
9
9
  export * from "./tasks_helpers";
10
10
  export * from "./boards_helpers";
11
11
  export * from "./redis";
12
+ export * from "./location_helpers";
12
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC;AACxB,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Geo } from "akeyless-types-commons";
2
+ export declare const get_distance_in_meters_between_geo_points: (location1: Geo, location2: Geo) => number;
3
+ export declare const get_location_url: (location: Geo) => string;
@@ -0,0 +1,16 @@
1
+ export const get_distance_in_meters_between_geo_points = (location1, location2) => {
2
+ const toRadians = (angle) => angle * (Math.PI / 180);
3
+ const R = 6371e3;
4
+ const φ1 = toRadians(location1.lat);
5
+ const φ2 = toRadians(location2.lat);
6
+ const Δφ = toRadians(location2.lat - location1.lat);
7
+ const Δλ = toRadians(location2.lng - location1.lng);
8
+ const a = Math.sin(Δφ / 2) * Math.sin(Δφ / 2) + Math.cos(φ1) * Math.cos(φ2) * Math.sin(Δλ / 2) * Math.sin(Δλ / 2);
9
+ const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
10
+ // distance in meters
11
+ return R * c;
12
+ };
13
+ export const get_location_url = (location) => {
14
+ return `https://www.google.com/maps?q=${location.lat},${location.lng}`;
15
+ };
16
+ //# sourceMappingURL=location_helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"location_helpers.js","sourceRoot":"","sources":["../../../src/helpers/location_helpers.ts"],"names":[],"mappings":"AAEA,MAAM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,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akeyless-server-commons",
3
- "version": "1.0.156",
3
+ "version": "1.0.157",
4
4
  "scripts": {
5
5
  "build:cjs": "tsc --project tsconfig.cjs.json",
6
6
  "build:esm": "tsc --project tsconfig.esm.json",