@golemio/pid 2.12.10-dev.1265906013 → 2.12.10-dev.1267493459
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/15_vehicle_descriptors.sql +3 -3
- package/db/example/redis/publicDepartureBoardsMock.json +13 -0
- package/db/example/redis/publicVehiclePositionsMock.json +24 -0
- package/db/migrations/postgresql/20240424122841-delay-at-past-stops-release-part-1.js +53 -0
- package/db/migrations/postgresql/sqls/20240424122841-delay-at-past-stops-release-part-1-down.sql +1 -0
- package/db/migrations/postgresql/sqls/20240424122841-delay-at-past-stops-release-part-1-up.sql +98 -0
- package/dist/integration-engine/ropid-gtfs/RopidGtfsFacade.d.ts +4 -3
- package/dist/integration-engine/ropid-gtfs/RopidGtfsFacade.js +8 -6
- package/dist/integration-engine/ropid-gtfs/RopidGtfsFacade.js.map +1 -1
- package/dist/integration-engine/ropid-gtfs/data-access/cache/PublicGtfsDepartureRepository.d.ts +14 -0
- package/dist/integration-engine/ropid-gtfs/data-access/cache/PublicGtfsDepartureRepository.js +82 -0
- package/dist/integration-engine/ropid-gtfs/data-access/cache/PublicGtfsDepartureRepository.js.map +1 -0
- package/dist/integration-engine/ropid-gtfs/data-access/precomputed/DeparturesRepository.d.ts +10 -2
- package/dist/integration-engine/ropid-gtfs/data-access/precomputed/DeparturesRepository.js +81 -10
- package/dist/integration-engine/ropid-gtfs/data-access/precomputed/DeparturesRepository.js.map +1 -1
- package/dist/integration-engine/ropid-gtfs/interfaces/IPublicDepartureDto.d.ts +12 -0
- package/dist/integration-engine/ropid-gtfs/interfaces/IPublicDepartureDto.js +3 -0
- package/dist/integration-engine/ropid-gtfs/interfaces/IPublicDepartureDto.js.map +1 -0
- package/dist/integration-engine/ropid-gtfs/ioc/Di.js +10 -0
- package/dist/integration-engine/ropid-gtfs/ioc/Di.js.map +1 -1
- package/dist/integration-engine/ropid-gtfs/ioc/RopidGtfsContainerToken.d.ts +4 -0
- package/dist/integration-engine/ropid-gtfs/ioc/RopidGtfsContainerToken.js +4 -0
- package/dist/integration-engine/ropid-gtfs/ioc/RopidGtfsContainerToken.js.map +1 -1
- package/dist/integration-engine/ropid-gtfs/transformations/PublicDepartureCacheTransformation.d.ts +7 -0
- package/dist/integration-engine/ropid-gtfs/transformations/PublicDepartureCacheTransformation.js +36 -0
- package/dist/integration-engine/ropid-gtfs/transformations/PublicDepartureCacheTransformation.js.map +1 -0
- package/dist/integration-engine/ropid-gtfs/workers/timetables/TimetableWorker.d.ts +2 -1
- package/dist/integration-engine/ropid-gtfs/workers/timetables/TimetableWorker.js +9 -1
- package/dist/integration-engine/ropid-gtfs/workers/timetables/TimetableWorker.js.map +1 -1
- package/dist/integration-engine/ropid-gtfs/workers/timetables/constants.d.ts +1 -0
- package/dist/integration-engine/ropid-gtfs/workers/timetables/constants.js +5 -0
- package/dist/integration-engine/ropid-gtfs/workers/timetables/constants.js.map +1 -0
- package/dist/integration-engine/ropid-gtfs/workers/timetables/tasks/CheckSavedRowsAndReplaceTablesTask.js +4 -0
- package/dist/integration-engine/ropid-gtfs/workers/timetables/tasks/CheckSavedRowsAndReplaceTablesTask.js.map +1 -1
- package/dist/integration-engine/ropid-gtfs/workers/timetables/tasks/RefreshPublicGtfsDepartureCacheTask.d.ts +21 -0
- package/dist/integration-engine/ropid-gtfs/workers/timetables/tasks/RefreshPublicGtfsDepartureCacheTask.js +102 -0
- package/dist/integration-engine/ropid-gtfs/workers/timetables/tasks/RefreshPublicGtfsDepartureCacheTask.js.map +1 -0
- package/dist/integration-engine/ropid-gtfs/workers/timetables/tasks/helpers/PrecomputedTablesFacade.d.ts +3 -2
- package/dist/integration-engine/ropid-gtfs/workers/timetables/tasks/helpers/PrecomputedTablesFacade.js +9 -7
- package/dist/integration-engine/ropid-gtfs/workers/timetables/tasks/helpers/PrecomputedTablesFacade.js.map +1 -1
- package/dist/integration-engine/ropid-gtfs/workers/timetables/tasks/interfaces/IRefreshPublicDepartureParams.d.ts +4 -0
- package/dist/integration-engine/ropid-gtfs/workers/timetables/tasks/interfaces/IRefreshPublicDepartureParams.js +3 -0
- package/dist/integration-engine/ropid-gtfs/workers/timetables/tasks/interfaces/IRefreshPublicDepartureParams.js.map +1 -0
- package/dist/integration-engine/ropid-gtfs/workers/timetables/tasks/schema/RefreshPublicDepartureSchema.d.ts +5 -0
- package/dist/integration-engine/ropid-gtfs/workers/timetables/tasks/schema/RefreshPublicDepartureSchema.js +31 -0
- package/dist/integration-engine/ropid-gtfs/workers/timetables/tasks/schema/RefreshPublicDepartureSchema.js.map +1 -0
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/data-access/cache/PublicApiCacheRepository.js +6 -1
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/data-access/cache/PublicApiCacheRepository.js.map +1 -1
- package/dist/output-gateway/index.js.map +1 -1
- package/dist/output-gateway/pid/helpers/DepartureBoardMapper.js +2 -1
- package/dist/output-gateway/pid/helpers/DepartureBoardMapper.js.map +1 -1
- package/dist/output-gateway/public/controllers/v1/PublicDepartureBoardsController.d.ts +8 -0
- package/dist/output-gateway/public/controllers/v1/PublicDepartureBoardsController.js +60 -0
- package/dist/output-gateway/public/controllers/v1/PublicDepartureBoardsController.js.map +1 -0
- package/dist/output-gateway/public/controllers/v1/interfaces/PublicParamsInterfaces.d.ts +10 -0
- package/dist/output-gateway/public/data-access/redis/PublicGtfsDepartureRepository.d.ts +11 -0
- package/dist/output-gateway/public/data-access/redis/PublicGtfsDepartureRepository.js +72 -0
- package/dist/output-gateway/public/data-access/redis/PublicGtfsDepartureRepository.js.map +1 -0
- package/dist/output-gateway/public/data-access/redis/PublicVehiclePositionsRepository.d.ts +1 -0
- package/dist/output-gateway/public/data-access/redis/PublicVehiclePositionsRepository.js +22 -2
- package/dist/output-gateway/public/data-access/redis/PublicVehiclePositionsRepository.js.map +1 -1
- package/dist/output-gateway/public/domain/IPublicDepartureTransformInputDto.d.ts +9 -0
- package/dist/output-gateway/public/domain/IPublicDepartureTransformInputDto.js +3 -0
- package/dist/output-gateway/public/domain/IPublicDepartureTransformInputDto.js.map +1 -0
- package/dist/output-gateway/public/domain/PublicApiDepartureInterfaces.d.ts +34 -0
- package/dist/output-gateway/public/domain/PublicApiDepartureInterfaces.js +3 -0
- package/dist/output-gateway/public/domain/PublicApiDepartureInterfaces.js.map +1 -0
- package/dist/output-gateway/public/domain/repository/IGtfsDepartureRepository.d.ts +4 -0
- package/dist/output-gateway/public/domain/repository/IGtfsDepartureRepository.js +3 -0
- package/dist/output-gateway/public/domain/repository/IGtfsDepartureRepository.js.map +1 -0
- package/dist/output-gateway/public/domain/repository/IVehiclePositionsRepository.d.ts +1 -0
- package/dist/output-gateway/public/ioc/Di.js +8 -0
- package/dist/output-gateway/public/ioc/Di.js.map +1 -1
- package/dist/output-gateway/public/ioc/OgModuleToken.d.ts +2 -0
- package/dist/output-gateway/public/ioc/OgModuleToken.js +2 -0
- package/dist/output-gateway/public/ioc/OgModuleToken.js.map +1 -1
- package/dist/output-gateway/public/routers/v1/PublicDeparturesRouter.d.ts +10 -0
- package/dist/output-gateway/public/routers/v1/PublicDeparturesRouter.js +28 -0
- package/dist/output-gateway/public/routers/v1/PublicDeparturesRouter.js.map +1 -0
- package/dist/output-gateway/public/routers/v1/{PublicRouter.d.ts → PublicVehiclePositionsRouter.d.ts} +3 -3
- package/dist/output-gateway/public/routers/v1/{PublicRouter.js → PublicVehiclePositionsRouter.js} +8 -8
- package/dist/output-gateway/public/routers/v1/PublicVehiclePositionsRouter.js.map +1 -0
- package/dist/output-gateway/public/routers/v1/helpers/CustomStopIdGroupValidator.d.ts +5 -0
- package/dist/output-gateway/public/routers/v1/helpers/CustomStopIdGroupValidator.js +42 -0
- package/dist/output-gateway/public/routers/v1/helpers/CustomStopIdGroupValidator.js.map +1 -0
- package/dist/output-gateway/public/service/facade/DepartureBoardFacade.d.ts +17 -0
- package/dist/output-gateway/public/service/facade/DepartureBoardFacade.js +106 -0
- package/dist/output-gateway/public/service/facade/DepartureBoardFacade.js.map +1 -0
- package/dist/output-gateway/public/service/transformations/PublicDepartureTransformation.d.ts +34 -0
- package/dist/output-gateway/public/service/transformations/PublicDepartureTransformation.js +54 -0
- package/dist/output-gateway/public/service/transformations/PublicDepartureTransformation.js.map +1 -0
- package/dist/output-gateway/shared/DepartureCalculator.d.ts +10 -0
- package/dist/output-gateway/shared/DepartureCalculator.js +26 -0
- package/dist/output-gateway/shared/DepartureCalculator.js.map +1 -0
- package/dist/output-gateway/shared/RopidRouterUtils.d.ts +2 -1
- package/dist/output-gateway/shared/RopidRouterUtils.js +4 -3
- package/dist/output-gateway/shared/RopidRouterUtils.js.map +1 -1
- package/dist/schema-definitions/ropid-gtfs/redis/const.d.ts +1 -0
- package/dist/schema-definitions/ropid-gtfs/redis/const.js +5 -0
- package/dist/schema-definitions/ropid-gtfs/redis/const.js.map +1 -0
- package/dist/schema-definitions/ropid-gtfs/redis/interfaces/IPublicGtfsDepartureCacheDto.d.ts +12 -0
- package/dist/schema-definitions/ropid-gtfs/redis/interfaces/IPublicGtfsDepartureCacheDto.js +3 -0
- package/dist/schema-definitions/ropid-gtfs/redis/interfaces/IPublicGtfsDepartureCacheDto.js.map +1 -0
- package/dist/schema-definitions/ropid-gtfs/redis/schemas/PublicGtfsDepartureDtoSchema.d.ts +4 -0
- package/dist/schema-definitions/ropid-gtfs/redis/schemas/PublicGtfsDepartureDtoSchema.js +69 -0
- package/dist/schema-definitions/ropid-gtfs/redis/schemas/PublicGtfsDepartureDtoSchema.js.map +1 -0
- package/docs/implementation_documentation.md +26 -0
- package/docs/openapi-output.yaml +233 -0
- package/package.json +1 -1
- package/dist/output-gateway/public/routers/v1/PublicRouter.js.map +0 -1
|
@@ -0,0 +1,106 @@
|
|
|
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.DepartureBoardFacade = void 0;
|
|
13
|
+
const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
|
|
14
|
+
const PublicDepartureTransformation_1 = require("../transformations/PublicDepartureTransformation");
|
|
15
|
+
class DepartureBoardFacade {
|
|
16
|
+
constructor(departureRepository, tripRepository, descriptorRepository) {
|
|
17
|
+
this.departureRepository = departureRepository;
|
|
18
|
+
this.tripRepository = tripRepository;
|
|
19
|
+
this.descriptorRepository = descriptorRepository;
|
|
20
|
+
this.transformation = new PublicDepartureTransformation_1.PublicDepartureTransformation();
|
|
21
|
+
}
|
|
22
|
+
getAll(stopIds, limit, routeShortNames, minutesAfter) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
let output = [];
|
|
25
|
+
const sortedStopGroups = this.sortStopGroupsByPriority(stopIds);
|
|
26
|
+
for (const stopGroup of sortedStopGroups) {
|
|
27
|
+
let outputGroup = [];
|
|
28
|
+
const departures = yield this.departureRepository.getPublicGtfsDepartureCache(stopGroup.stopIds, minutesAfter);
|
|
29
|
+
try {
|
|
30
|
+
for (const departure of departures) {
|
|
31
|
+
const vehicleIds = yield this.tripRepository.getAllVehicleIdsForTrip(departure.trip_id);
|
|
32
|
+
const duplicatedDepartures = yield this.duplicateDeparturesWithDifferentVehicleIds(departure, vehicleIds);
|
|
33
|
+
outputGroup = outputGroup.concat(duplicatedDepartures);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
if (err instanceof golemio_errors_1.AbstractGolemioError) {
|
|
38
|
+
throw err;
|
|
39
|
+
}
|
|
40
|
+
throw new golemio_errors_1.GeneralError("Error while retrieving cached data", this.constructor.name, err, 500);
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
if (routeShortNames) {
|
|
44
|
+
outputGroup = outputGroup.filter((departure) => routeShortNames.includes(departure.route.short_name));
|
|
45
|
+
}
|
|
46
|
+
outputGroup = this.sortDeparturesByPredictedTimestamp(outputGroup);
|
|
47
|
+
// minutesBefore is set to 0 because we want to display departures that are already happening
|
|
48
|
+
// this may change in the future
|
|
49
|
+
outputGroup = this.removeDeparturesOutsideTimeRange(outputGroup, 0, minutesAfter).slice(0, limit);
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
throw new golemio_errors_1.GeneralError("Error while manipulating departures", this.constructor.name, err, 500);
|
|
53
|
+
}
|
|
54
|
+
output.push(outputGroup);
|
|
55
|
+
}
|
|
56
|
+
return output;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
duplicateDeparturesWithDifferentVehicleIds(departure, vehicleIds) {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
let outputGroup = [];
|
|
62
|
+
// If there are no vehicleIds, we still want to display the departure
|
|
63
|
+
// but without any RT/vehicle information
|
|
64
|
+
if (vehicleIds.length === 0) {
|
|
65
|
+
outputGroup.push(this.transformation.transformElement({
|
|
66
|
+
departure,
|
|
67
|
+
vehicleId: null,
|
|
68
|
+
vehiclePosition: null,
|
|
69
|
+
vehicleDescriptor: null,
|
|
70
|
+
}));
|
|
71
|
+
return outputGroup;
|
|
72
|
+
}
|
|
73
|
+
// Otherwise, we want to duplicate the departure for each vehicleId
|
|
74
|
+
// (multiple vehicles can be on the same trip at the same time)
|
|
75
|
+
for (const vehicleId of vehicleIds) {
|
|
76
|
+
const vehiclePosition = yield this.tripRepository.getDetailedVehiclePosition(vehicleId);
|
|
77
|
+
const vehicleDescriptor = (vehiclePosition === null || vehiclePosition === void 0 ? void 0 : vehiclePosition.detailed_info.registration_number)
|
|
78
|
+
? yield this.descriptorRepository.getOneByRegNumber(departure.route_type, vehiclePosition === null || vehiclePosition === void 0 ? void 0 : vehiclePosition.detailed_info.registration_number)
|
|
79
|
+
: null;
|
|
80
|
+
outputGroup.push(this.transformation.transformElement({
|
|
81
|
+
departure,
|
|
82
|
+
vehicleId,
|
|
83
|
+
vehiclePosition,
|
|
84
|
+
vehicleDescriptor,
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
return outputGroup;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
removeDeparturesOutsideTimeRange(departureGroup, minutesBefore, minutesAfter) {
|
|
91
|
+
const now = new Date();
|
|
92
|
+
const timeRangeStart = new Date(now.getTime() - minutesBefore * 60 * 1000);
|
|
93
|
+
const timeRangeEnd = new Date(now.getTime() + minutesAfter * 60 * 1000);
|
|
94
|
+
departureGroup = departureGroup.filter((departure) => new Date(departure.departure.timestamp_predicted) >= timeRangeStart &&
|
|
95
|
+
new Date(departure.departure.timestamp_predicted) <= timeRangeEnd);
|
|
96
|
+
return departureGroup;
|
|
97
|
+
}
|
|
98
|
+
sortStopGroupsByPriority(stopIds) {
|
|
99
|
+
return Array.from(stopIds).sort((a, b) => a.priority - b.priority);
|
|
100
|
+
}
|
|
101
|
+
sortDeparturesByPredictedTimestamp(departureGroup) {
|
|
102
|
+
return departureGroup.sort((a, b) => new Date(a.departure.timestamp_predicted).getTime() - new Date(b.departure.timestamp_predicted).getTime());
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.DepartureBoardFacade = DepartureBoardFacade;
|
|
106
|
+
//# sourceMappingURL=DepartureBoardFacade.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DepartureBoardFacade.js","sourceRoot":"","sources":["../../../../../src/output-gateway/public/service/facade/DepartureBoardFacade.ts"],"names":[],"mappings":";;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AA4C;QACnF,OAAO,cAAc,CAAC,IAAI,CACtB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC,OAAO,EAAE,CACtH,CAAC;IACN,CAAC;CACJ;AAjID,oDAiIC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { IPublicDepartureTransformInputDto } from "../../domain/IPublicDepartureTransformInputDto";
|
|
2
|
+
import { IPublicApiDeparture } from "../../domain/PublicApiDepartureInterfaces";
|
|
3
|
+
import { AbstractTransformation } from "@golemio/core/dist/helpers/transformation/AbstractTransformation";
|
|
4
|
+
export declare class PublicDepartureTransformation extends AbstractTransformation<IPublicDepartureTransformInputDto, IPublicApiDeparture> {
|
|
5
|
+
name: string;
|
|
6
|
+
protected transformInternal: (inputDto: IPublicDepartureTransformInputDto) => {
|
|
7
|
+
departure: {
|
|
8
|
+
timestamp_scheduled: string;
|
|
9
|
+
timestamp_predicted: string;
|
|
10
|
+
delay_seconds: number | null;
|
|
11
|
+
minutes: number;
|
|
12
|
+
};
|
|
13
|
+
stop: {
|
|
14
|
+
id: string;
|
|
15
|
+
sequence: number;
|
|
16
|
+
platform_code: string | null;
|
|
17
|
+
};
|
|
18
|
+
route: {
|
|
19
|
+
type: string;
|
|
20
|
+
short_name: string;
|
|
21
|
+
};
|
|
22
|
+
trip: {
|
|
23
|
+
id: string;
|
|
24
|
+
headsign: string;
|
|
25
|
+
is_canceled: boolean;
|
|
26
|
+
};
|
|
27
|
+
vehicle: {
|
|
28
|
+
id: string | null;
|
|
29
|
+
is_wheelchair_accessible: boolean | null;
|
|
30
|
+
is_air_conditioned: boolean | null;
|
|
31
|
+
has_charger: boolean | null;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PublicDepartureTransformation = void 0;
|
|
4
|
+
const RouteTypeEnums_1 = require("../../../../helpers/RouteTypeEnums");
|
|
5
|
+
const DepartureCalculator_1 = require("../../../shared/DepartureCalculator");
|
|
6
|
+
const RopidRouterUtils_1 = require("../../../shared/RopidRouterUtils");
|
|
7
|
+
const AbstractTransformation_1 = require("@golemio/core/dist/helpers/transformation/AbstractTransformation");
|
|
8
|
+
const const_1 = require("../../../../const");
|
|
9
|
+
class PublicDepartureTransformation extends AbstractTransformation_1.AbstractTransformation {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.name = "PublicDepartureTransformation";
|
|
13
|
+
this.transformInternal = (inputDto) => {
|
|
14
|
+
var _a, _b, _c, _d, _e, _f;
|
|
15
|
+
const { departure, vehicleId, vehiclePosition, vehicleDescriptor } = inputDto;
|
|
16
|
+
const delayInSeconds = (_a = vehiclePosition === null || vehiclePosition === void 0 ? void 0 : vehiclePosition.delay) !== null && _a !== void 0 ? _a : null;
|
|
17
|
+
const departureTime = new Date(departure.departure_datetime);
|
|
18
|
+
const arrivalTime = departure.arrival_datetime ? new Date(departure.arrival_datetime) : null;
|
|
19
|
+
const predictedDepartureTime = DepartureCalculator_1.DepartureCalculator.getPredictedDepartureTime(departureTime, arrivalTime, delayInSeconds);
|
|
20
|
+
return {
|
|
21
|
+
departure: {
|
|
22
|
+
timestamp_scheduled: (_b = RopidRouterUtils_1.RopidRouterUtils.formatTimestamp(departureTime)) !== null && _b !== void 0 ? _b : departure.departure_datetime,
|
|
23
|
+
timestamp_predicted: (_c = RopidRouterUtils_1.RopidRouterUtils.formatTimestamp(predictedDepartureTime)) !== null && _c !== void 0 ? _c : departure.departure_datetime,
|
|
24
|
+
delay_seconds: delayInSeconds,
|
|
25
|
+
minutes: DepartureCalculator_1.DepartureCalculator.getDepartureMinutes(predictedDepartureTime),
|
|
26
|
+
},
|
|
27
|
+
stop: {
|
|
28
|
+
id: departure.stop_id,
|
|
29
|
+
sequence: departure.stop_sequence,
|
|
30
|
+
// NOTE platform_code is always null for trains
|
|
31
|
+
// fill from realtime data (CIS stop platform code) if needed in the future
|
|
32
|
+
platform_code: departure.platform_code,
|
|
33
|
+
},
|
|
34
|
+
route: {
|
|
35
|
+
type: RouteTypeEnums_1.GTFSRouteTypeEnum[departure.route_type].toLowerCase(),
|
|
36
|
+
short_name: departure.route_short_name,
|
|
37
|
+
},
|
|
38
|
+
trip: {
|
|
39
|
+
id: departure.trip_id,
|
|
40
|
+
headsign: departure.trip_headsign,
|
|
41
|
+
is_canceled: (vehiclePosition === null || vehiclePosition === void 0 ? void 0 : vehiclePosition.state_position) === const_1.StatePositionEnum.CANCELED,
|
|
42
|
+
},
|
|
43
|
+
vehicle: {
|
|
44
|
+
id: vehicleId,
|
|
45
|
+
is_wheelchair_accessible: (_d = vehiclePosition === null || vehiclePosition === void 0 ? void 0 : vehiclePosition.detailed_info.is_wheelchair_accessible) !== null && _d !== void 0 ? _d : null,
|
|
46
|
+
is_air_conditioned: (_e = vehicleDescriptor === null || vehicleDescriptor === void 0 ? void 0 : vehicleDescriptor.is_air_conditioned) !== null && _e !== void 0 ? _e : null,
|
|
47
|
+
has_charger: (_f = vehicleDescriptor === null || vehicleDescriptor === void 0 ? void 0 : vehicleDescriptor.has_usb_chargers) !== null && _f !== void 0 ? _f : null,
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.PublicDepartureTransformation = PublicDepartureTransformation;
|
|
54
|
+
//# sourceMappingURL=PublicDepartureTransformation.js.map
|
package/dist/output-gateway/public/service/transformations/PublicDepartureTransformation.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PublicDepartureTransformation.js","sourceRoot":"","sources":["../../../../../src/output-gateway/public/service/transformations/PublicDepartureTrans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,IAAI,EAAE,kCAAiB,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE;oBAC3D,UAAU,EAAE,SAAS,CAAC,gBAAgB;iBACzC;gBACD,IAAI,EAAE;oBACF,EAAE,EAAE,SAAS,CAAC,OAAO;oBACrB,QAAQ,EAAE,SAAS,CAAC,aAAa;oBACjC,WAAW,EAAE,CAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,cAAc,MAAK,yBAAiB,CAAC,QAAQ;iBAC9E;gBACD,OAAO,EAAE;oBACL,EAAE,EAAE,SAAS;oBACb,wBAAwB,EAAE,MAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,aAAa,CAAC,wBAAwB,mCAAI,IAAI;oBACzF,kBAAkB,EAAE,MAAA,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,kBAAkB,mCAAI,IAAI;oBACjE,WAAW,EAAE,MAAA,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,gBAAgB,mCAAI,IAAI;iBAC3D;aACJ,CAAC;QACN,CAAC,CAAC;IACN,CAAC;CAAA;AA7CD,sEA6CC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class DepartureCalculator {
|
|
2
|
+
/**
|
|
3
|
+
* Calculates the predicted departure time based on the scheduled departure time, arrival time and delay.
|
|
4
|
+
**/
|
|
5
|
+
static getPredictedDepartureTime: (departureTime: Date, arrivalTime: Date | null, delayInSeconds: number | null) => Date;
|
|
6
|
+
/**
|
|
7
|
+
* Calculates the number of minutes until the predicted departure time.
|
|
8
|
+
**/
|
|
9
|
+
static getDepartureMinutes: (predictedDepartureTime: Date) => number;
|
|
10
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DepartureCalculator = void 0;
|
|
4
|
+
class DepartureCalculator {
|
|
5
|
+
}
|
|
6
|
+
exports.DepartureCalculator = DepartureCalculator;
|
|
7
|
+
/**
|
|
8
|
+
* Calculates the predicted departure time based on the scheduled departure time, arrival time and delay.
|
|
9
|
+
**/
|
|
10
|
+
DepartureCalculator.getPredictedDepartureTime = (departureTime, arrivalTime, delayInSeconds) => {
|
|
11
|
+
let delayInSecondsWithDefault = delayInSeconds !== null && delayInSeconds !== void 0 ? delayInSeconds : 0;
|
|
12
|
+
let adjustedDepartureTime = new Date(departureTime.getTime() + delayInSecondsWithDefault * 1000);
|
|
13
|
+
if (arrivalTime && delayInSecondsWithDefault > 0) {
|
|
14
|
+
const dwellInSeconds = (departureTime.getTime() - arrivalTime.getTime()) / 1000;
|
|
15
|
+
const minDwellInSeconds = Math.min(delayInSecondsWithDefault, dwellInSeconds);
|
|
16
|
+
adjustedDepartureTime.setTime(adjustedDepartureTime.getTime() - minDwellInSeconds * 1000);
|
|
17
|
+
}
|
|
18
|
+
return adjustedDepartureTime;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Calculates the number of minutes until the predicted departure time.
|
|
22
|
+
**/
|
|
23
|
+
DepartureCalculator.getDepartureMinutes = (predictedDepartureTime) => {
|
|
24
|
+
return Math.round((predictedDepartureTime.getTime() - new Date().getTime()) / (60 * 1000));
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=DepartureCalculator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DepartureCalculator.js","sourceRoot":"","sources":["../../../src/output-gateway/shared/DepartureCalculator.ts"],"names":[],"mappings":";;;AAAA,MAAa,mBAAmB;;AAAhC,kDA4BC;AA3BG;;IAEI;AACU,6CAAyB,GAAG,CACtC,aAAmB,EACnB,WAAwB,EACxB,cAA6B,EACzB,EAAE;IACN,IAAI,yBAAyB,GAAG,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,CAAC,CAAC;IACpD,IAAI,qBAAqB,GAAG,IAAI,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,GAAG,yBAAyB,GAAG,IAAI,CAAC,CAAC;IAEjG,IAAI,WAAW,IAAI,yBAAyB,GAAG,CAAC,EAAE;QAC9C,MAAM,cAAc,GAAG,CAAC,aAAa,CAAC,OAAO,EAAE,GAAG,WAAW,CAAC,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC;QAChF,MAAM,iBAAiB,GAAG,IAAI,CAAC,GAAG,CAAC,yBAAyB,EAAE,cAAc,CAAC,CAAC;QAE9E,qBAAqB,CAAC,OAAO,CAAC,qBAAqB,CAAC,OAAO,EAAE,GAAG,iBAAiB,GAAG,IAAI,CAAC,CAAC;KAC7F;IAED,OAAO,qBAAqB,CAAC;AACjC,CAAC,CAAC;AAEF;;IAEI;AACU,uCAAmB,GAAG,CAAC,sBAA4B,EAAU,EAAE;IACzE,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,sBAAsB,CAAC,OAAO,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;AAC/F,CAAC,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ClassConstructor } from "@golemio/core/dist/shared/class-transformer";
|
|
2
2
|
import { ParsedQs } from "qs";
|
|
3
3
|
export declare class RopidRouterUtils {
|
|
4
|
+
static TIMEZONE: string;
|
|
4
5
|
/**
|
|
5
6
|
* Convert plain object to DTO class instance
|
|
6
7
|
*/
|
|
@@ -8,7 +9,7 @@ export declare class RopidRouterUtils {
|
|
|
8
9
|
/**
|
|
9
10
|
* Format to ISO 8601 (without milliseconds)
|
|
10
11
|
*/
|
|
11
|
-
static formatTimestamp: (dateObject: Date | null, preferredTimezone
|
|
12
|
+
static formatTimestamp: (dateObject: Date | null, preferredTimezone?: string) => string | null;
|
|
12
13
|
/**
|
|
13
14
|
* Validate and return timezone (it is possible to use _ symbol instead of URL encoded / symbol)
|
|
14
15
|
*/
|
|
@@ -4,13 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.RopidRouterUtils = void 0;
|
|
7
|
-
const config_1 = require("@golemio/core/dist/output-gateway/config");
|
|
8
7
|
const Logger_1 = require("@golemio/core/dist/output-gateway/Logger");
|
|
9
|
-
const
|
|
8
|
+
const config_1 = require("@golemio/core/dist/output-gateway/config");
|
|
10
9
|
const class_transformer_1 = require("@golemio/core/dist/shared/class-transformer");
|
|
10
|
+
const moment_timezone_1 = __importDefault(require("@golemio/core/dist/shared/moment-timezone"));
|
|
11
11
|
class RopidRouterUtils {
|
|
12
12
|
}
|
|
13
13
|
exports.RopidRouterUtils = RopidRouterUtils;
|
|
14
|
+
RopidRouterUtils.TIMEZONE = "Europe/Prague";
|
|
14
15
|
/**
|
|
15
16
|
* Convert plain object to DTO class instance
|
|
16
17
|
*/
|
|
@@ -20,7 +21,7 @@ RopidRouterUtils.mapObjectToDTOInstance = (dto, data) => {
|
|
|
20
21
|
/**
|
|
21
22
|
* Format to ISO 8601 (without milliseconds)
|
|
22
23
|
*/
|
|
23
|
-
RopidRouterUtils.formatTimestamp = (dateObject, preferredTimezone) => {
|
|
24
|
+
RopidRouterUtils.formatTimestamp = (dateObject, preferredTimezone = RopidRouterUtils.TIMEZONE) => {
|
|
24
25
|
if (!dateObject)
|
|
25
26
|
return null;
|
|
26
27
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RopidRouterUtils.js","sourceRoot":"","sources":["../../../src/output-gateway/shared/RopidRouterUtils.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"RopidRouterUtils.js","sourceRoot":"","sources":["../../../src/output-gateway/shared/RopidRouterUtils.ts"],"names":[],"mappings":";;;;;;AAAA,qEAA+D;AAC/D,qEAAkE;AAClE,mFAAgG;AAChG,gGAA+D;AAG/D,MAAa,gBAAgB;;AAA7B,4CA0CC;AAzCiB,yBAAQ,GAAG,eAAe,CAAC;AAEzC;;GAEG;AACW,uCAAsB,GAAG,CAAI,GAAwB,EAAE,IAAS,EAAE,EAAE;IAC9E,OAAO,IAAA,mCAAe,EAAC,GAAG,EAAE,IAAI,EAAE,EAAE,mBAAmB,EAAE,IAAI,EAAE,CAAC,CAAC;AACrE,CAAC,CAAC;AAEF;;GAEG;AACW,gCAAe,GAAG,CAAC,UAAuB,EAAE,iBAAiB,GAAG,gBAAgB,CAAC,QAAQ,EAAiB,EAAE;IACtH,IAAI,CAAC,UAAU;QAAE,OAAO,IAAI,CAAC;IAE7B,IAAI;QACA,MAAM,QAAQ,GAAG,IAAA,yBAAM,EAAC,UAAU,CAAC,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,MAAM,EAAE,CAAC;QAEnE,IAAI,QAAQ,KAAK,cAAc,EAAE;YAC7B,YAAG,CAAC,KAAK,CAAC,wDAAwD,CAAC,CAAC;YACpE,OAAO,IAAI,CAAC;SACf;QAED,OAAO,QAAQ,CAAC;KACnB;IAAC,OAAO,GAAG,EAAE;QACV,YAAG,CAAC,KAAK,CAAC,wDAAwD,EAAE,GAAG,CAAC,CAAC;QACzE,OAAO,IAAI,CAAC;KACf;AACL,CAAC,CAAC;AAEF;;GAEG;AACW,qCAAoB,GAAG,CAAC,iBAAmC,EAAU,EAAE;IACjF,MAAM,QAAQ,GACV,OAAO,iBAAiB,KAAK,QAAQ;QACjC,CAAC,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;QACtC,CAAC,CAAC,eAAM,CAAC,gBAAgB,CAAC,eAAe,CAAC;IAElD,OAAO,QAAQ,CAAC;AACpB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PUBLIC_DEPARTURE_NAMESPACE_PREFIX = "gtfsPublicDepartureCache";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"const.js","sourceRoot":"","sources":["../../../../src/schema-definitions/ropid-gtfs/redis/const.ts"],"names":[],"mappings":";;;AAAa,QAAA,iCAAiC,GAAG,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { GTFSRouteTypeEnum } from "../../../../helpers/RouteTypeEnums";
|
|
2
|
+
export interface IPublicGtfsDepartureCacheDto {
|
|
3
|
+
stop_id: string;
|
|
4
|
+
departure_datetime: string;
|
|
5
|
+
arrival_datetime: string | null;
|
|
6
|
+
route_short_name: string;
|
|
7
|
+
route_type: GTFSRouteTypeEnum;
|
|
8
|
+
trip_id: string;
|
|
9
|
+
stop_sequence: number;
|
|
10
|
+
platform_code: string | null;
|
|
11
|
+
trip_headsign: string;
|
|
12
|
+
}
|
package/dist/schema-definitions/ropid-gtfs/redis/interfaces/IPublicGtfsDepartureCacheDto.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IPublicGtfsDepartureCacheDto.js","sourceRoot":"","sources":["../../../../../src/schema-definitions/ropid-gtfs/redis/interfaces/IPublicGtfsDepartureCacheDto.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { JSONSchemaType } from "@golemio/core/dist/shared/ajv";
|
|
2
|
+
import { IPublicGtfsDepartureCacheDto } from "../interfaces/IPublicGtfsDepartureCacheDto";
|
|
3
|
+
declare const publicGtfsDepartureDtoSchema: JSONSchemaType<IPublicGtfsDepartureCacheDto[]>;
|
|
4
|
+
export { publicGtfsDepartureDtoSchema as PublicGtfsDepartureDtoSchema };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PublicGtfsDepartureDtoSchema = void 0;
|
|
4
|
+
const publicGtfsDepartureDtoSchema = {
|
|
5
|
+
$schema: "http://json-schema.org/draft-04/schema#",
|
|
6
|
+
title: "PublicGtfsDepartureDto",
|
|
7
|
+
type: "array",
|
|
8
|
+
items: {
|
|
9
|
+
type: "object",
|
|
10
|
+
properties: {
|
|
11
|
+
stop_id: {
|
|
12
|
+
type: "string",
|
|
13
|
+
},
|
|
14
|
+
departure_datetime: {
|
|
15
|
+
type: "string",
|
|
16
|
+
},
|
|
17
|
+
arrival_datetime: {
|
|
18
|
+
oneOf: [
|
|
19
|
+
{
|
|
20
|
+
type: "string",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
type: "null",
|
|
24
|
+
nullable: true,
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
route_short_name: {
|
|
29
|
+
type: "string",
|
|
30
|
+
},
|
|
31
|
+
route_type: {
|
|
32
|
+
type: "number",
|
|
33
|
+
},
|
|
34
|
+
trip_id: {
|
|
35
|
+
type: "string",
|
|
36
|
+
},
|
|
37
|
+
stop_sequence: {
|
|
38
|
+
type: "number",
|
|
39
|
+
},
|
|
40
|
+
platform_code: {
|
|
41
|
+
oneOf: [
|
|
42
|
+
{
|
|
43
|
+
type: "string",
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
type: "null",
|
|
47
|
+
nullable: true,
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
trip_headsign: {
|
|
52
|
+
type: "string",
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
required: [
|
|
56
|
+
"stop_id",
|
|
57
|
+
"departure_datetime",
|
|
58
|
+
"arrival_datetime",
|
|
59
|
+
"route_short_name",
|
|
60
|
+
"route_type",
|
|
61
|
+
"trip_id",
|
|
62
|
+
"stop_sequence",
|
|
63
|
+
"platform_code",
|
|
64
|
+
"trip_headsign",
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
exports.PublicGtfsDepartureDtoSchema = publicGtfsDepartureDtoSchema;
|
|
69
|
+
//# sourceMappingURL=PublicGtfsDepartureDtoSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PublicGtfsDepartureDtoSchema.js","sourceRoot":"","sources":["../../../../../src/schema-definitions/ropid-gtfs/redis/schemas/PublicGtfsDepartureDtoSchema.ts"],"names":[],"mappings":";;;AAGA,MAAM,4BAA4B,GAAmD;IACjF,OAAO,EAAE,yCAAyC;IAClD,KAAK,EAAE,wBAAwB;IAC/B,IAAI,EAAE,OAAO;IACb,KAAK,EAAE;QACH,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACR,OAAO,EAAE;gBACL,IAAI,EAAE,QAAQ;aACjB;YACD,kBAAkB,EAAE;gBAChB,IAAI,EAAE,QAAQ;aACjB;YACD,gBAAgB,EAAE;gBACd,KAAK,EAAE;oBACH;wBACI,IAAI,EAAE,QAAQ;qBACjB;oBACD;wBACI,IAAI,EAAE,MAAM;wBACZ,QAAQ,EAAE,IAAI;qBACjB;iBACJ;aACJ;YACD,gBAAgB,EAAE;gBACd,IAAI,EAAE,QAAQ;aACjB;YACD,UAAU,EAAE;gBACR,IAAI,EAAE,QAAQ;aACjB;YACD,OAAO,EAAE;gBACL,IAAI,EAAE,QAAQ;aACjB;YACD,aAAa,EAAE;gBACX,IAAI,EAAE,QAAQ;aACjB;YACD,aAAa,EAAE;gBACX,KAAK,EAAE;oBACH;wBACI,IAAI,EAAE,QAAQ;qBACjB;oBACD;wBACI,IAAI,EAAE,MAAM;wBACZ,QAAQ,EAAE,IAAI;qBACjB;iBACJ;aACJ;YACD,aAAa,EAAE;gBACX,IAAI,EAAE,QAAQ;aACjB;SACJ;QACD,QAAQ,EAAE;YACN,SAAS;YACT,oBAAoB;YACpB,kBAAkB;YAClB,kBAAkB;YAClB,YAAY;YACZ,SAAS;YACT,eAAe;YACf,eAAe;YACf,eAAe;SAClB;KACJ;CACJ,CAAC;AACuC,oEAA4B"}
|
|
@@ -504,6 +504,7 @@ Worker má na starost aktualizaci presets číselníků
|
|
|
504
504
|
- závislé fronty (do kterých jsou odesílány zprávy z metody workeru)
|
|
505
505
|
- název: vehicle-positions.ropidgtfs.downloadDatasets
|
|
506
506
|
- název: vehicle-positions.ropidgtfs.refreshPrecomputedTables
|
|
507
|
+
- název: vehicle-positions.ropidgtfs.refreshPublicGtfsDepartureCache
|
|
507
508
|
- název: vehicle-positions.vehiclepositions.refreshGTFSTripData
|
|
508
509
|
- datové zdroje
|
|
509
510
|
- ROPID FTP
|
|
@@ -548,6 +549,23 @@ Worker má na starost aktualizaci presets číselníků
|
|
|
548
549
|
- RopidGTFSPrecomputedDeparturesModel `ropidgtfs_precomputed_departures`
|
|
549
550
|
- RopidGTFSPrecomputedTripScheduleModel `ropidgtfs_precomputed_trip_schedule`
|
|
550
551
|
|
|
552
|
+
#### task _RefreshPublicGtfsDepartureCacheTask_
|
|
553
|
+
|
|
554
|
+
Task se stará o aktualizaci cache pro public odjezdy. Pouští se pravidelně cronem a po dokončení načtení nových JŘ.
|
|
555
|
+
|
|
556
|
+
- vstupní rabbitmq fronta
|
|
557
|
+
- název: vehicle-positions.ropidgtfs.refreshPublicGtfsDepartureCache
|
|
558
|
+
- TTL: 59 minut
|
|
559
|
+
- parametry: `{intervalFromHours, intervalToHours}`
|
|
560
|
+
- závislé fronty (do kterých jsou odesílány zprávy z metody workeru)
|
|
561
|
+
- žádné
|
|
562
|
+
- datové zdroje
|
|
563
|
+
- ROPID FTP
|
|
564
|
+
- transformace
|
|
565
|
+
- [PublicDepartureCacheTransformation](../src/integration-engine/ropid-gtfs/transformations/PublicDepartureCacheTransformation.ts)
|
|
566
|
+
- data modely
|
|
567
|
+
- RopidGTFSPrecomputedDeparturesModel `ropidgtfs_precomputed_departures`
|
|
568
|
+
|
|
551
569
|
### PresetWorker
|
|
552
570
|
|
|
553
571
|
#### _Task ~ SavePresetsDataTask_
|
|
@@ -1256,3 +1274,11 @@ Worker má na starost retenci dat tabulek Azure Table Storage
|
|
|
1256
1274
|
- `stop_times`: seznam zastávek, které vozidlo projelo a projede, vč. informací o zpoždění (historických/predikovaných), ve formátu geojson
|
|
1257
1275
|
- `shapes`: seznam tvarů trasy (podle GTFS; nejedná se o naše předpočítané anchor pointy, které se mimo zastávky oproti GTFS shapes mohou lišit), ve formátu geojson
|
|
1258
1276
|
- `vehicle_descriptor`: informace o vozidle (dopravce, dostupnost klimatizace, USB, ...)
|
|
1277
|
+
|
|
1278
|
+
#### _/public/departureboards_
|
|
1279
|
+
|
|
1280
|
+
- načte nacacheované odjezdy z redisu
|
|
1281
|
+
- možno filtrovat podle skupin zastávek `stopIds` (podle GTFS číselníku) s možností nastavení pořadí navrácených skupin s odjezdy - příklad `?stopIds[]={"0": ["U717Z5P"]}&stopIds[]={"1": ["U718Z5P", "U719Z5P"]}`
|
|
1282
|
+
- podle názvů linek a jak daleko do budoucnosti se mají odjezdy navracet
|
|
1283
|
+
- limitování počtu odjezdů v každé skupině
|
|
1284
|
+
- EP je optimalizován pro vyšší zátěž z mobilní aplikace PID lítačka - požadavek do databáze z OG pouze v případě nutnosti obnovit cache s vehicle descriptory (klimatizace, usb nabíječky), jinak je vše z Redisu
|