@golemio/pid 2.9.6-dev.1055849165 → 2.9.6-dev.1063418817
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/db/example/redis/publicVehiclePositionsMock.json +24 -0
- package/dist/helpers/RouteTypeEnums.d.ts +2 -0
- package/dist/helpers/RouteTypeEnums.js +31 -1
- package/dist/helpers/RouteTypeEnums.js.map +1 -1
- package/dist/integration-engine/vehicle-positions/ioc/Di.js +6 -0
- package/dist/integration-engine/vehicle-positions/ioc/Di.js.map +1 -1
- package/dist/integration-engine/vehicle-positions/ioc/VPContainerToken.d.ts +3 -0
- package/dist/integration-engine/vehicle-positions/ioc/VPContainerToken.js +3 -0
- package/dist/integration-engine/vehicle-positions/ioc/VPContainerToken.js.map +1 -1
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/VPWorker.d.ts +2 -1
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/VPWorker.js +7 -0
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/VPWorker.js.map +1 -1
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/data-access/TripsRepository.d.ts +2 -1
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/data-access/TripsRepository.js +61 -0
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/data-access/TripsRepository.js.map +1 -1
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/data-access/cache/PublicApiCacheRepository.d.ts +7 -0
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/data-access/cache/PublicApiCacheRepository.js +66 -0
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/data-access/cache/PublicApiCacheRepository.js.map +1 -0
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/data-access/helpers/PositionsMapper.js +3 -1
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/data-access/helpers/PositionsMapper.js.map +1 -1
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/data-access/interfaces/TripRepositoryInterfaces.d.ts +12 -0
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/tasks/RefreshPublicCacheTask.d.ts +20 -0
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/tasks/RefreshPublicCacheTask.js +111 -0
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/tasks/RefreshPublicCacheTask.js.map +1 -0
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/transformations/PublicApiTripTransformation.d.ts +10 -0
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/transformations/PublicApiTripTransformation.js +34 -0
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/transformations/PublicApiTripTransformation.js.map +1 -0
- package/dist/output-gateway/index.js.map +1 -1
- package/dist/output-gateway/public/controllers/v1/IParams.d.ts +7 -0
- package/dist/output-gateway/public/controllers/v1/IParams.js +3 -0
- package/dist/output-gateway/public/controllers/v1/IParams.js.map +1 -0
- package/dist/output-gateway/public/controllers/v1/PublicVehiclePositionsController.d.ts +8 -0
- package/dist/output-gateway/public/controllers/v1/PublicVehiclePositionsController.js +47 -0
- package/dist/output-gateway/public/controllers/v1/PublicVehiclePositionsController.js.map +1 -0
- package/dist/output-gateway/public/data-access/redis/PublicVehiclePositionsRepository.d.ts +13 -0
- package/dist/output-gateway/public/data-access/redis/PublicVehiclePositionsRepository.js +68 -0
- package/dist/output-gateway/public/data-access/redis/PublicVehiclePositionsRepository.js.map +1 -0
- package/dist/output-gateway/public/domain/IBoudingBox.d.ts +15 -0
- package/dist/output-gateway/public/domain/IBoudingBox.js +3 -0
- package/dist/output-gateway/public/domain/IBoudingBox.js.map +1 -0
- package/dist/output-gateway/public/domain/const.d.ts +3 -0
- package/dist/output-gateway/public/domain/const.js +12 -0
- package/dist/output-gateway/public/domain/const.js.map +1 -0
- package/dist/output-gateway/public/domain/repository/IVehiclePositionsRepository.d.ts +6 -0
- package/dist/output-gateway/public/domain/repository/IVehiclePositionsRepository.js +3 -0
- package/dist/output-gateway/public/domain/repository/IVehiclePositionsRepository.js.map +1 -0
- package/dist/output-gateway/public/ioc/Di.d.ts +2 -0
- package/dist/output-gateway/public/ioc/Di.js +38 -0
- package/dist/output-gateway/public/ioc/Di.js.map +1 -0
- package/dist/output-gateway/public/ioc/OgModuleToken.d.ts +6 -0
- package/dist/output-gateway/public/ioc/OgModuleToken.js +10 -0
- package/dist/output-gateway/public/ioc/OgModuleToken.js.map +1 -0
- package/dist/output-gateway/public/routers/v1/PublicRouter.d.ts +12 -0
- package/dist/output-gateway/public/routers/v1/PublicRouter.js +37 -0
- package/dist/output-gateway/public/routers/v1/PublicRouter.js.map +1 -0
- package/dist/output-gateway/public/service/VPSubscriber.d.ts +7 -0
- package/dist/output-gateway/public/service/VPSubscriber.js +33 -0
- package/dist/output-gateway/public/service/VPSubscriber.js.map +1 -0
- package/dist/output-gateway/public/service/facade/VehiclePositionsFacade.d.ts +13 -0
- package/dist/output-gateway/public/service/facade/VehiclePositionsFacade.js +42 -0
- package/dist/output-gateway/public/service/facade/VehiclePositionsFacade.js.map +1 -0
- package/dist/output-gateway/public/service/helpers/BoundingBoxHelper.d.ts +5 -0
- package/dist/output-gateway/public/service/helpers/BoundingBoxHelper.js +22 -0
- package/dist/output-gateway/public/service/helpers/BoundingBoxHelper.js.map +1 -0
- package/dist/output-gateway/public/service/transformations/PublicVehiclePositionsTransformation.d.ts +7 -0
- package/dist/output-gateway/public/service/transformations/PublicVehiclePositionsTransformation.js +18 -0
- package/dist/output-gateway/public/service/transformations/PublicVehiclePositionsTransformation.js.map +1 -0
- package/dist/schema-definitions/vehicle-positions/redis/const.d.ts +1 -0
- package/dist/schema-definitions/vehicle-positions/redis/const.js +5 -0
- package/dist/schema-definitions/vehicle-positions/redis/const.js.map +1 -0
- package/dist/schema-definitions/vehicle-positions/redis/interfaces/IPublicApiCacheDto.d.ts +12 -0
- package/dist/schema-definitions/vehicle-positions/redis/interfaces/IPublicApiCacheDto.js +3 -0
- package/dist/schema-definitions/vehicle-positions/redis/interfaces/IPublicApiCacheDto.js.map +1 -0
- package/dist/schema-definitions/vehicle-positions/redis/schemas/PublicApiCacheDtoSchema.d.ts +4 -0
- package/dist/schema-definitions/vehicle-positions/redis/schemas/PublicApiCacheDtoSchema.js +69 -0
- package/dist/schema-definitions/vehicle-positions/redis/schemas/PublicApiCacheDtoSchema.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IPublicApiCacheDto } from "../../../../../schema-definitions/vehicle-positions/redis/interfaces/IPublicApiCacheDto";
|
|
2
|
+
import { AbstractTransformation } from "@golemio/core/dist/helpers/transformation/AbstractTransformation";
|
|
3
|
+
import { IEnrichedTripForPublicApi } from "../data-access/interfaces/TripRepositoryInterfaces";
|
|
4
|
+
type TransformIn = IEnrichedTripForPublicApi;
|
|
5
|
+
type TransformOut = IPublicApiCacheDto;
|
|
6
|
+
export declare class PublicApiTripTransformation extends AbstractTransformation<TransformIn, TransformOut> {
|
|
7
|
+
name: string;
|
|
8
|
+
protected transformInternal: (data: TransformIn) => TransformOut;
|
|
9
|
+
}
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.PublicApiTripTransformation = void 0;
|
|
10
|
+
const AbstractTransformation_1 = require("@golemio/core/dist/helpers/transformation/AbstractTransformation");
|
|
11
|
+
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
|
|
12
|
+
let PublicApiTripTransformation = exports.PublicApiTripTransformation = class PublicApiTripTransformation extends AbstractTransformation_1.AbstractTransformation {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
15
|
+
this.name = "PublicApiTripTransformation";
|
|
16
|
+
this.transformInternal = (data) => {
|
|
17
|
+
return {
|
|
18
|
+
gtfs_trip_id: data.gtfs_trip_id,
|
|
19
|
+
gtfs_route_type: data.gtfs_route_type,
|
|
20
|
+
gtfs_route_short_name: data.gtfs_route_short_name,
|
|
21
|
+
run_number: data.run_number,
|
|
22
|
+
vehicle_registration_number: data.vehicle_registration_number,
|
|
23
|
+
lat: Number.parseFloat(data.lat),
|
|
24
|
+
lng: Number.parseFloat(data.lng),
|
|
25
|
+
bearing: data.bearing,
|
|
26
|
+
delay: data.delay,
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.PublicApiTripTransformation = PublicApiTripTransformation = __decorate([
|
|
32
|
+
(0, tsyringe_1.injectable)()
|
|
33
|
+
], PublicApiTripTransformation);
|
|
34
|
+
//# sourceMappingURL=PublicApiTripTransformation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PublicApiTripTransformation.js","sourceRoot":"","sources":["../../../../../../src/integration-engine/vehicle-positions/workers/vehicle-positions/transformations/PublicApiTripTransformation.ts"],"names":[],"mappings":";;;;;;;;;AACA,6GAA0G;AAC1G,iEAAgE;AAOzD,IAAM,2BAA2B,yCAAjC,MAAM,2BAA4B,SAAQ,+CAAiD;IAA3F;;QACI,SAAI,GAAG,6BAA6B,CAAC;QAElC,sBAAiB,GAAG,CAAC,IAAiB,EAAgB,EAAE;YAC9D,OAAO;gBACH,YAAY,EAAE,IAAI,CAAC,YAAY;gBAC/B,eAAe,EAAE,IAAI,CAAC,eAAe;gBACrC,qBAAqB,EAAE,IAAI,CAAC,qBAAqB;gBACjD,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,2BAA2B,EAAE,IAAI,CAAC,2BAA2B;gBAC7D,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC;gBAChC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC;gBAChC,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,KAAK,EAAE,IAAI,CAAC,KAAK;aACpB,CAAC;QACN,CAAC,CAAC;IACN,CAAC;CAAA,CAAA;sCAhBY,2BAA2B;IADvC,IAAA,qBAAU,GAAE;GACA,2BAA2B,CAgBvC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/output-gateway/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/output-gateway/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,sEAAsD;AACtD,6CAA6B;AAC7B,0DAA0C;AAC1C,wEAAwD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { GTFSRouteTypeEnum } from "../../../../helpers/RouteTypeEnums";
|
|
2
|
+
import { IBoundingBox } from "../../domain/IBoudingBox";
|
|
3
|
+
export interface IParams {
|
|
4
|
+
boundingBox: IBoundingBox;
|
|
5
|
+
routeShortName: string | undefined;
|
|
6
|
+
type: GTFSRouteTypeEnum | undefined;
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IParams.js","sourceRoot":"","sources":["../../../../../src/output-gateway/public/controllers/v1/IParams.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { NextFunction, Request, Response } from "@golemio/core/dist/shared/express";
|
|
2
|
+
import { ParsedQs } from "qs";
|
|
3
|
+
import { IParams } from "./IParams";
|
|
4
|
+
export declare class PublicVehiclePositionsController {
|
|
5
|
+
constructor();
|
|
6
|
+
getAll: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
7
|
+
parseParams(query: ParsedQs): IParams;
|
|
8
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PublicVehiclePositionsController = void 0;
|
|
13
|
+
const const_1 = require("../../domain/const");
|
|
14
|
+
const Di_1 = require("../../ioc/Di");
|
|
15
|
+
const OgModuleToken_1 = require("../../ioc/OgModuleToken");
|
|
16
|
+
const RouteTypeEnums_1 = require("../../../../helpers/RouteTypeEnums");
|
|
17
|
+
class PublicVehiclePositionsController {
|
|
18
|
+
constructor() {
|
|
19
|
+
this.getAll = (req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
try {
|
|
21
|
+
const facade = Di_1.OgPublicContainer.resolve(OgModuleToken_1.OgModuleToken.PublicVehiclePositionsFacade);
|
|
22
|
+
const params = this.parseParams(req.query);
|
|
23
|
+
const result = yield facade.getAll(params.boundingBox, params.routeShortName, params.type);
|
|
24
|
+
res.json(result);
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
next(err);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
parseParams(query) {
|
|
32
|
+
const boundingBox = query.boundingBox ? query.boundingBox.split(",").map((x) => parseFloat(x)) : undefined;
|
|
33
|
+
// format "topLeft.lat,topLeft.lon,bottomRight.lat,bottomRight.lon"
|
|
34
|
+
return {
|
|
35
|
+
boundingBox: {
|
|
36
|
+
topLeftLongitude: boundingBox ? boundingBox[1] : const_1.DEFAULT_BOUDINGBOX.topLeftLongitude,
|
|
37
|
+
topLeftLatitude: boundingBox ? boundingBox[0] : const_1.DEFAULT_BOUDINGBOX.topLeftLatitude,
|
|
38
|
+
bottomRightLongitude: boundingBox ? boundingBox[3] : const_1.DEFAULT_BOUDINGBOX.bottomRightLongitude,
|
|
39
|
+
bottomRightLatitude: boundingBox ? boundingBox[2] : const_1.DEFAULT_BOUDINGBOX.bottomRightLatitude,
|
|
40
|
+
},
|
|
41
|
+
routeShortName: query.routeShortName ? query.routeShortName : undefined,
|
|
42
|
+
type: query.type ? (0, RouteTypeEnums_1.getGtfsRouteType)(query.type) : undefined,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.PublicVehiclePositionsController = PublicVehiclePositionsController;
|
|
47
|
+
//# sourceMappingURL=PublicVehiclePositionsController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PublicVehiclePositionsController.js","sourceRoot":"","sources":["../../../../../src/output-gateway/public/controllers/v1/PublicVehiclePositionsController.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAA6D;AAC7D,qCAAsD;AACtD,2DAA6D;AAK7D,uEAA2D;AAE3D,MAAa,gCAAgC;IACzC;QAEO,WAAM,GAAG,CAAO,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAE,EAAE;YACtE,IAAI;gBACA,MAAM,MAAM,GAAG,sBAAiB,CAAC,OAAO,CAA+B,6BAAa,CAAC,4BAA4B,CAAC,CAAC;gBACnH,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,CAAC,CAAC,IAAA,iCAAgB,EAAC,KAAK,CAAC,IAAc,CAAC,CAAC,CAAC,CAAC,SAAS;SACxE,CAAC;IACN,CAAC;CACJ;AA7BD,4EA6BC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IBoundingBoxWithCenter } from "../../domain/IBoudingBox";
|
|
2
|
+
import { IVehiclePositionsRepository } from "../../domain/repository/IVehiclePositionsRepository";
|
|
3
|
+
import { IPublicApiCacheDto } from "../../../../schema-definitions/vehicle-positions/redis/interfaces/IPublicApiCacheDto";
|
|
4
|
+
import { IoRedisConnector } from "@golemio/core/dist/helpers/data-access/redis/IoRedisConnector";
|
|
5
|
+
import { ILogger } from "@golemio/core/dist/helpers/logger/LoggerProvider";
|
|
6
|
+
export declare class PublicVehiclePositionsRepository implements IVehiclePositionsRepository {
|
|
7
|
+
private redisConnector;
|
|
8
|
+
private log;
|
|
9
|
+
private setName;
|
|
10
|
+
constructor(redisConnector: IoRedisConnector, log: ILogger);
|
|
11
|
+
getAllVehiclePositions(boundingBox: IBoundingBoxWithCenter): Promise<IPublicApiCacheDto[]>;
|
|
12
|
+
setCurrentSetName(name: string): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.PublicVehiclePositionsRepository = void 0;
|
|
25
|
+
const OgModuleToken_1 = require("../../ioc/OgModuleToken");
|
|
26
|
+
const IoRedisConnector_1 = require("@golemio/core/dist/helpers/data-access/redis/IoRedisConnector");
|
|
27
|
+
const CoreToken_1 = require("@golemio/core/dist/helpers/ioc/CoreToken");
|
|
28
|
+
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
|
|
29
|
+
let PublicVehiclePositionsRepository = exports.PublicVehiclePositionsRepository = class PublicVehiclePositionsRepository {
|
|
30
|
+
constructor(redisConnector, log) {
|
|
31
|
+
this.redisConnector = redisConnector;
|
|
32
|
+
this.log = log;
|
|
33
|
+
this.setName = undefined; // loaded via pub sub
|
|
34
|
+
}
|
|
35
|
+
getAllVehiclePositions(boundingBox) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
if (!this.setName) {
|
|
38
|
+
this.log.debug("Empty setName for public vehicle positions api.");
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
if (!this.redisConnector.isConnected()) {
|
|
42
|
+
yield this.redisConnector.connect();
|
|
43
|
+
}
|
|
44
|
+
const connection = this.redisConnector.getConnection();
|
|
45
|
+
const vehiclePositions = yield connection.geosearch(this.setName, "FROMLONLAT", boundingBox.centerPoint.longitude, boundingBox.centerPoint.latitude, "BYBOX", boundingBox.width, boundingBox.height, "m", "ASC");
|
|
46
|
+
return vehiclePositions.map((el) => {
|
|
47
|
+
try {
|
|
48
|
+
return JSON.parse(el);
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
this.log.error(err);
|
|
52
|
+
this.log.error(`Cannot parse ${el}`);
|
|
53
|
+
return {};
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
setCurrentSetName(name) {
|
|
59
|
+
this.setName = name;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
exports.PublicVehiclePositionsRepository = PublicVehiclePositionsRepository = __decorate([
|
|
63
|
+
(0, tsyringe_1.injectable)(),
|
|
64
|
+
__param(0, (0, tsyringe_1.inject)(OgModuleToken_1.OgModuleToken.RedisConnector)),
|
|
65
|
+
__param(1, (0, tsyringe_1.inject)(CoreToken_1.CoreToken.Logger)),
|
|
66
|
+
__metadata("design:paramtypes", [IoRedisConnector_1.IoRedisConnector, Object])
|
|
67
|
+
], PublicVehiclePositionsRepository);
|
|
68
|
+
//# sourceMappingURL=PublicVehiclePositionsRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PublicVehiclePositionsRepository.js","sourceRoot":"","sources":["../../../../../src/output-gateway/public/data-access/redis/PublicVehiclePositionsRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAEA,2DAA6D;AAE7D,oGAAiG;AACjG,wEAAqE;AAErE,iEAAwE;AAGjE,IAAM,gCAAgC,8CAAtC,MAAM,gCAAgC;IAGzC,YAC0C,cAAwC,EACpD,GAAoB;QADA,mBAA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AA,IAAA,iBAAM,EAAC,6BAAa,CAAC,cAAc,CAAC,CAAA;IACpC,WAAA,IAAA,iBAAM,EAAC,qBAAS,CAAC,MAAM,CAAC,CAAA;qCADqC,mCAAgB;GAJzE,gCAAgC,CA6C5C"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface IBoundingBox {
|
|
2
|
+
topLeftLongitude: number;
|
|
3
|
+
topLeftLatitude: number;
|
|
4
|
+
bottomRightLongitude: number;
|
|
5
|
+
bottomRightLatitude: number;
|
|
6
|
+
}
|
|
7
|
+
export interface IBoundingBoxWithCenter {
|
|
8
|
+
centerPoint: IPoint;
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
}
|
|
12
|
+
export interface IPoint {
|
|
13
|
+
longitude: number;
|
|
14
|
+
latitude: number;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IBoudingBox.js","sourceRoot":"","sources":["../../../../src/output-gateway/public/domain/IBoudingBox.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_BOUDINGBOX = exports.APP_NAME = void 0;
|
|
4
|
+
exports.APP_NAME = "vp-litacka-api";
|
|
5
|
+
// currently bb around whole czechia
|
|
6
|
+
exports.DEFAULT_BOUDINGBOX = {
|
|
7
|
+
topLeftLongitude: 12.04,
|
|
8
|
+
topLeftLatitude: 51.05,
|
|
9
|
+
bottomRightLongitude: 19.01,
|
|
10
|
+
bottomRightLatitude: 48.54,
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=const.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"const.js","sourceRoot":"","sources":["../../../../src/output-gateway/public/domain/const.ts"],"names":[],"mappings":";;;AAEa,QAAA,QAAQ,GAAG,gBAAgB,CAAC;AAEzC,oCAAoC;AACvB,QAAA,kBAAkB,GAAiB;IAC5C,gBAAgB,EAAE,KAAK;IACvB,eAAe,EAAE,KAAK;IACtB,oBAAoB,EAAE,KAAK;IAC3B,mBAAmB,EAAE,KAAK;CAC7B,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IPublicApiCacheDto } from "../../../../schema-definitions/vehicle-positions/redis/interfaces/IPublicApiCacheDto";
|
|
2
|
+
import { IBoundingBoxWithCenter } from "../IBoudingBox";
|
|
3
|
+
export interface IVehiclePositionsRepository {
|
|
4
|
+
getAllVehiclePositions(boundingBox: IBoundingBoxWithCenter): Promise<IPublicApiCacheDto[]>;
|
|
5
|
+
setCurrentSetName(name: string): void;
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IVehiclePositionsRepository.js","sourceRoot":"","sources":["../../../../../src/output-gateway/public/domain/repository/IVehiclePositionsRepository.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OgPublicContainer = void 0;
|
|
4
|
+
const const_1 = require("../../../schema-definitions/vehicle-positions/redis/const");
|
|
5
|
+
const IoRedisConnector_1 = require("@golemio/core/dist/helpers/data-access/redis/IoRedisConnector");
|
|
6
|
+
const CoreToken_1 = require("@golemio/core/dist/helpers/ioc/CoreToken");
|
|
7
|
+
const Di_1 = require("@golemio/core/dist/output-gateway/ioc/Di");
|
|
8
|
+
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
|
|
9
|
+
const PublicVehiclePositionsRepository_1 = require("../data-access/redis/PublicVehiclePositionsRepository");
|
|
10
|
+
const VPSubscriber_1 = require("../service/VPSubscriber");
|
|
11
|
+
const VehiclePositionsFacade_1 = require("../service/facade/VehiclePositionsFacade");
|
|
12
|
+
const OgModuleToken_1 = require("./OgModuleToken");
|
|
13
|
+
const ogPublicContainer = Di_1.OutputGatewayContainer.createChildContainer();
|
|
14
|
+
exports.OgPublicContainer = ogPublicContainer;
|
|
15
|
+
ogPublicContainer.register(OgModuleToken_1.OgModuleToken.RedisConnector, {
|
|
16
|
+
useFactory: (0, tsyringe_1.instanceCachingFactory)((c) => {
|
|
17
|
+
const config = c.resolve(CoreToken_1.CoreToken.SimpleConfig);
|
|
18
|
+
return new IoRedisConnector_1.IoRedisConnector(config.getValue("env.REDIS_CONN"), c.resolve(CoreToken_1.CoreToken.Logger));
|
|
19
|
+
}),
|
|
20
|
+
});
|
|
21
|
+
ogPublicContainer.registerSingleton(OgModuleToken_1.OgModuleToken.PublicVehiclePositionsRepository, PublicVehiclePositionsRepository_1.PublicVehiclePositionsRepository);
|
|
22
|
+
ogPublicContainer.register(OgModuleToken_1.OgModuleToken.PublicVehiclePositionsFacade, {
|
|
23
|
+
useFactory: (0, tsyringe_1.instanceCachingFactory)((c) => {
|
|
24
|
+
return new VehiclePositionsFacade_1.PublicVehiclePositionsFacade(c.resolve(OgModuleToken_1.OgModuleToken.PublicVehiclePositionsRepository), c.resolve(CoreToken_1.CoreToken.Logger));
|
|
25
|
+
}),
|
|
26
|
+
});
|
|
27
|
+
ogPublicContainer.register(OgModuleToken_1.OgModuleToken.VPSubscriber, {
|
|
28
|
+
useFactory: (0, tsyringe_1.instanceCachingFactory)((c) => {
|
|
29
|
+
const config = c.resolve(CoreToken_1.CoreToken.SimpleConfig);
|
|
30
|
+
const logger = c.resolve(CoreToken_1.CoreToken.Logger);
|
|
31
|
+
return new VPSubscriber_1.VPSubscriber({
|
|
32
|
+
channelName: const_1.PUBLIC_CACHE_NAMESPACE_PREFIX,
|
|
33
|
+
redisConnectionString: config.getValue("env.REDIS_CONN"),
|
|
34
|
+
logger: logger,
|
|
35
|
+
}, c.resolve(OgModuleToken_1.OgModuleToken.PublicVehiclePositionsRepository));
|
|
36
|
+
}),
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=Di.js.map
|
|
@@ -0,0 +1 @@
|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CAAC,OAAO,CAAgB,qBAAS,CAAC,YAAY,CAAC,CAAC;QAChE,MAAM,MAAM,GAAG,CAAC,CAAC,OAAO,CAAU,qBAAS,CAAC,MAAM,CAAC,CAAC;QAEpD,OAAO,IAAI,2BAAY,CACnB;YACI,WAAW,EAAE,qCAA6B;YAC1C,qBAAqB,EAAE,MAAM,CAAC,QAAQ,CAAS,gBAAgB,CAAC;YAChE,MAAM,EAAE,MAAM;SACjB,EACD,CAAC,CAAC,OAAO,CAA8B,6BAAa,CAAC,gCAAgC,CAAC,CACzF,CAAC;IACN,CAAC,CAAC;CACL,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OgModuleToken = void 0;
|
|
4
|
+
exports.OgModuleToken = {
|
|
5
|
+
RedisConnector: Symbol(),
|
|
6
|
+
PublicVehiclePositionsRepository: Symbol(),
|
|
7
|
+
PublicVehiclePositionsFacade: Symbol(),
|
|
8
|
+
VPSubscriber: Symbol(),
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=OgModuleToken.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OgModuleToken.js","sourceRoot":"","sources":["../../../../src/output-gateway/public/ioc/OgModuleToken.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG;IACzB,cAAc,EAAE,MAAM,EAAE;IACxB,gCAAgC,EAAE,MAAM,EAAE;IAC1C,4BAA4B,EAAE,MAAM,EAAE;IACtC,YAAY,EAAE,MAAM,EAAE;CACzB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="express" />
|
|
2
|
+
import { Router } from "@golemio/core/dist/shared/express";
|
|
3
|
+
export declare class PublicRouter {
|
|
4
|
+
router: Router;
|
|
5
|
+
private controller;
|
|
6
|
+
private redisSubscriber;
|
|
7
|
+
private supportedTypes;
|
|
8
|
+
constructor();
|
|
9
|
+
protected initRoutes(expire?: string | number | undefined): void;
|
|
10
|
+
}
|
|
11
|
+
declare const v1PublicRouter: Router;
|
|
12
|
+
export { v1PublicRouter };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.v1PublicRouter = exports.PublicRouter = void 0;
|
|
4
|
+
const RouteTypeEnums_1 = require("../../../../helpers/RouteTypeEnums");
|
|
5
|
+
const PublicVehiclePositionsController_1 = require("../../controllers/v1/PublicVehiclePositionsController");
|
|
6
|
+
const Di_1 = require("../../ioc/Di");
|
|
7
|
+
const OgModuleToken_1 = require("../../ioc/OgModuleToken");
|
|
8
|
+
const Validation_1 = require("@golemio/core/dist/output-gateway/Validation");
|
|
9
|
+
const express_1 = require("@golemio/core/dist/shared/express");
|
|
10
|
+
const express_validator_1 = require("@golemio/core/dist/shared/express-validator");
|
|
11
|
+
class PublicRouter {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.router = (0, express_1.Router)();
|
|
14
|
+
this.controller = new PublicVehiclePositionsController_1.PublicVehiclePositionsController();
|
|
15
|
+
this.initRoutes();
|
|
16
|
+
this.redisSubscriber = Di_1.OgPublicContainer.resolve(OgModuleToken_1.OgModuleToken.VPSubscriber);
|
|
17
|
+
this.redisSubscriber.initialize();
|
|
18
|
+
this.supportedTypes = (0, RouteTypeEnums_1.getGtfsRouteTypesAsStrings)();
|
|
19
|
+
}
|
|
20
|
+
initRoutes(expire) {
|
|
21
|
+
this.router.get("/vehiclepositions", [
|
|
22
|
+
(0, express_validator_1.query)("boundingBox")
|
|
23
|
+
.optional()
|
|
24
|
+
.isString()
|
|
25
|
+
.matches(/^\d+\.?\d*(,\d+\.?\d*){3}$/),
|
|
26
|
+
(0, express_validator_1.query)("routeShortName").optional().isString(),
|
|
27
|
+
(0, express_validator_1.oneOf)([
|
|
28
|
+
[(0, express_validator_1.query)("type").optional().isArray(), (0, express_validator_1.query)("type.*").optional().isString().isIn(this.supportedTypes)],
|
|
29
|
+
(0, express_validator_1.query)("type").optional().isString().isIn(this.supportedTypes),
|
|
30
|
+
]),
|
|
31
|
+
], Validation_1.checkErrors, this.controller.getAll);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.PublicRouter = PublicRouter;
|
|
35
|
+
const v1PublicRouter = new PublicRouter().router;
|
|
36
|
+
exports.v1PublicRouter = v1PublicRouter;
|
|
37
|
+
//# sourceMappingURL=PublicRouter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PublicRouter.js","sourceRoot":"","sources":["../../../../../src/output-gateway/public/routers/v1/PublicRouter.ts"],"names":[],"mappings":";;;AAAA,uEAAqE;AACrE,4GAA8G;AAC9G,qCAAsD;AACtD,2DAA6D;AAE7D,6EAA2E;AAC3E,+DAA2D;AAC3D,mFAA2E;AAE3E,MAAa,YAAY;IAMrB;QACI,IAAI,CAAC,MAAM,GAAG,IAAA,gBAAM,GAAE,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,IAAI,mEAAgC,EAAE,CAAC;QACzD,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,eAAe,GAAG,sBAAiB,CAAC,OAAO,CAAe,6BAAa,CAAC,YAAY,CAAC,CAAC;QAC3F,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,CAAC;QAClC,IAAI,CAAC,cAAc,GAAG,IAAA,2CAA0B,GAAE,CAAC;IACvD,CAAC;IAES,UAAU,CAAC,MAAoC;QACrD,IAAI,CAAC,MAAM,CAAC,GAAG,CACX,mBAAmB,EACnB;YACI,IAAA,yBAAK,EAAC,aAAa,CAAC;iBACf,QAAQ,EAAE;iBACV,QAAQ,EAAE;iBACV,OAAO,CAAC,4BAA4B,CAAC;YAC1C,IAAA,yBAAK,EAAC,gBAAgB,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;YAC7C,IAAA,yBAAK,EAAC;gBACF,CAAC,IAAA,yBAAK,EAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,EAAE,IAAA,yBAAK,EAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;gBACrG,IAAA,yBAAK,EAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC;aAChE,CAAC;SACL,EACD,wBAAW,EACX,IAAI,CAAC,UAAU,CAAC,MAAM,CACzB,CAAC;IACN,CAAC;CACJ;AAjCD,oCAiCC;AAED,MAAM,cAAc,GAAG,IAAI,YAAY,EAAE,CAAC,MAAM,CAAC;AAExC,wCAAc"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ISubscriberOptions, RedisSubscriber } from "@golemio/core/dist/helpers/data-access/pubsub/subscribers/RedisSubscriber";
|
|
2
|
+
import { IVehiclePositionsRepository } from "../domain/repository/IVehiclePositionsRepository";
|
|
3
|
+
export declare class VPSubscriber extends RedisSubscriber {
|
|
4
|
+
private repository;
|
|
5
|
+
constructor(options: ISubscriberOptions, repository: IVehiclePositionsRepository);
|
|
6
|
+
initialize(): Promise<void>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.VPSubscriber = void 0;
|
|
13
|
+
const RedisSubscriber_1 = require("@golemio/core/dist/helpers/data-access/pubsub/subscribers/RedisSubscriber");
|
|
14
|
+
class VPSubscriber extends RedisSubscriber_1.RedisSubscriber {
|
|
15
|
+
constructor(options, repository) {
|
|
16
|
+
super(options);
|
|
17
|
+
this.repository = repository;
|
|
18
|
+
}
|
|
19
|
+
initialize() {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
yield this.subscribe();
|
|
22
|
+
this.logger.debug("Redis subscriber subscribed to channel for Public API.");
|
|
23
|
+
this.listen((message) => {
|
|
24
|
+
this.logger.debug("Redis subscriber received a message to change repository source.");
|
|
25
|
+
if (message !== undefined) {
|
|
26
|
+
this.repository.setCurrentSetName(message);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.VPSubscriber = VPSubscriber;
|
|
33
|
+
//# sourceMappingURL=VPSubscriber.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VPSubscriber.js","sourceRoot":"","sources":["../../../../src/output-gateway/public/service/VPSubscriber.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+GAAgI;AAGhI,MAAa,YAAa,SAAQ,iCAAe;IAC7C,YAAY,OAA2B,EAAU,UAAuC;QACpF,KAAK,CAAC,OAAO,CAAC,CAAC;QAD8B,eAAU,GAAV,UAAU,CAA6B;IAExF,CAAC;IAEY,UAAU;;YACnB,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;YAEvB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,wDAAwD,CAAC,CAAC;YAC5E,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE;gBACpB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,kEAAkE,CAAC,CAAC;gBACtF,IAAI,OAAO,KAAK,SAAS,EAAE;oBACvB,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;iBAC9C;YACL,CAAC,CAAC,CAAC;QACP,CAAC;KAAA;CACJ;AAhBD,oCAgBC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { GTFSRouteTypeEnum } from "../../../../helpers/RouteTypeEnums";
|
|
2
|
+
import { IBoundingBox } from "../../domain/IBoudingBox";
|
|
3
|
+
import { IVehiclePositionsRepository } from "../../domain/repository/IVehiclePositionsRepository";
|
|
4
|
+
import { ILogger } from "@golemio/core/dist/helpers/logger/LoggerProvider";
|
|
5
|
+
import { IGeoJSONFeatureCollection } from "@golemio/core/dist/output-gateway";
|
|
6
|
+
export declare class PublicVehiclePositionsFacade {
|
|
7
|
+
private repository;
|
|
8
|
+
private log;
|
|
9
|
+
private transformation;
|
|
10
|
+
constructor(repository: IVehiclePositionsRepository, log: ILogger);
|
|
11
|
+
getAll(boundingBox: IBoundingBox, routeShortName: string | undefined, type: GTFSRouteTypeEnum | undefined): Promise<IGeoJSONFeatureCollection>;
|
|
12
|
+
private filterClientSide;
|
|
13
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PublicVehiclePositionsFacade = void 0;
|
|
13
|
+
const output_gateway_1 = require("@golemio/core/dist/output-gateway");
|
|
14
|
+
const BoundingBoxHelper_1 = require("../helpers/BoundingBoxHelper");
|
|
15
|
+
const PublicVehiclePositionsTransformation_1 = require("../transformations/PublicVehiclePositionsTransformation");
|
|
16
|
+
class PublicVehiclePositionsFacade {
|
|
17
|
+
constructor(repository, log) {
|
|
18
|
+
this.repository = repository;
|
|
19
|
+
this.log = log;
|
|
20
|
+
this.transformation = new PublicVehiclePositionsTransformation_1.PublicVehiclePositionsTransformation();
|
|
21
|
+
}
|
|
22
|
+
getAll(boundingBox, routeShortName, type) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const boundingBoxWithCenter = BoundingBoxHelper_1.BoundingBoxHelper.mapToCenterFormat(boundingBox);
|
|
25
|
+
this.log.debug(`width: ${boundingBoxWithCenter.width}m, height: ${boundingBoxWithCenter.height}m`);
|
|
26
|
+
const vehiclePositions = yield this.repository.getAllVehiclePositions(boundingBoxWithCenter);
|
|
27
|
+
const filteredResults = vehiclePositions.filter((el) => this.filterClientSide(el, routeShortName, type));
|
|
28
|
+
return (0, output_gateway_1.buildGeojsonFeatureCollection)(this.transformation.transformArray(filteredResults));
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
filterClientSide(el, routeShortName, type) {
|
|
32
|
+
if (routeShortName && el.gtfs_route_short_name !== routeShortName) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
if (type && el.gtfs_route_type !== type) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.PublicVehiclePositionsFacade = PublicVehiclePositionsFacade;
|
|
42
|
+
//# sourceMappingURL=VehiclePositionsFacade.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VehiclePositions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-0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.BoundingBoxHelper = void 0;
|
|
7
|
+
const cheap_ruler_1 = __importDefault(require("cheap-ruler"));
|
|
8
|
+
class BoundingBoxHelper {
|
|
9
|
+
static mapToCenterFormat(boundingBox) {
|
|
10
|
+
const centerPoint = {
|
|
11
|
+
longitude: (boundingBox.bottomRightLongitude + boundingBox.topLeftLongitude) / 2,
|
|
12
|
+
latitude: (boundingBox.bottomRightLatitude + boundingBox.topLeftLatitude) / 2,
|
|
13
|
+
};
|
|
14
|
+
// Calculate the width and height in meters
|
|
15
|
+
const width = this.ruler.distance([boundingBox.topLeftLongitude, boundingBox.topLeftLatitude], [boundingBox.bottomRightLongitude, boundingBox.topLeftLatitude]);
|
|
16
|
+
const height = this.ruler.distance([boundingBox.topLeftLongitude, boundingBox.topLeftLatitude], [boundingBox.topLeftLongitude, boundingBox.bottomRightLatitude]);
|
|
17
|
+
return { centerPoint, width, height };
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.BoundingBoxHelper = BoundingBoxHelper;
|
|
21
|
+
BoundingBoxHelper.ruler = (0, cheap_ruler_1.default)(50, "meters");
|
|
22
|
+
//# sourceMappingURL=BoundingBoxHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BoundingBoxHelper.js","sourceRoot":"","sources":["../../../../../src/output-gateway/public/service/helpers/BoundingBoxHelper.ts"],"names":[],"mappings":";;;;;;AACA,8DAAqC;AAErC,MAAa,iBAAiB;IAGnB,MAAM,CAAC,iBAAiB,CAAC,WAAyB;QACrD,MAAM,WAAW,GAAG;YAChB,SAAS,EAAE,CAAC,WAAW,CAAC,oBAAoB,GAAG,WAAW,CAAC,gBAAgB,CAAC,GAAG,CAAC;YAChF,QAAQ,EAAE,CAAC,WAAW,CAAC,mBAAmB,GAAG,WAAW,CAAC,eAAe,CAAC,GAAG,CAAC;SAChF,CAAC;QACF,2CAA2C;QAC3C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAC7B,CAAC,WAAW,CAAC,gBAAgB,EAAE,WAAW,CAAC,eAAe,CAAC,EAC3D,CAAC,WAAW,CAAC,oBAAoB,EAAE,WAAW,CAAC,eAAe,CAAC,CAClE,CAAC;QACF,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAC9B,CAAC,WAAW,CAAC,gBAAgB,EAAE,WAAW,CAAC,eAAe,CAAC,EAC3D,CAAC,WAAW,CAAC,gBAAgB,EAAE,WAAW,CAAC,mBAAmB,CAAC,CAClE,CAAC;QAEF,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAC1C,CAAC;;AAnBL,8CAoBC;AAnBkB,uBAAK,GAAG,IAAA,qBAAU,EAAC,EAAE,EAAE,QAAQ,CAAC,CAAC"}
|
package/dist/output-gateway/public/service/transformations/PublicVehiclePositionsTransformation.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IPublicApiCacheDto } from "../../../../schema-definitions/vehicle-positions/redis/interfaces/IPublicApiCacheDto";
|
|
2
|
+
import { AbstractTransformation } from "@golemio/core/dist/helpers/transformation/AbstractTransformation";
|
|
3
|
+
import { IGeoJSONFeature } from "@golemio/core/dist/output-gateway/Geo";
|
|
4
|
+
export declare class PublicVehiclePositionsTransformation extends AbstractTransformation<IPublicApiCacheDto, IGeoJSONFeature> {
|
|
5
|
+
name: string;
|
|
6
|
+
protected transformInternal: (element: IPublicApiCacheDto) => IGeoJSONFeature;
|
|
7
|
+
}
|
package/dist/output-gateway/public/service/transformations/PublicVehiclePositionsTransformation.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PublicVehiclePositionsTransformation = void 0;
|
|
4
|
+
const RouteTypeEnums_1 = require("../../../../helpers/RouteTypeEnums");
|
|
5
|
+
const AbstractTransformation_1 = require("@golemio/core/dist/helpers/transformation/AbstractTransformation");
|
|
6
|
+
const Geo_1 = require("@golemio/core/dist/output-gateway/Geo");
|
|
7
|
+
class PublicVehiclePositionsTransformation extends AbstractTransformation_1.AbstractTransformation {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.name = "OutputDtoTransformation";
|
|
11
|
+
this.transformInternal = (element) => {
|
|
12
|
+
var _a;
|
|
13
|
+
return (0, Geo_1.buildGeojsonFeature)(Object.assign(Object.assign({}, element), { gtfs_route_type: ((_a = RouteTypeEnums_1.GTFSRouteTypeEnum[element.gtfs_route_type]) !== null && _a !== void 0 ? _a : RouteTypeEnums_1.GTFSRouteTypeEnum[1700]).toLowerCase() }), "lng", "lat", true);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.PublicVehiclePositionsTransformation = PublicVehiclePositionsTransformation;
|
|
18
|
+
//# sourceMappingURL=PublicVehiclePositionsTransformation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PublicVehiclePositionsTransformation.js","sourceRoot":"","sources":["../../../../../src/output-gateway/public/service/transformations/PublicVehiclePositionsTransformation.ts"],"names":[],"mappings":";;;AAAA,uEAA4D;AAE5D,6GAA0G;AAC1G,+DAA6F;AAE7F,MAAa,oCAAqC,SAAQ,+CAA2D;IAArH;;QACW,SAAI,GAAW,yBAAyB,CAAC;QAEtC,sBAAiB,GAAG,CAAC,OAA2B,EAAE,EAAE;;YAC1D,OAAO,IAAA,yBAAmB,kCAEf,OAAO,KACV,eAAe,EAAE,CAAC,MAAA,kCAAiB,CAAC,OAAO,CAAC,eAAe,CAAC,mCAAI,kCAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,EAAE,KAE1G,KAAK,EACL,KAAK,EACL,IAAI,CACP,CAAC;QACN,CAAC,CAAC;IACN,CAAC;CAAA;AAdD,oFAcC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PUBLIC_CACHE_NAMESPACE_PREFIX = "vpPublicCache";
|