@golemio/pid 2.1.13-dev.504816437 → 2.1.13-dev.509077630
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/{departure_directions.sql → 01_departure_directions.sql} +0 -0
- package/db/example/{pid_line_example_115.sql → 02_pid_line_example_115.sql} +0 -0
- package/db/example/{ropid_gtfs_dump.sql → 03_ropidgtfs_dump.sql} +0 -0
- package/db/example/{ropidvymi_example.sql → 04_ropidvymi_example.sql} +0 -0
- package/db/example/{vehicle_positions_dump.sql → 05_vehicle_positions_dump.sql} +0 -0
- package/db/example/06_ropidgtfs_train_trips_stop_times.sql +83 -0
- package/db/example/{tmp_example.sql → 07_tmp_example.sql} +0 -0
- package/db/example/{zzz_precomputed_tables.sql → 99_precomputed_tables.sql} +0 -0
- package/db/example/{trip_updates.pb → pb/trip_updates.pb} +0 -0
- package/db/example/{vehicle_positions.pb → pb/vehicle_positions.pb} +0 -0
- package/dist/const.d.ts +4 -0
- package/dist/const.js +6 -1
- package/dist/const.js.map +1 -1
- package/dist/integration-engine/ropid-gtfs/RopidGTFSScheduledTripsModel.d.ts +1 -1
- package/dist/integration-engine/ropid-gtfs/RopidGTFSStopTimesModel.d.ts +11 -0
- package/dist/integration-engine/ropid-gtfs/RopidGTFSStopTimesModel.js +32 -0
- package/dist/integration-engine/ropid-gtfs/RopidGTFSStopTimesModel.js.map +1 -1
- package/dist/integration-engine/ropid-gtfs/RopidGTFSWorker.js +2 -2
- package/dist/integration-engine/ropid-gtfs/RopidGTFSWorker.js.map +1 -1
- package/dist/integration-engine/vehicle-positions/VehiclePositionsInterfaces.d.ts +152 -0
- package/dist/integration-engine/vehicle-positions/VehiclePositionsInterfaces.js +3 -0
- package/dist/integration-engine/vehicle-positions/VehiclePositionsInterfaces.js.map +1 -0
- package/dist/integration-engine/vehicle-positions/VehiclePositionsUtils.d.ts +22 -0
- package/dist/integration-engine/vehicle-positions/VehiclePositionsUtils.js +53 -0
- package/dist/integration-engine/vehicle-positions/VehiclePositionsUtils.js.map +1 -0
- package/dist/integration-engine/vehicle-positions/VehiclePositionsWorker.d.ts +32 -93
- package/dist/integration-engine/vehicle-positions/VehiclePositionsWorker.js +179 -111
- package/dist/integration-engine/vehicle-positions/VehiclePositionsWorker.js.map +1 -1
- package/dist/integration-engine/vehicle-positions/index.d.ts +2 -5
- package/dist/integration-engine/vehicle-positions/index.js +2 -5
- package/dist/integration-engine/vehicle-positions/index.js.map +1 -1
- package/dist/integration-engine/vehicle-positions/{VehiclePositionsPositionsModel.d.ts → models/VehiclePositionsPositionsModel.d.ts} +3 -3
- package/dist/integration-engine/vehicle-positions/{VehiclePositionsPositionsModel.js → models/VehiclePositionsPositionsModel.js} +3 -3
- package/dist/integration-engine/vehicle-positions/models/VehiclePositionsPositionsModel.js.map +1 -0
- package/dist/integration-engine/vehicle-positions/{VehiclePositionsRunsMessagesModel.d.ts → models/VehiclePositionsRunsMessagesModel.d.ts} +0 -0
- package/dist/integration-engine/vehicle-positions/{VehiclePositionsRunsMessagesModel.js → models/VehiclePositionsRunsMessagesModel.js} +5 -5
- package/dist/integration-engine/vehicle-positions/models/VehiclePositionsRunsMessagesModel.js.map +1 -0
- package/dist/integration-engine/vehicle-positions/{VehiclePositionsRunsModel.d.ts → models/VehiclePositionsRunsModel.d.ts} +2 -2
- package/dist/integration-engine/vehicle-positions/{VehiclePositionsRunsModel.js → models/VehiclePositionsRunsModel.js} +2 -2
- package/dist/integration-engine/vehicle-positions/models/VehiclePositionsRunsModel.js.map +1 -0
- package/dist/integration-engine/vehicle-positions/{VehiclePositionsStopsModel.d.ts → models/VehiclePositionsStopsModel.d.ts} +0 -0
- package/dist/integration-engine/vehicle-positions/{VehiclePositionsStopsModel.js → models/VehiclePositionsStopsModel.js} +1 -1
- package/dist/integration-engine/vehicle-positions/models/VehiclePositionsStopsModel.js.map +1 -0
- package/dist/integration-engine/vehicle-positions/{VehiclePositionsTripsModel.d.ts → models/VehiclePositionsTripsModel.d.ts} +5 -7
- package/dist/integration-engine/vehicle-positions/{VehiclePositionsTripsModel.js → models/VehiclePositionsTripsModel.js} +47 -32
- package/dist/integration-engine/vehicle-positions/models/VehiclePositionsTripsModel.js.map +1 -0
- package/dist/integration-engine/vehicle-positions/models/index.d.ts +5 -0
- package/dist/integration-engine/vehicle-positions/models/index.js +18 -0
- package/dist/integration-engine/vehicle-positions/models/index.js.map +1 -0
- package/dist/integration-engine/vehicle-positions/{VehiclePositionsRunsTransformation.d.ts → transformations/VehiclePositionsRunsTransformation.d.ts} +1 -1
- package/dist/integration-engine/vehicle-positions/{VehiclePositionsRunsTransformation.js → transformations/VehiclePositionsRunsTransformation.js} +1 -1
- package/dist/integration-engine/vehicle-positions/transformations/VehiclePositionsRunsTransformation.js.map +1 -0
- package/dist/integration-engine/vehicle-positions/transformations/VehiclePositionsTransformation.d.ts +108 -0
- package/dist/integration-engine/vehicle-positions/{VehiclePositionsTransformation.js → transformations/VehiclePositionsTransformation.js} +42 -45
- package/dist/integration-engine/vehicle-positions/transformations/VehiclePositionsTransformation.js.map +1 -0
- package/dist/integration-engine/vehicle-positions/transformations/index.d.ts +2 -0
- package/dist/integration-engine/vehicle-positions/transformations/index.js +15 -0
- package/dist/integration-engine/vehicle-positions/transformations/index.js.map +1 -0
- package/dist/output-gateway/vehicle-positions/models/VehiclePositionsTripsModel.js +1 -1
- package/dist/output-gateway/vehicle-positions/models/VehiclePositionsTripsModel.js.map +1 -1
- package/dist/schema-definitions/vehicle-positions/index.d.ts +9 -2
- package/dist/schema-definitions/vehicle-positions/index.js +18 -2
- package/dist/schema-definitions/vehicle-positions/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/integration-engine/vehicle-positions/VehiclePositionsPositionsModel.js.map +0 -1
- package/dist/integration-engine/vehicle-positions/VehiclePositionsRunsMessagesModel.js.map +0 -1
- package/dist/integration-engine/vehicle-positions/VehiclePositionsRunsModel.js.map +0 -1
- package/dist/integration-engine/vehicle-positions/VehiclePositionsRunsTransformation.js.map +0 -1
- package/dist/integration-engine/vehicle-positions/VehiclePositionsStopsModel.js.map +0 -1
- package/dist/integration-engine/vehicle-positions/VehiclePositionsTransformation.d.ts +0 -49
- package/dist/integration-engine/vehicle-positions/VehiclePositionsTransformation.js.map +0 -1
- package/dist/integration-engine/vehicle-positions/VehiclePositionsTripsModel.js.map +0 -1
|
@@ -1,89 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { BaseWorker } from "@golemio/core/dist/integration-engine/workers";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { IVehiclePositionsRunCommon } from "./VehiclePositionsRunsTransformation";
|
|
6
|
-
import { Feature, Point } from "@turf/turf";
|
|
7
|
-
import { ITripPositionAttributes } from "./VehiclePositionsPositionsModel";
|
|
8
|
-
interface IComputedPositionAtStopStreak {
|
|
9
|
-
firstPositionTimestamp: number | null;
|
|
10
|
-
firstPositionDelay: number | null;
|
|
11
|
-
stop_sequence: number | null;
|
|
12
|
-
}
|
|
13
|
-
export interface IPositionsContext {
|
|
14
|
-
lastPositionId: string | null;
|
|
15
|
-
lastPositionOriginTimestamp: number | null;
|
|
16
|
-
lastPositionTracking: Feature<Point, ITripPositionAttributes> | null;
|
|
17
|
-
lastPositionCanceled: boolean | null;
|
|
18
|
-
lastPositionLastStop: {
|
|
19
|
-
id: string | null;
|
|
20
|
-
sequence: number | null;
|
|
21
|
-
arrival_time: number | null;
|
|
22
|
-
departure_time: number | null;
|
|
23
|
-
};
|
|
24
|
-
lastPositionDelay: number | null;
|
|
25
|
-
atStopStreak: IComputedPositionAtStopStreak;
|
|
26
|
-
lastPositionBeforeTrackDelayed: {
|
|
27
|
-
delay: number;
|
|
28
|
-
origin_timestamp: number;
|
|
29
|
-
} | null;
|
|
30
|
-
isLastPositionAfterTrack: boolean;
|
|
31
|
-
tripId: string;
|
|
32
|
-
}
|
|
33
|
-
export interface IShapeAnchorPoint {
|
|
34
|
-
index: number;
|
|
35
|
-
at_stop: boolean;
|
|
36
|
-
bearing: number;
|
|
37
|
-
coordinates: [number, number];
|
|
38
|
-
distance_from_last_stop: number;
|
|
39
|
-
last_stop_sequence: number;
|
|
40
|
-
next_stop_sequence: number;
|
|
41
|
-
shape_dist_traveled: number;
|
|
42
|
-
this_stop_sequence: number | null;
|
|
43
|
-
time_scheduled_seconds: number;
|
|
44
|
-
}
|
|
45
|
-
export interface ISegmentShape extends IShape {
|
|
46
|
-
shape_at_stop: boolean;
|
|
47
|
-
}
|
|
48
|
-
interface IComputationTrip {
|
|
49
|
-
trip_id: string;
|
|
50
|
-
stop_times: IStopTime[];
|
|
51
|
-
shapes_anchor_points: IShapeAnchorPoint[];
|
|
52
|
-
}
|
|
53
|
-
interface ITripPositionsWithOrWithoutGTFS {
|
|
54
|
-
gtfsData: IComputationTrip | null;
|
|
55
|
-
id: string;
|
|
56
|
-
gtfs_trip_id: string;
|
|
57
|
-
gtfs_route_type: GTFSRouteTypeEnum;
|
|
58
|
-
start_timestamp: string;
|
|
59
|
-
agency_name_scheduled: string;
|
|
60
|
-
start_cis_stop_id: number;
|
|
61
|
-
positions: ITripPositionAttributes[];
|
|
62
|
-
}
|
|
63
|
-
export interface ITripPositionsWithGTFS extends ITripPositionsWithOrWithoutGTFS {
|
|
64
|
-
gtfsData: IComputationTrip;
|
|
65
|
-
}
|
|
66
|
-
export interface ICurrentPositionProperties {
|
|
67
|
-
id: string;
|
|
68
|
-
origin_time: string;
|
|
69
|
-
origin_timestamp: number;
|
|
70
|
-
tcp_event: string | null;
|
|
71
|
-
}
|
|
72
|
-
export interface ILastPositionProperties {
|
|
73
|
-
time_delay: number;
|
|
74
|
-
atStopStreak: IComputedPositionAtStopStreak;
|
|
75
|
-
}
|
|
76
|
-
export interface IPropagateDelay {
|
|
77
|
-
nextGtfsTrips: string[];
|
|
78
|
-
currentOriginTimestamp: number;
|
|
79
|
-
currentGtfsTripId: string;
|
|
80
|
-
currentRegistrationNumber: number;
|
|
81
|
-
currentDelay: number;
|
|
82
|
-
currentStartTime: string;
|
|
83
|
-
currentEndTime: string;
|
|
84
|
-
}
|
|
3
|
+
import { IVehiclePositionsRunCommon } from "./transformations";
|
|
4
|
+
import type { IPropagateDelay } from "./VehiclePositionsInterfaces";
|
|
85
5
|
export declare class VehiclePositionsWorker extends BaseWorker {
|
|
86
6
|
private modelGTFSTrips;
|
|
7
|
+
private modelGTFSStopTimes;
|
|
87
8
|
private modelPositions;
|
|
88
9
|
private modelRuns;
|
|
89
10
|
private modelStops;
|
|
@@ -93,26 +14,36 @@ export declare class VehiclePositionsWorker extends BaseWorker {
|
|
|
93
14
|
private delayComputationTripsModel;
|
|
94
15
|
private runTripsModel;
|
|
95
16
|
private gtfsRtModel;
|
|
17
|
+
private tripStopsModel;
|
|
96
18
|
private upsertTripsFQ;
|
|
97
19
|
private readonly queuePrefix;
|
|
98
|
-
private modelGTFSStopTimes;
|
|
99
20
|
constructor();
|
|
100
|
-
saveDataToDB: (msg:
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
21
|
+
saveDataToDB: (msg: {
|
|
22
|
+
content: Buffer;
|
|
23
|
+
}) => Promise<void>;
|
|
24
|
+
saveStopsToDB: (msg: {
|
|
25
|
+
content: Buffer;
|
|
26
|
+
}) => Promise<void>;
|
|
27
|
+
updateGTFSTripId: (msg: {
|
|
28
|
+
content: Buffer;
|
|
29
|
+
}) => Promise<void>;
|
|
30
|
+
generateGtfsRt: () => Promise<void>;
|
|
104
31
|
private isUpdateDelayRunTripsIdsData;
|
|
105
32
|
private mapDelayedPositionsToRunTrips;
|
|
106
33
|
propagateDelayForGtfsTrip: (data: IPropagateDelay) => Promise<void>;
|
|
107
|
-
propagateDelay: (msg:
|
|
108
|
-
|
|
34
|
+
propagateDelay: (msg: {
|
|
35
|
+
content: Buffer;
|
|
36
|
+
}) => Promise<void>;
|
|
37
|
+
updateDelay: (msg: {
|
|
38
|
+
content: Buffer;
|
|
39
|
+
}) => Promise<void>;
|
|
109
40
|
/**
|
|
110
41
|
* Queue listener method - triggers processing of TCP input gateway runs data
|
|
111
42
|
*
|
|
112
43
|
* @param {object} msg - xml->json parsed run message
|
|
113
44
|
* @returns {void}
|
|
114
45
|
*/
|
|
115
|
-
saveRunsToDB: (msg: any) => Promise<void>;
|
|
46
|
+
saveRunsToDB: (msg: Record<string, any>) => Promise<void>;
|
|
116
47
|
/**
|
|
117
48
|
* Process not public trips from runs data
|
|
118
49
|
*
|
|
@@ -126,7 +57,9 @@ export declare class VehiclePositionsWorker extends BaseWorker {
|
|
|
126
57
|
* @param {object} msg
|
|
127
58
|
* @returns {void}
|
|
128
59
|
*/
|
|
129
|
-
updateRunsGTFSTripId: (msg:
|
|
60
|
+
updateRunsGTFSTripId: (msg: {
|
|
61
|
+
content: Buffer;
|
|
62
|
+
}) => Promise<void>;
|
|
130
63
|
/**
|
|
131
64
|
* Queue listener method - delete old data
|
|
132
65
|
*/
|
|
@@ -138,7 +71,14 @@ export declare class VehiclePositionsWorker extends BaseWorker {
|
|
|
138
71
|
*
|
|
139
72
|
* @returns {string[]} array of tripIds
|
|
140
73
|
*/
|
|
141
|
-
private
|
|
74
|
+
private setAndReturnScheduledTrips;
|
|
75
|
+
/**
|
|
76
|
+
* Get trip stops schedule by block id
|
|
77
|
+
*
|
|
78
|
+
* @param {string} blockId - Target gtfs block id
|
|
79
|
+
* @param {string} tripIds - List of inserted gtfs trip ids
|
|
80
|
+
*/
|
|
81
|
+
private setAndReturnTripStopsSchedule;
|
|
142
82
|
/**
|
|
143
83
|
* Takes all newly computed positions and saves it, then save the last ones to the trips
|
|
144
84
|
*
|
|
@@ -266,4 +206,3 @@ export declare class VehiclePositionsWorker extends BaseWorker {
|
|
|
266
206
|
*/
|
|
267
207
|
private divideSegmentLine;
|
|
268
208
|
}
|
|
269
|
-
export {};
|
|
@@ -27,13 +27,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
27
27
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
28
|
});
|
|
29
29
|
};
|
|
30
|
-
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
31
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
32
|
-
var m = o[Symbol.asyncIterator], i;
|
|
33
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
34
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
35
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
36
|
-
};
|
|
37
30
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
38
31
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
39
32
|
};
|
|
@@ -52,12 +45,13 @@ const helpers_1 = require("@golemio/core/dist/integration-engine/helpers");
|
|
|
52
45
|
const models_1 = require("@golemio/core/dist/integration-engine/models");
|
|
53
46
|
const workers_1 = require("@golemio/core/dist/integration-engine/workers");
|
|
54
47
|
const ropid_gtfs_1 = require("../../schema-definitions/ropid-gtfs");
|
|
55
|
-
const RopidGTFSTripsModel_1 = require("../ropid-gtfs/RopidGTFSTripsModel");
|
|
56
48
|
const vehicle_positions_1 = require("../../schema-definitions/vehicle-positions");
|
|
57
|
-
const _1 = require("./");
|
|
58
49
|
const const_1 = require("../../const");
|
|
59
|
-
const
|
|
50
|
+
const RopidGTFSTripsModel_1 = require("../ropid-gtfs/RopidGTFSTripsModel");
|
|
60
51
|
const RopidGTFSStopTimesModel_1 = require("../ropid-gtfs/RopidGTFSStopTimesModel");
|
|
52
|
+
const models_2 = require("./models");
|
|
53
|
+
const transformations_1 = require("./transformations");
|
|
54
|
+
const VehiclePositionsUtils_1 = require("./VehiclePositionsUtils");
|
|
61
55
|
var PositionHandlerEnum;
|
|
62
56
|
(function (PositionHandlerEnum) {
|
|
63
57
|
PositionHandlerEnum["TRACKING"] = "TRACKING";
|
|
@@ -109,10 +103,11 @@ class VehiclePositionsWorker extends workers_1.BaseWorker {
|
|
|
109
103
|
}
|
|
110
104
|
}
|
|
111
105
|
for (const key in chunks) {
|
|
112
|
-
const
|
|
106
|
+
const positions = transformedData.positions.filter((position) => chunks[key].includes(position.trips_id));
|
|
107
|
+
const updatedTrips = yield this.modelTrips.findAllAssocTripIds(chunks[key]);
|
|
113
108
|
yield this.sendMessageToExchange("workers." + this.queuePrefix + ".updateDelay", JSON.stringify({
|
|
114
|
-
positions
|
|
115
|
-
updatedTrips
|
|
109
|
+
positions,
|
|
110
|
+
updatedTrips,
|
|
116
111
|
}));
|
|
117
112
|
}
|
|
118
113
|
});
|
|
@@ -131,7 +126,7 @@ class VehiclePositionsWorker extends workers_1.BaseWorker {
|
|
|
131
126
|
this.updateGTFSTripId = (msg) => __awaiter(this, void 0, void 0, function* () {
|
|
132
127
|
const inputData = JSON.parse(msg.content.toString());
|
|
133
128
|
// unique ids in input data in key-value (id-positions) structure
|
|
134
|
-
|
|
129
|
+
let positionsByIds = {};
|
|
135
130
|
for (const position of inputData.positions) {
|
|
136
131
|
positionsByIds[position.trips_id] = position;
|
|
137
132
|
}
|
|
@@ -140,13 +135,13 @@ class VehiclePositionsWorker extends workers_1.BaseWorker {
|
|
|
140
135
|
if (!trip.origin_route_name || !trip.sequence_id || !positionsByIds[trip.id].origin_timestamp)
|
|
141
136
|
return;
|
|
142
137
|
const timestampLast = (0, moment_timezone_1.default)(positionsByIds[trip.id].origin_timestamp).tz("Europe/Prague").format();
|
|
143
|
-
return this.
|
|
138
|
+
return this.setAndReturnScheduledTrips({
|
|
144
139
|
route_id: trip.origin_route_name,
|
|
145
140
|
run_number: trip.sequence_id,
|
|
146
141
|
msg_last_timestamp: timestampLast,
|
|
147
142
|
});
|
|
148
143
|
}));
|
|
149
|
-
// find for each trip
|
|
144
|
+
// find gtfs data for each trip
|
|
150
145
|
const promiseValues = yield Promise.all(inputData.trips.map((trip) => __awaiter(this, void 0, void 0, function* () {
|
|
151
146
|
try {
|
|
152
147
|
return yield this.modelTrips.findGTFSTripId(trip);
|
|
@@ -156,35 +151,71 @@ class VehiclePositionsWorker extends workers_1.BaseWorker {
|
|
|
156
151
|
return err;
|
|
157
152
|
}
|
|
158
153
|
})));
|
|
154
|
+
let existingTripsPromiseValues = [], existingTripsPromiseErrors = [];
|
|
159
155
|
// filter only trips with found gtfs data
|
|
160
|
-
const
|
|
161
|
-
|
|
156
|
+
for (const trip of promiseValues) {
|
|
157
|
+
if (trip instanceof golemio_errors_1.CustomError) {
|
|
158
|
+
existingTripsPromiseErrors.push(trip);
|
|
159
|
+
}
|
|
160
|
+
else if (trip instanceof Array) {
|
|
161
|
+
existingTripsPromiseValues.push(...trip);
|
|
162
|
+
}
|
|
163
|
+
else if ((trip === null || trip === void 0 ? void 0 : trip.constructor) === Object) {
|
|
164
|
+
existingTripsPromiseValues.push(trip);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
let tripsByBlockId = {};
|
|
168
|
+
for (const trip of existingTripsPromiseValues) {
|
|
169
|
+
if (!trip.gtfs_block_id || !trip.gtfs_trip_id)
|
|
170
|
+
continue;
|
|
171
|
+
if (!tripsByBlockId[trip.gtfs_block_id]) {
|
|
172
|
+
tripsByBlockId[trip.gtfs_block_id] = new Set();
|
|
173
|
+
}
|
|
174
|
+
tripsByBlockId[trip.gtfs_block_id].add(trip.gtfs_trip_id);
|
|
175
|
+
}
|
|
176
|
+
// create cache for trip stops (grouped by block id)
|
|
177
|
+
const tripStopsSchedulesByBlockIds = yield Object.entries(tripsByBlockId).reduce((acc, [blockId, tripIds]) => __awaiter(this, void 0, void 0, function* () {
|
|
178
|
+
const tripStops = yield acc;
|
|
179
|
+
try {
|
|
180
|
+
tripStops[blockId] = yield this.setAndReturnTripStopsSchedule(blockId, [...tripIds]);
|
|
181
|
+
}
|
|
182
|
+
catch (err) {
|
|
183
|
+
helpers_1.IntegrationErrorHandler.handle(err);
|
|
184
|
+
}
|
|
185
|
+
return acc;
|
|
186
|
+
}), Promise.resolve({}));
|
|
162
187
|
let currentPosition;
|
|
163
|
-
for (const trip of
|
|
188
|
+
for (const trip of existingTripsPromiseValues) {
|
|
164
189
|
if (positionsByIds[trip.id]) {
|
|
165
190
|
currentPosition = positionsByIds[trip.id];
|
|
191
|
+
continue;
|
|
166
192
|
}
|
|
167
|
-
|
|
168
|
-
|
|
193
|
+
if (!currentPosition) {
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
const { shouldCreateNewPosition, trackingStatus } = VehiclePositionsUtils_1.VehiclePositionsUtils.determineNewPositionTracking(tripStopsSchedulesByBlockIds[trip.gtfs_block_id], trip, currentPosition);
|
|
197
|
+
if (shouldCreateNewPosition) {
|
|
198
|
+
// duplicate position with new created trip for second trip
|
|
169
199
|
const newPosition = Object.assign({}, currentPosition);
|
|
170
200
|
newPosition.trips_id = trip.id;
|
|
201
|
+
newPosition.tracking = trackingStatus !== null && trackingStatus !== void 0 ? trackingStatus : newPosition.tracking;
|
|
171
202
|
inputData.positions.push(newPosition);
|
|
172
203
|
}
|
|
173
204
|
}
|
|
174
205
|
yield this.modelPositions.save(inputData.positions);
|
|
175
206
|
// successfully updated gtfs ids
|
|
176
|
-
for (let i = 0, chunkSize = 100, imax =
|
|
207
|
+
for (let i = 0, chunkSize = 100, imax = existingTripsPromiseValues.length; i < imax; i += chunkSize) {
|
|
177
208
|
yield this.sendMessageToExchange("workers." + this.queuePrefix + ".updateDelay", JSON.stringify({
|
|
178
209
|
positions: [],
|
|
179
|
-
updatedTrips:
|
|
210
|
+
updatedTrips: existingTripsPromiseValues.slice(i, i + chunkSize),
|
|
180
211
|
}));
|
|
181
212
|
}
|
|
182
213
|
// gtfsId updating errors
|
|
183
|
-
for (let i = 0, imax =
|
|
184
|
-
helpers_1.IntegrationErrorHandler.handle(
|
|
214
|
+
for (let i = 0, imax = existingTripsPromiseErrors.length; i < imax; i++) {
|
|
215
|
+
helpers_1.IntegrationErrorHandler.handle(existingTripsPromiseErrors[i]);
|
|
185
216
|
}
|
|
186
217
|
});
|
|
187
|
-
this.generateGtfsRt = (
|
|
218
|
+
this.generateGtfsRt = () => __awaiter(this, void 0, void 0, function* () {
|
|
188
219
|
const results = yield this.modelTrips.findAllForGTFSRt();
|
|
189
220
|
const updatesMessage = gtfsRealtime.FeedMessage.create();
|
|
190
221
|
const positionsMessage = gtfsRealtime.FeedMessage.create();
|
|
@@ -205,7 +236,7 @@ class VehiclePositionsWorker extends workers_1.BaseWorker {
|
|
|
205
236
|
tripId: r.gtfs_trip_id,
|
|
206
237
|
routeId: r.gtfs_route_id,
|
|
207
238
|
};
|
|
208
|
-
const vehicleDescriptor = Object.assign({ id: r.gtfs_route_type ===
|
|
239
|
+
const vehicleDescriptor = Object.assign({ id: r.gtfs_route_type === models_2.GTFSRouteTypeEnum.TRAIN
|
|
209
240
|
? "train-" + r.cis_trip_number
|
|
210
241
|
: "service-" + r.gtfs_route_type + "-" + r.vehicle_registration_number }, (r.vehicle_registration_number && {
|
|
211
242
|
label: r.vehicle_registration_number,
|
|
@@ -334,10 +365,10 @@ class VehiclePositionsWorker extends workers_1.BaseWorker {
|
|
|
334
365
|
const tripIds = inputData.updatedTrips.map((trip) => trip.id);
|
|
335
366
|
if (((_b = inputData.positions) === null || _b === void 0 ? void 0 : _b.length) > 0) {
|
|
336
367
|
// unique ids in input data in key-value (id-positions) structure
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
}
|
|
368
|
+
let positionsByIds = {};
|
|
369
|
+
for (const position of inputData.positions) {
|
|
370
|
+
positionsByIds[position.trips_id] = position;
|
|
371
|
+
}
|
|
341
372
|
// unique block_id's and its parent input trips_id in key-value (block_id-trips_id) structure
|
|
342
373
|
const blockIdsToParentTripsId = inputData.updatedTrips.reduce((acc, currentTrip) => {
|
|
343
374
|
if (!acc[currentTrip.gtfs_block_id]) {
|
|
@@ -353,13 +384,34 @@ class VehiclePositionsWorker extends workers_1.BaseWorker {
|
|
|
353
384
|
}
|
|
354
385
|
return acc;
|
|
355
386
|
}, {});
|
|
387
|
+
// Get cached schedule for each unique block_id
|
|
388
|
+
const tripStopsSchedulesByBlockIds = yield Object.keys(blockIdsToParentTripsId).reduce((acc, blockId) => __awaiter(this, void 0, void 0, function* () {
|
|
389
|
+
const tripStops = yield acc;
|
|
390
|
+
try {
|
|
391
|
+
const schedule = yield this.tripStopsModel.get(blockId);
|
|
392
|
+
if (schedule) {
|
|
393
|
+
tripStops[blockId] = schedule;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
catch (err) {
|
|
397
|
+
helpers_1.IntegrationErrorHandler.handle(err);
|
|
398
|
+
}
|
|
399
|
+
return acc;
|
|
400
|
+
}), Promise.resolve({}));
|
|
356
401
|
// duplicate positions for trips with block_ids
|
|
357
402
|
for (const trip of inputData.updatedTrips) {
|
|
358
|
-
if (
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
403
|
+
if (positionsByIds[trip.id]) {
|
|
404
|
+
continue;
|
|
405
|
+
}
|
|
406
|
+
const currentPosition = inputData.positions.find((position) => {
|
|
407
|
+
return position.trips_id === blockIdsToParentTripsId[trip.gtfs_block_id];
|
|
408
|
+
});
|
|
409
|
+
const { shouldCreateNewPosition, trackingStatus } = VehiclePositionsUtils_1.VehiclePositionsUtils.determineNewPositionTracking(tripStopsSchedulesByBlockIds[trip.gtfs_block_id], trip, currentPosition);
|
|
410
|
+
if (shouldCreateNewPosition) {
|
|
411
|
+
// duplicate position with new created trip for second trip
|
|
412
|
+
const newPosition = Object.assign({}, currentPosition);
|
|
362
413
|
newPosition.trips_id = trip.id;
|
|
414
|
+
newPosition.tracking = trackingStatus !== null && trackingStatus !== void 0 ? trackingStatus : newPosition.tracking;
|
|
363
415
|
inputData.positions.push(newPosition);
|
|
364
416
|
}
|
|
365
417
|
}
|
|
@@ -382,7 +434,7 @@ class VehiclePositionsWorker extends workers_1.BaseWorker {
|
|
|
382
434
|
helpers_1.log.debug("Delay Computation data (Redis) was not found. (gtfsTripId = " + trip.gtfs_trip_id + ")");
|
|
383
435
|
try {
|
|
384
436
|
const gtfs = yield this.getResultObjectForDelayCalculation(trip.gtfs_trip_id);
|
|
385
|
-
yield this.delayComputationTripsModel.set("trip_id", gtfs,
|
|
437
|
+
yield this.delayComputationTripsModel.set("trip_id", gtfs, VehiclePositionsUtils_1.VehiclePositionsUtils.DELAY_COMPUTATION_CACHE_TTL);
|
|
386
438
|
trip.gtfsData = gtfs;
|
|
387
439
|
}
|
|
388
440
|
catch (err) {
|
|
@@ -456,9 +508,8 @@ class VehiclePositionsWorker extends workers_1.BaseWorker {
|
|
|
456
508
|
* @returns {void}
|
|
457
509
|
*/
|
|
458
510
|
this.updateRunsGTFSTripId = (msg) => __awaiter(this, void 0, void 0, function* () {
|
|
459
|
-
var e_1, _e;
|
|
460
511
|
const input = JSON.parse(msg.content.toString());
|
|
461
|
-
const schedule = yield this.
|
|
512
|
+
const schedule = yield this.setAndReturnScheduledTrips(input.run);
|
|
462
513
|
const { actual_stop_timestamp_scheduled: actualStopTimestampScheduled, msg_timestamp: msgTimestamp, events: event, } = input.run_message;
|
|
463
514
|
const delayMsg = {
|
|
464
515
|
updatedTrips: [],
|
|
@@ -473,62 +524,51 @@ class VehiclePositionsWorker extends workers_1.BaseWorker {
|
|
|
473
524
|
}
|
|
474
525
|
return;
|
|
475
526
|
}
|
|
476
|
-
if (actualStopTimestampScheduled) {
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
yield this.modelPositions.upsertRunPosition(input, gtfsCurrentTrip, isCurrentTripTracking);
|
|
502
|
-
delayMsg.updatedTrips.push(currentTrip);
|
|
503
|
-
}
|
|
504
|
-
// last/next gtfs trip for run
|
|
505
|
-
const gtfsLastNextTrips = schedule.filter((el) => {
|
|
506
|
-
return (((asts.clone().subtract(15, "minutes") <= (0, moment_timezone_1.default)(el.end_timestamp) && (0, moment_timezone_1.default)(el.end_timestamp) <= asts) ||
|
|
507
|
-
(asts <= (0, moment_timezone_1.default)(el.start_timestamp) && (0, moment_timezone_1.default)(el.start_timestamp) <= asts.clone().add(60, "minutes"))) &&
|
|
508
|
-
el.trip_id !== (gtfsCurrentTrip === null || gtfsCurrentTrip === void 0 ? void 0 : gtfsCurrentTrip.trip_id));
|
|
509
|
-
});
|
|
510
|
-
try {
|
|
511
|
-
for (var gtfsLastNextTrips_1 = __asyncValues(gtfsLastNextTrips), gtfsLastNextTrips_1_1; gtfsLastNextTrips_1_1 = yield gtfsLastNextTrips_1.next(), !gtfsLastNextTrips_1_1.done;) {
|
|
512
|
-
const gtfsTrip = gtfsLastNextTrips_1_1.value;
|
|
513
|
-
const trip = yield this.modelTrips.upsertRunTrip(input, gtfsTrip);
|
|
514
|
-
yield this.modelPositions.upsertRunPosition(input, gtfsTrip, false);
|
|
515
|
-
delayMsg.updatedTrips.push(trip);
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
519
|
-
finally {
|
|
520
|
-
try {
|
|
521
|
-
if (gtfsLastNextTrips_1_1 && !gtfsLastNextTrips_1_1.done && (_e = gtfsLastNextTrips_1.return)) yield _e.call(gtfsLastNextTrips_1);
|
|
522
|
-
}
|
|
523
|
-
finally { if (e_1) throw e_1.error; }
|
|
524
|
-
}
|
|
525
|
-
// send to updateDelay only if there are some trips updated
|
|
526
|
-
if (delayMsg.updatedTrips.length > 0) {
|
|
527
|
-
yield this.sendMessageToExchange("workers." + this.queuePrefix + ".updateDelay", JSON.stringify(delayMsg));
|
|
528
|
-
}
|
|
527
|
+
if (!actualStopTimestampScheduled) {
|
|
528
|
+
helpers_1.log.warn(`updateRunsGTFSTripId: actualStopTimestampScheduled is not provided for current run: ${JSON.stringify(input.run)}`);
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
const asts = (0, moment_timezone_1.default)(+actualStopTimestampScheduled);
|
|
532
|
+
// current gtfs trip for run
|
|
533
|
+
const gtfsCurrentTrip = schedule.find((el, i) => {
|
|
534
|
+
return asts.isBetween((0, moment_timezone_1.default)(el.start_timestamp), (0, moment_timezone_1.default)(el.end_timestamp), "second", "[]");
|
|
535
|
+
});
|
|
536
|
+
let isCurrentTripTracking = false;
|
|
537
|
+
if (gtfsCurrentTrip &&
|
|
538
|
+
// tram is always on track while pushes messages only on stops
|
|
539
|
+
(gtfsCurrentTrip.route_type === models_2.GTFSRouteTypeEnum.TRAM ||
|
|
540
|
+
// when bus announces DEPARTURE TCP event, it means that trip is on track
|
|
541
|
+
(gtfsCurrentTrip.route_type === models_2.GTFSRouteTypeEnum.BUS && event === const_1.TCPEventEnum.DEPARTURED) ||
|
|
542
|
+
// when trip has set first stop time, and message timestamp is after scheduled start, set as tracking
|
|
543
|
+
(asts.isSame((0, moment_timezone_1.default)(gtfsCurrentTrip.start_timestamp)) &&
|
|
544
|
+
(0, moment_timezone_1.default)(msgTimestamp).isSameOrAfter((0, moment_timezone_1.default)(gtfsCurrentTrip.start_timestamp))) ||
|
|
545
|
+
// of course when trip announcing some next stop time in schedule, then set as tracking
|
|
546
|
+
asts.isAfter((0, moment_timezone_1.default)(gtfsCurrentTrip.start_timestamp)))) {
|
|
547
|
+
isCurrentTripTracking = true;
|
|
548
|
+
}
|
|
549
|
+
const gtfsCurrentTripId = gtfsCurrentTrip && gtfsCurrentTrip.trip_id;
|
|
550
|
+
if (!gtfsCurrentTripId) {
|
|
551
|
+
helpers_1.log.warn(`updateRunsGTFSTripId: could not find current gtfsTrip for run: ${JSON.stringify(input)}`);
|
|
529
552
|
}
|
|
530
553
|
else {
|
|
531
|
-
|
|
554
|
+
const currentTrip = yield this.modelTrips.upsertRunTrip(input, gtfsCurrentTrip);
|
|
555
|
+
yield this.modelPositions.upsertRunPosition(input, gtfsCurrentTrip, isCurrentTripTracking);
|
|
556
|
+
delayMsg.updatedTrips.push(currentTrip);
|
|
557
|
+
}
|
|
558
|
+
// last/next gtfs trip for run
|
|
559
|
+
const gtfsLastNextTrips = schedule.filter((el) => {
|
|
560
|
+
return (((asts.clone().subtract(15, "minutes") <= (0, moment_timezone_1.default)(el.end_timestamp) && (0, moment_timezone_1.default)(el.end_timestamp) <= asts) ||
|
|
561
|
+
(asts <= (0, moment_timezone_1.default)(el.start_timestamp) && (0, moment_timezone_1.default)(el.start_timestamp) <= asts.clone().add(60, "minutes"))) &&
|
|
562
|
+
el.trip_id !== (gtfsCurrentTrip === null || gtfsCurrentTrip === void 0 ? void 0 : gtfsCurrentTrip.trip_id));
|
|
563
|
+
});
|
|
564
|
+
for (const gtfsTrip of gtfsLastNextTrips) {
|
|
565
|
+
const trip = yield this.modelTrips.upsertRunTrip(input, gtfsTrip);
|
|
566
|
+
yield this.modelPositions.upsertRunPosition(input, gtfsTrip, false);
|
|
567
|
+
delayMsg.updatedTrips.push(trip);
|
|
568
|
+
}
|
|
569
|
+
// send to updateDelay only if there are some trips updated
|
|
570
|
+
if (delayMsg.updatedTrips.length > 0) {
|
|
571
|
+
yield this.sendMessageToExchange("workers." + this.queuePrefix + ".updateDelay", JSON.stringify(delayMsg));
|
|
532
572
|
}
|
|
533
573
|
});
|
|
534
574
|
/**
|
|
@@ -558,7 +598,7 @@ class VehiclePositionsWorker extends workers_1.BaseWorker {
|
|
|
558
598
|
*
|
|
559
599
|
* @returns {string[]} array of tripIds
|
|
560
600
|
*/
|
|
561
|
-
this.
|
|
601
|
+
this.setAndReturnScheduledTrips = (scheduleData) => __awaiter(this, void 0, void 0, function* () {
|
|
562
602
|
const { route_id, run_number, msg_last_timestamp } = scheduleData;
|
|
563
603
|
const scheduledTripIds = yield this.runTripsModel.get(`${route_id}_${run_number}`);
|
|
564
604
|
if (!(scheduledTripIds === null || scheduledTripIds === void 0 ? void 0 : scheduledTripIds.schedule)) {
|
|
@@ -568,11 +608,34 @@ class VehiclePositionsWorker extends workers_1.BaseWorker {
|
|
|
568
608
|
el.start_timestamp = (0, moment_timezone_1.default)(el.start_timestamp).tz("Europe/Prague").format();
|
|
569
609
|
el.end_timestamp = (0, moment_timezone_1.default)(el.end_timestamp).tz("Europe/Prague").format();
|
|
570
610
|
});
|
|
571
|
-
yield this.runTripsModel.set(`${route_id}_${run_number}`, { schedule: result },
|
|
611
|
+
yield this.runTripsModel.set(`${route_id}_${run_number}`, { schedule: result }, VehiclePositionsUtils_1.VehiclePositionsUtils.RUN_TRIPS_CACHE_TTL);
|
|
572
612
|
return result;
|
|
573
613
|
}
|
|
574
614
|
return scheduledTripIds.schedule;
|
|
575
615
|
});
|
|
616
|
+
/**
|
|
617
|
+
* Get trip stops schedule by block id
|
|
618
|
+
*
|
|
619
|
+
* @param {string} blockId - Target gtfs block id
|
|
620
|
+
* @param {string} tripIds - List of inserted gtfs trip ids
|
|
621
|
+
*/
|
|
622
|
+
this.setAndReturnTripStopsSchedule = (blockId, tripIds) => __awaiter(this, void 0, void 0, function* () {
|
|
623
|
+
var _e;
|
|
624
|
+
const schedule = (_e = (yield this.tripStopsModel.get(blockId))) !== null && _e !== void 0 ? _e : {};
|
|
625
|
+
try {
|
|
626
|
+
const tripStops = yield this.modelGTFSStopTimes.findTripStops(tripIds);
|
|
627
|
+
const tripStopsSchedule = tripStops.reduce((acc, curr) => {
|
|
628
|
+
acc[curr.trip_id] = { trip_stops: curr.trip_stops };
|
|
629
|
+
return acc;
|
|
630
|
+
}, schedule);
|
|
631
|
+
yield this.tripStopsModel.set(blockId, tripStopsSchedule, VehiclePositionsUtils_1.VehiclePositionsUtils.TRIP_STOPS_CACHE_TTL);
|
|
632
|
+
return tripStopsSchedule;
|
|
633
|
+
}
|
|
634
|
+
catch (err) {
|
|
635
|
+
helpers_1.log.warn("Unable to retrieve trip stops", err);
|
|
636
|
+
return schedule;
|
|
637
|
+
}
|
|
638
|
+
});
|
|
576
639
|
/**
|
|
577
640
|
* Takes all newly computed positions and saves it, then save the last ones to the trips
|
|
578
641
|
*
|
|
@@ -680,9 +743,9 @@ class VehiclePositionsWorker extends workers_1.BaseWorker {
|
|
|
680
743
|
return PositionHandlerEnum.DO_NOTHING;
|
|
681
744
|
if (position.is_canceled)
|
|
682
745
|
return PositionHandlerEnum.CANCELED;
|
|
683
|
-
if (position.lat && position.lng && position.tracking ===
|
|
746
|
+
if (position.lat && position.lng && position.tracking === const_1.PositionTrackingEnum.TRACKING)
|
|
684
747
|
return PositionHandlerEnum.TRACKING;
|
|
685
|
-
if (position.tracking !==
|
|
748
|
+
if (position.tracking !== const_1.PositionTrackingEnum.TRACKING)
|
|
686
749
|
return PositionHandlerEnum.NOT_TRACKING;
|
|
687
750
|
return PositionHandlerEnum.NOT_TRACKING;
|
|
688
751
|
};
|
|
@@ -732,7 +795,7 @@ class VehiclePositionsWorker extends workers_1.BaseWorker {
|
|
|
732
795
|
}
|
|
733
796
|
else {
|
|
734
797
|
// if there is tracking 2 position with same origin_timestamp then this position is duplicate
|
|
735
|
-
const statePosition = tripPositions.positions.find((e) => e.origin_timestamp === position.origin_timestamp && e.tracking ===
|
|
798
|
+
const statePosition = tripPositions.positions.find((e) => e.origin_timestamp === position.origin_timestamp && e.tracking === const_1.PositionTrackingEnum.TRACKING)
|
|
736
799
|
? const_1.StatePositionEnum.DUPLICATE
|
|
737
800
|
: const_1.StatePositionEnum.AFTER_TRACK;
|
|
738
801
|
const lastShapesAnchorPoint = tripPositions.gtfsData.shapes_anchor_points[tripPositions.gtfsData.shapes_anchor_points.length - 1];
|
|
@@ -825,7 +888,6 @@ class VehiclePositionsWorker extends workers_1.BaseWorker {
|
|
|
825
888
|
.valueOf();
|
|
826
889
|
};
|
|
827
890
|
// FIND ALL SHAPE POINTS IN POLYGON CIRCLE, GET SEGMENTS WITH CONSEQUENTING POINTS
|
|
828
|
-
// TODO this should a class method
|
|
829
891
|
this.getShapePointsAroundPosition = (tripShapePoints, radius) => __awaiter(this, void 0, void 0, function* () {
|
|
830
892
|
const ptsInRadius = [];
|
|
831
893
|
let segmentIndex = 0;
|
|
@@ -983,9 +1045,9 @@ class VehiclePositionsWorker extends workers_1.BaseWorker {
|
|
|
983
1045
|
if (Math.abs(timeRealDiff) < Math.abs(minTimeRealDiff)) {
|
|
984
1046
|
minTimeRealDiff = timeRealDiff;
|
|
985
1047
|
// push trip into nearest at_stop shape anchor point if trip "P" event (tram) / "V" event (bus)
|
|
986
|
-
if (((gtfsRouteType ===
|
|
1048
|
+
if (((gtfsRouteType === models_2.GTFSRouteTypeEnum.TRAM &&
|
|
987
1049
|
currentPosition.properties.tcp_event === const_1.TCPEventEnum.ARRIVAL_ANNOUNCED) ||
|
|
988
|
-
(gtfsRouteType ===
|
|
1050
|
+
(gtfsRouteType === models_2.GTFSRouteTypeEnum.BUS && currentPosition.properties.tcp_event === const_1.TCPEventEnum.V)) &&
|
|
989
1051
|
thisClosestPoint.this_stop_sequence === null) {
|
|
990
1052
|
let movingShapePointIndex = thisClosestPoint.index;
|
|
991
1053
|
while (thisClosestPoint.this_stop_sequence === null && movingShapePointIndex < lastTripShapePoint.index) {
|
|
@@ -1000,7 +1062,7 @@ class VehiclePositionsWorker extends workers_1.BaseWorker {
|
|
|
1000
1062
|
statePosition = const_1.StatePositionEnum.ON_TRACK;
|
|
1001
1063
|
}
|
|
1002
1064
|
// if tram position has "V" avent tram is after track
|
|
1003
|
-
if (gtfsRouteType ===
|
|
1065
|
+
if (gtfsRouteType === models_2.GTFSRouteTypeEnum.TRAM && currentPosition.properties.tcp_event === const_1.TCPEventEnum.V) {
|
|
1004
1066
|
statePosition = const_1.StatePositionEnum.AFTER_TRACK;
|
|
1005
1067
|
thisClosestPoint = lastTripShapePoint;
|
|
1006
1068
|
timeDelay = null;
|
|
@@ -1312,31 +1374,37 @@ class VehiclePositionsWorker extends workers_1.BaseWorker {
|
|
|
1312
1374
|
}
|
|
1313
1375
|
return resultSegmentPoints;
|
|
1314
1376
|
};
|
|
1315
|
-
this.modelPositions = new
|
|
1316
|
-
this.modelStops = new
|
|
1317
|
-
this.modelRuns = new
|
|
1318
|
-
this.transformationRuns = new
|
|
1319
|
-
this.modelTrips = new
|
|
1320
|
-
this.transformation = new
|
|
1377
|
+
this.modelPositions = new models_2.VehiclePositionsPositionsModel();
|
|
1378
|
+
this.modelStops = new models_2.VehiclePositionsStopsModel();
|
|
1379
|
+
this.modelRuns = new models_2.VehiclePositionsRunsModel();
|
|
1380
|
+
this.transformationRuns = new transformations_1.VehiclePositionsRunsTransformation();
|
|
1381
|
+
this.modelTrips = new models_2.VehiclePositionsTripsModel();
|
|
1382
|
+
this.transformation = new transformations_1.VehiclePositionsTransformation();
|
|
1321
1383
|
this.delayComputationTripsModel = new models_1.RedisModel(ropid_gtfs_1.RopidGTFS.delayComputationTrips.name + "Model", {
|
|
1322
1384
|
decodeDataAfterGet: JSON.parse,
|
|
1323
1385
|
encodeDataBeforeSave: JSON.stringify,
|
|
1324
1386
|
isKeyConstructedFromData: true,
|
|
1325
1387
|
prefix: ropid_gtfs_1.RopidGTFS.delayComputationTrips.mongoCollectionName,
|
|
1326
1388
|
}, new golemio_validator_1.Validator(ropid_gtfs_1.RopidGTFS.delayComputationTrips.name + "ModelValidator", ropid_gtfs_1.RopidGTFS.delayComputationTrips.outputMongooseSchemaObject));
|
|
1327
|
-
this.runTripsModel = new models_1.RedisModel(vehicle_positions_1.VehiclePositions.
|
|
1389
|
+
this.runTripsModel = new models_1.RedisModel(vehicle_positions_1.VehiclePositions.runsTrips.name + "Model", {
|
|
1328
1390
|
decodeDataAfterGet: JSON.parse,
|
|
1329
1391
|
encodeDataBeforeSave: JSON.stringify,
|
|
1330
1392
|
isKeyConstructedFromData: false,
|
|
1331
|
-
prefix: vehicle_positions_1.VehiclePositions.
|
|
1332
|
-
}, new golemio_validator_1.Validator(vehicle_positions_1.VehiclePositions.
|
|
1393
|
+
prefix: vehicle_positions_1.VehiclePositions.runsTrips.namespacePrefix,
|
|
1394
|
+
}, new golemio_validator_1.Validator(vehicle_positions_1.VehiclePositions.runsTrips.name + "ModelValidator", vehicle_positions_1.VehiclePositions.runsTrips.outputMongooseSchemaObject));
|
|
1333
1395
|
this.queuePrefix = config_1.config.RABBIT_EXCHANGE_NAME + "." + vehicle_positions_1.VehiclePositions.name.toLowerCase();
|
|
1334
1396
|
this.gtfsRtModel = new models_1.RedisModel("GTFSRealTimeModel", {
|
|
1335
1397
|
isKeyConstructedFromData: false,
|
|
1336
1398
|
prefix: "files:gtfsRt",
|
|
1337
1399
|
});
|
|
1338
|
-
this.
|
|
1400
|
+
this.tripStopsModel = new models_1.RedisModel(vehicle_positions_1.VehiclePositions.tripStops.name + "Model", {
|
|
1401
|
+
decodeDataAfterGet: JSON.parse,
|
|
1402
|
+
encodeDataBeforeSave: JSON.stringify,
|
|
1403
|
+
isKeyConstructedFromData: false,
|
|
1404
|
+
prefix: vehicle_positions_1.VehiclePositions.tripStops.namespacePrefix,
|
|
1405
|
+
}, new golemio_validator_1.Validator(vehicle_positions_1.VehiclePositions.tripStops.name + "ModelValidator", vehicle_positions_1.VehiclePositions.tripStops.outputMongooseSchemaObject));
|
|
1339
1406
|
this.modelGTFSTrips = new RopidGTFSTripsModel_1.RopidGTFSTripsModel();
|
|
1407
|
+
this.modelGTFSStopTimes = new RopidGTFSStopTimesModel_1.RopidGTFSStopTimesModel();
|
|
1340
1408
|
// Create trips upsert queue for preventing transaction deadlocks
|
|
1341
1409
|
this.upsertTripsFQ = fastq_1.default.promise(this.modelTrips.bulkUpsert, 1);
|
|
1342
1410
|
}
|