@lyxa.ai/core 1.3.184 → 1.3.186
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/dist/libraries/event/events/mongo-stream-changes-batch-process-shops-event.d.ts +1 -0
- package/dist/libraries/event/events/mongo-stream-changes-batch-process-shops-event.js +1 -0
- package/dist/libraries/event/events/mongo-stream-changes-batch-process-shops-event.js.map +1 -1
- package/dist/libraries/map/mapService.js +2 -12
- package/dist/libraries/map/mapService.js.map +1 -1
- package/dist/libraries/trpc/middlewares/auth.d.ts +1 -1
- package/dist/libraries/trpc/middlewares/createRoleProtectedProcedure.d.ts +1 -1
- package/dist/libraries/trpc/middlewares/phone-verified.d.ts +1 -1
- package/dist/libraries/trpc/middlewares/publicUserDecoder.d.ts +1 -1
- package/dist/types/README.md +1 -1
- package/dist/types/package.json +1 -1
- package/dist/types/utilities/shared/distance.d.ts +1 -0
- package/dist/types/utilities/shared/distance.js +18 -0
- package/dist/types/utilities/shared/distance.js.map +1 -0
- package/dist/utilities/shared/distance.d.ts +1 -0
- package/dist/utilities/shared/distance.js +18 -0
- package/dist/utilities/shared/distance.js.map +1 -0
- package/package.json +1 -1
|
@@ -13,6 +13,7 @@ export declare enum UpdateCollectionAtlasSearchEnum {
|
|
|
13
13
|
BRANDS = "brands",
|
|
14
14
|
PRODUCTS = "products",
|
|
15
15
|
CATEGORIES = "categories",
|
|
16
|
+
SHOP_CATEGORIES = "shopCategories",
|
|
16
17
|
USER_APP_SECTION_SETTING = "userAppSectionSetting"
|
|
17
18
|
}
|
|
18
19
|
declare const MongoStreamsBatchProcessShopsSchema: z.ZodObject<{
|
|
@@ -19,6 +19,7 @@ var UpdateCollectionAtlasSearchEnum;
|
|
|
19
19
|
UpdateCollectionAtlasSearchEnum["BRANDS"] = "brands";
|
|
20
20
|
UpdateCollectionAtlasSearchEnum["PRODUCTS"] = "products";
|
|
21
21
|
UpdateCollectionAtlasSearchEnum["CATEGORIES"] = "categories";
|
|
22
|
+
UpdateCollectionAtlasSearchEnum["SHOP_CATEGORIES"] = "shopCategories";
|
|
22
23
|
UpdateCollectionAtlasSearchEnum["USER_APP_SECTION_SETTING"] = "userAppSectionSetting";
|
|
23
24
|
})(UpdateCollectionAtlasSearchEnum || (exports.UpdateCollectionAtlasSearchEnum = UpdateCollectionAtlasSearchEnum = {}));
|
|
24
25
|
const baseFields = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mongo-stream-changes-batch-process-shops-event.js","sourceRoot":"/","sources":["libraries/event/events/mongo-stream-changes-batch-process-shops-event.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,4CAAyC;AACzC,8CAAkD;AAClD,uFAA0G;AAE1G,IAAY,0BAKX;AALD,WAAY,0BAA0B;IAClC,+CAAiB,CAAA;IACjB,+CAAiB,CAAA;IACjB,iDAAmB,CAAA;IACnB,+CAAiB,CAAA;AACrB,CAAC,EALW,0BAA0B,0CAA1B,0BAA0B,QAKrC;AAED,IAAY,+
|
|
1
|
+
{"version":3,"file":"mongo-stream-changes-batch-process-shops-event.js","sourceRoot":"/","sources":["libraries/event/events/mongo-stream-changes-batch-process-shops-event.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,4CAAyC;AACzC,8CAAkD;AAClD,uFAA0G;AAE1G,IAAY,0BAKX;AALD,WAAY,0BAA0B;IAClC,+CAAiB,CAAA;IACjB,+CAAiB,CAAA;IACjB,iDAAmB,CAAA;IACnB,+CAAiB,CAAA;AACrB,CAAC,EALW,0BAA0B,0CAA1B,0BAA0B,QAKrC;AAED,IAAY,+BAQX;AARD,WAAY,+BAA+B;IACvC,kDAAe,CAAA;IACf,gDAAa,CAAA;IACb,oDAAiB,CAAA;IACjB,wDAAqB,CAAA;IACrB,4DAAyB,CAAA;IACzB,qEAAkC,CAAA;IAClC,qFAAkD,CAAA;AACtD,CAAC,EARW,+BAA+B,+CAA/B,+BAA+B,QAQ1C;AAED,MAAM,UAAU,GAAG;IACf,SAAS,EAAE,iCAAa,CAAC,QAAQ,CAAC,0BAA0B,EAAE,yBAAyB,CAAC;IACxF,gBAAgB,EAAE,iCAAa,CAAC,QAAQ,CAAC,+BAA+B,EAAE,oBAAoB,CAAC;IAC/F,aAAa,EAAE,OAAC,CAAC,GAAG,EAAE;IACtB,YAAY,EAAE,OAAC,CAAC,GAAG,EAAE;CACxB,CAAC;AACF,MAAM,aAAa,GAAG,IAAA,uCAAmB,EAAC,UAAU,CAAC,CAAC;AACtD,MAAM,EACF,UAAU,EAAE,mCAAmC,GAClD,GAAG,aAAa,CAAC,aAAa,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAIrD,MAAa,kCAAmC,SAAQ,qBAAkC;IACtF,YAAY,OAAyC;QACjD,KAAK,CAAC,8BAAiB,CAAC,8CAA8C,EAAE,OAAkC,CAAC,CAAC;IAChH,CAAC;CACJ;AAJD,gFAIC","sourcesContent":["import { z } from 'zod';\nimport { BaseEvent } from '../BaseEvent';\nimport { PublishEventEnums } from '../EventEnums';\nimport { createSchemaBuilder, DTO, ZodValidation } from '../../../utilities/validation/global-validation';\n\nexport enum ChangeStreamOperationTypes {\n INSERT = \"insert\",\n UPDATE = \"update\",\n REPLACE = \"replace\",\n DELETE = \"delete\"\n}\n\nexport enum UpdateCollectionAtlasSearchEnum {\n SHOPS = 'shops',\n TAGS = 'tags',\n BRANDS = 'brands',\n PRODUCTS = 'products',\n CATEGORIES = 'categories',\n SHOP_CATEGORIES = 'shopCategories',\n USER_APP_SECTION_SETTING = 'userAppSectionSetting'\n}\n\nconst baseFields = {\n operation: ZodValidation.enumType(ChangeStreamOperationTypes, 'Mongo streams operation'),\n updateCollection: ZodValidation.enumType(UpdateCollectionAtlasSearchEnum, 'Updated collection'),\n updatedFields: z.any(),\n fullDocument: z.any()\n};\nconst schemaBuilder = createSchemaBuilder(baseFields);\nconst {\n BaseSchema: MongoStreamsBatchProcessShopsSchema,\n} = schemaBuilder.getAllSchemas({ createdAt: true });\n\nexport type MongoStreamsBatchProcessShopsDTO = DTO<typeof MongoStreamsBatchProcessShopsSchema>;\n\nexport class MongoStreamsBatchProcessShopsEvent extends BaseEvent<Record<string, unknown>> {\n constructor(payload: MongoStreamsBatchProcessShopsDTO) {\n super(PublishEventEnums.MONGO_STREAM_CHANGES_BATCH_PROCESS_SHOPS_EVENT, payload as Record<string, unknown>);\n }\n}"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MapService = exports.MapProvider = void 0;
|
|
4
|
+
const distance_1 = require("../../utilities/shared/distance");
|
|
4
5
|
var MapProvider;
|
|
5
6
|
(function (MapProvider) {
|
|
6
7
|
MapProvider["GOOGLE"] = "google";
|
|
@@ -14,18 +15,7 @@ class MapService {
|
|
|
14
15
|
this.osrm = osrm;
|
|
15
16
|
}
|
|
16
17
|
calculateHaversineDistance(coord1, coord2) {
|
|
17
|
-
|
|
18
|
-
const [lat2, lon2] = coord2;
|
|
19
|
-
const R = 6371;
|
|
20
|
-
const dLat = ((lat2 - lat1) * Math.PI) / 180;
|
|
21
|
-
const dLon = ((lon2 - lon1) * Math.PI) / 180;
|
|
22
|
-
const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
|
|
23
|
-
Math.cos((lat1 * Math.PI) / 180) *
|
|
24
|
-
Math.cos((lat2 * Math.PI) / 180) *
|
|
25
|
-
Math.sin(dLon / 2) *
|
|
26
|
-
Math.sin(dLon / 2);
|
|
27
|
-
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
|
28
|
-
return R * c;
|
|
18
|
+
return (0, distance_1.haversineDistance)(coord1, coord2);
|
|
29
19
|
}
|
|
30
20
|
getProvider(options) {
|
|
31
21
|
const provider = options?.provider ?? MapProvider.OSRM;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapService.js","sourceRoot":"/","sources":["libraries/map/mapService.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"mapService.js","sourceRoot":"/","sources":["libraries/map/mapService.ts"],"names":[],"mappings":";;;AASA,8DAAoE;AAEpE,IAAY,WAGX;AAHD,WAAY,WAAW;IACtB,gCAAiB,CAAA;IACjB,4BAAa,CAAA;AACd,CAAC,EAHW,WAAW,2BAAX,WAAW,QAGtB;AAOD,MAAa,UAAU;IACd,MAAM,CAAoB;IAC1B,IAAI,CAAiB;IAE7B,YAAY,MAAyB,EAAE,IAAoB;QAC1D,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,CAAC;IAQM,0BAA0B,CAAC,MAAwB,EAAE,MAAwB;QACnF,OAAO,IAAA,4BAAiB,EAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,CAAC;IAEO,WAAW,CAAC,OAAoB;QAEvC,MAAM,QAAQ,GAAG,OAAO,EAAE,QAAQ,IAAI,WAAW,CAAC,IAAI,CAAC;QAEvD,QAAQ,QAAQ,EAAE,CAAC;YAClB,KAAK,WAAW,CAAC,MAAM;gBACtB,OAAO,IAAI,CAAC,MAAM,CAAC;YACpB,KAAK,WAAW,CAAC,IAAI;gBACpB,OAAO,IAAI,CAAC,IAAI,CAAC;YAClB;gBACC,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAC1C,CAAC;IACF,CAAC;IAEM,KAAK,CAAC,mCAAmC,CAC/C,MAAwB,EACxB,MAAwB,EACxB,OAAoB;QAEpB,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC;QAC5B,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC;QAE5B,IAAI,CAAC;YACJ,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,eAAe,CACnE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,EACnC,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CACnC,CAAC;YACF,IAAI,YAAY,IAAI,YAAY,CAAC,QAAQ,EAAE,CAAC;gBAC3C,OAAO,YAAY,CAAC,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC;YAC3C,CAAC;QACF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,CAAC,KAAK,CAAC,iCAAiC,KAAK,EAAE,CAAC,CAAC;QACzD,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,yDAAyD,CAAC,CAAC;QACvE,OAAO,IAAI,CAAC,0BAA0B,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,eAAe,CACpB,MAAmB,EACnB,WAAwB,EACxB,OAAoB;QAEpB,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,eAAe,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC7E,CAAC;IAED,KAAK,CAAC,wBAAwB,CAC7B,MAAmB,EACnB,WAAwB,EACxB,SAA6B,EAC7B,OAAoB;QAEpB,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,wBAAwB,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;IACjG,CAAC;IAED,KAAK,CAAC,iBAAiB,CACtB,OAA2B,EAC3B,YAAgC,EAChC,OAAoB;QAEpB,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,iBAAiB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACjF,CAAC;CACD;AAhFD,gCAgFC","sourcesContent":["import { GoogleMapsService } from './providers/google-maps';\nimport { OsrmMapService } from './providers/osrm';\nimport {\n\tICoordinate,\n\tIDistanceInfo,\n\tIMapService,\n\tIRouteMatrixDTO,\n\tIWaypointDistanceInfo,\n} from './interfaces/IMapService';\nimport { haversineDistance } from '../../utilities/shared/distance';\n\nexport enum MapProvider {\n\tGOOGLE = 'google',\n\tOSRM = 'osrm',\n}\n\nexport interface MapOptions {\n\tprovider: MapProvider;\n\t// Add other options if needed\n}\n\nexport class MapService {\n\tprivate google: GoogleMapsService;\n\tprivate osrm: OsrmMapService;\n\n\tconstructor(google: GoogleMapsService, osrm: OsrmMapService) {\n\t\tthis.google = google;\n\t\tthis.osrm = osrm;\n\t}\n\n\t/**\n\t *\n\t * @param coord1 [latitude, longitude]\n\t * @param coord2 [latitude, longitude]\n\t * @returns straight line distance in KM\n\t */\n\tpublic calculateHaversineDistance(coord1: [number, number], coord2: [number, number]): number {\n\t\treturn haversineDistance(coord1, coord2);\n\t}\n\t\n\tprivate getProvider(options?: MapOptions): IMapService {\n\t\t// Default to OSRM if options not provided\n\t\tconst provider = options?.provider ?? MapProvider.OSRM;\n\n\t\tswitch (provider) {\n\t\t\tcase MapProvider.GOOGLE:\n\t\t\t\treturn this.google;\n\t\t\tcase MapProvider.OSRM:\n\t\t\t\treturn this.osrm;\n\t\t\tdefault:\n\t\t\t\tthrow new Error('Unknown map provider');\n\t\t}\n\t}\n\n\tpublic async calculateDistanceBetweenCoordinates(\n\t\tcoord1: [number, number],\n\t\tcoord2: [number, number],\n\t\toptions?: MapOptions // optional\n\t): Promise<number> {\n\t\tconst [lon1, lat1] = coord1;\n\t\tconst [lon2, lat2] = coord2;\n\n\t\ttry {\n\t\t\tconst distanceInfo = await this.getProvider(options).getDistanceInfo(\n\t\t\t\t{ latitude: lat1, longitude: lon1 },\n\t\t\t\t{ latitude: lat2, longitude: lon2 }\n\t\t\t);\n\t\t\tif (distanceInfo && distanceInfo.distance) {\n\t\t\t\treturn distanceInfo.distance.value / 1000;\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.error(`Error fetching distance info: ${error}`);\n\t\t}\n\t\tconsole.log('Maps API failed. Falling back to Haversine calculation.');\n\t\treturn this.calculateHaversineDistance(coord1, coord2);\n\t}\n\n\tasync getDistanceInfo(\n\t\torigin: ICoordinate,\n\t\tdestination: ICoordinate,\n\t\toptions?: MapOptions\n\t): Promise<IDistanceInfo> {\n\t\treturn await this.getProvider(options).getDistanceInfo(origin, destination);\n\t}\n\n\tasync getWaypointsDistanceInfo(\n\t\torigin: ICoordinate,\n\t\tdestination: ICoordinate,\n\t\twaypoints: Array<ICoordinate>,\n\t\toptions?: MapOptions\n\t): Promise<IWaypointDistanceInfo> {\n\t\treturn await this.getProvider(options).getWaypointsDistanceInfo(origin, destination, waypoints);\n\t}\n\n\tasync getDistanceMatrix(\n\t\torigins: Array<ICoordinate>,\n\t\tdestinations: Array<ICoordinate>,\n\t\toptions?: MapOptions\n\t): Promise<IRouteMatrixDTO[]> {\n\t\treturn await this.getProvider(options).getDistanceMatrix(origins, destinations);\n\t}\n}\n"]}
|
|
@@ -5,10 +5,10 @@ interface AuthOptions {
|
|
|
5
5
|
autoRefresh?: boolean;
|
|
6
6
|
}
|
|
7
7
|
export declare function createAuthenticatedProcedure(options: AuthOptions): import("@trpc/server").TRPCProcedureBuilder<import("../context").LyxaHTTPContext, object, {
|
|
8
|
-
req: import("http").IncomingMessage;
|
|
9
8
|
res: import("http").ServerResponse<import("http").IncomingMessage>;
|
|
10
9
|
tokenType: TokenType | undefined;
|
|
11
10
|
entity: import("../context").EntityContext | undefined;
|
|
11
|
+
req: import("http").IncomingMessage;
|
|
12
12
|
requestId: string | undefined;
|
|
13
13
|
usedRefreshToken: boolean | undefined;
|
|
14
14
|
tokenRenewed: boolean | undefined;
|
|
@@ -4,10 +4,10 @@ interface RoleProtectedOptions {
|
|
|
4
4
|
allowedRoles: string[];
|
|
5
5
|
}
|
|
6
6
|
export declare function createRoleProtectedProcedure(options: RoleProtectedOptions): import("@trpc/server").TRPCProcedureBuilder<import("../context").LyxaHTTPContext, object, {
|
|
7
|
-
req: import("http").IncomingMessage;
|
|
8
7
|
res: import("http").ServerResponse<import("http").IncomingMessage>;
|
|
9
8
|
tokenType: import("../../auth").TokenType | undefined;
|
|
10
9
|
entity: import("../context").EntityContext | undefined;
|
|
10
|
+
req: import("http").IncomingMessage;
|
|
11
11
|
requestId: string | undefined;
|
|
12
12
|
usedRefreshToken: boolean | undefined;
|
|
13
13
|
tokenRenewed: boolean | undefined;
|
|
@@ -3,10 +3,10 @@ interface PhoneVerifiedOptions {
|
|
|
3
3
|
entityTypes: AuthEntityType[];
|
|
4
4
|
}
|
|
5
5
|
export declare function createPhoneVerifiedProcedure(options: PhoneVerifiedOptions): import("@trpc/server").TRPCProcedureBuilder<import("../context").LyxaHTTPContext, object, {
|
|
6
|
-
req: import("http").IncomingMessage;
|
|
7
6
|
res: import("http").ServerResponse<import("http").IncomingMessage>;
|
|
8
7
|
tokenType: import("../../auth").TokenType | undefined;
|
|
9
8
|
entity: import("../context").EntityContext | undefined;
|
|
9
|
+
req: import("http").IncomingMessage;
|
|
10
10
|
requestId: string | undefined;
|
|
11
11
|
usedRefreshToken: boolean | undefined;
|
|
12
12
|
tokenRenewed: boolean | undefined;
|
|
@@ -5,10 +5,10 @@ interface AuthOptions {
|
|
|
5
5
|
autoRefresh?: boolean;
|
|
6
6
|
}
|
|
7
7
|
export declare function publicUserDecoder(options: AuthOptions): import("@trpc/server").TRPCProcedureBuilder<import("../context").LyxaHTTPContext, object, {
|
|
8
|
-
req: import("http").IncomingMessage;
|
|
9
8
|
res: import("http").ServerResponse<import("http").IncomingMessage>;
|
|
10
9
|
tokenType: TokenType | undefined;
|
|
11
10
|
entity: import("../context").EntityContext | undefined;
|
|
11
|
+
req: import("http").IncomingMessage;
|
|
12
12
|
requestId: string | undefined;
|
|
13
13
|
usedRefreshToken: boolean | undefined;
|
|
14
14
|
tokenRenewed: boolean | undefined;
|
package/dist/types/README.md
CHANGED
package/dist/types/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function haversineDistance(coord1: [number, number], coord2: [number, number]): number;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.haversineDistance = haversineDistance;
|
|
4
|
+
function haversineDistance(coord1, coord2) {
|
|
5
|
+
const [lat1, lon1] = coord1;
|
|
6
|
+
const [lat2, lon2] = coord2;
|
|
7
|
+
const R = 6371;
|
|
8
|
+
const dLat = ((lat2 - lat1) * Math.PI) / 180;
|
|
9
|
+
const dLon = ((lon2 - lon1) * Math.PI) / 180;
|
|
10
|
+
const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
|
|
11
|
+
Math.cos((lat1 * Math.PI) / 180) *
|
|
12
|
+
Math.cos((lat2 * Math.PI) / 180) *
|
|
13
|
+
Math.sin(dLon / 2) *
|
|
14
|
+
Math.sin(dLon / 2);
|
|
15
|
+
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
|
16
|
+
return R * c;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=distance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"distance.js","sourceRoot":"/","sources":["utilities/shared/distance.ts"],"names":[],"mappings":";;AAMA,8CAcC;AAdD,SAAgB,iBAAiB,CAAC,MAAwB,EAAE,MAAwB;IACnF,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC;IAC5B,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC;IAC5B,MAAM,CAAC,GAAG,IAAI,CAAC;IACf,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;IAC7C,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;IAC7C,MAAM,CAAC,GACN,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC;QACvC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;YAC/B,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;YAChC,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC;YAClB,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;IACrB,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,OAAO,CAAC,GAAG,CAAC,CAAC;AACd,CAAC","sourcesContent":["/**\n * Calculates the Haversine distance between two coordinates.\n * @param coord1 [latitude, longitude]\n * @param coord2 [latitude, longitude]\n * @returns straight line distance in KM\n */\nexport function haversineDistance(coord1: [number, number], coord2: [number, number]): number {\n\tconst [lat1, lon1] = coord1;\n\tconst [lat2, lon2] = coord2;\n\tconst R = 6371;\n\tconst dLat = ((lat2 - lat1) * Math.PI) / 180;\n\tconst dLon = ((lon2 - lon1) * Math.PI) / 180;\n\tconst a =\n\t\tMath.sin(dLat / 2) * Math.sin(dLat / 2) +\n\t\tMath.cos((lat1 * Math.PI) / 180) *\n\t\t\tMath.cos((lat2 * Math.PI) / 180) *\n\t\t\tMath.sin(dLon / 2) *\n\t\t\tMath.sin(dLon / 2);\n\tconst c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));\n\treturn R * c;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function haversineDistance(coord1: [number, number], coord2: [number, number]): number;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.haversineDistance = haversineDistance;
|
|
4
|
+
function haversineDistance(coord1, coord2) {
|
|
5
|
+
const [lat1, lon1] = coord1;
|
|
6
|
+
const [lat2, lon2] = coord2;
|
|
7
|
+
const R = 6371;
|
|
8
|
+
const dLat = ((lat2 - lat1) * Math.PI) / 180;
|
|
9
|
+
const dLon = ((lon2 - lon1) * Math.PI) / 180;
|
|
10
|
+
const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
|
|
11
|
+
Math.cos((lat1 * Math.PI) / 180) *
|
|
12
|
+
Math.cos((lat2 * Math.PI) / 180) *
|
|
13
|
+
Math.sin(dLon / 2) *
|
|
14
|
+
Math.sin(dLon / 2);
|
|
15
|
+
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
|
16
|
+
return R * c;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=distance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"distance.js","sourceRoot":"/","sources":["utilities/shared/distance.ts"],"names":[],"mappings":";;AAMA,8CAcC;AAdD,SAAgB,iBAAiB,CAAC,MAAwB,EAAE,MAAwB;IACnF,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC;IAC5B,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC;IAC5B,MAAM,CAAC,GAAG,IAAI,CAAC;IACf,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;IAC7C,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;IAC7C,MAAM,CAAC,GACN,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC;QACvC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;YAC/B,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;YAChC,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC;YAClB,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;IACrB,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,OAAO,CAAC,GAAG,CAAC,CAAC;AACd,CAAC","sourcesContent":["/**\n * Calculates the Haversine distance between two coordinates.\n * @param coord1 [latitude, longitude]\n * @param coord2 [latitude, longitude]\n * @returns straight line distance in KM\n */\nexport function haversineDistance(coord1: [number, number], coord2: [number, number]): number {\n\tconst [lat1, lon1] = coord1;\n\tconst [lat2, lon2] = coord2;\n\tconst R = 6371;\n\tconst dLat = ((lat2 - lat1) * Math.PI) / 180;\n\tconst dLon = ((lon2 - lon1) * Math.PI) / 180;\n\tconst a =\n\t\tMath.sin(dLat / 2) * Math.sin(dLat / 2) +\n\t\tMath.cos((lat1 * Math.PI) / 180) *\n\t\t\tMath.cos((lat2 * Math.PI) / 180) *\n\t\t\tMath.sin(dLon / 2) *\n\t\t\tMath.sin(dLon / 2);\n\tconst c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));\n\treturn R * c;\n}\n"]}
|