@golemio/pid 2.12.11-dev.1276079620 → 2.12.11-dev.1276112660
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/output-gateway/public/service/helpers/trip-scope/strategy/StopTimesTripScopeHandler.d.ts +1 -0
- package/dist/output-gateway/public/service/helpers/trip-scope/strategy/StopTimesTripScopeHandler.js +18 -0
- package/dist/output-gateway/public/service/helpers/trip-scope/strategy/StopTimesTripScopeHandler.js.map +1 -1
- package/package.json +1 -1
|
@@ -10,4 +10,5 @@ export declare class StopTimesTripScopeHandler extends AbstractTripScopeHandler
|
|
|
10
10
|
constructor(delayComputationRepository: IDelayComputationRepository, stopTimeRepository: IStopTimeRepository);
|
|
11
11
|
handle(output: IPublicApiDetailedTrip, vehiclePosition: IPublicApiCacheDto): Promise<IPublicApiDetailedTrip>;
|
|
12
12
|
private filterNoStopWaypoints;
|
|
13
|
+
private shouldFallbackToScheduleTime;
|
|
13
14
|
}
|
package/dist/output-gateway/public/service/helpers/trip-scope/strategy/StopTimesTripScopeHandler.js
CHANGED
|
@@ -29,6 +29,7 @@ const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
|
|
|
29
29
|
const luxon_1 = require("@golemio/core/dist/shared/luxon");
|
|
30
30
|
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
|
|
31
31
|
const AbstractTripScopeHandler_1 = require("./AbstractTripScopeHandler");
|
|
32
|
+
const const_1 = require("../../../../../../const");
|
|
32
33
|
let StopTimesTripScopeHandler = exports.StopTimesTripScopeHandler = class StopTimesTripScopeHandler extends AbstractTripScopeHandler_1.AbstractTripScopeHandler {
|
|
33
34
|
constructor(delayComputationRepository, stopTimeRepository) {
|
|
34
35
|
super();
|
|
@@ -44,6 +45,18 @@ let StopTimesTripScopeHandler = exports.StopTimesTripScopeHandler = class StopTi
|
|
|
44
45
|
}
|
|
45
46
|
const filteredStopTimes = this.filterNoStopWaypoints(delayComputationCache.stop_times);
|
|
46
47
|
const stopTimes = this.tripStopTimesTransformation.transformArray(filteredStopTimes);
|
|
48
|
+
// TODO this is a temporary solution, we need to fix the underlying issue in the source view
|
|
49
|
+
// v_public_vehiclepositions_combined_stop_times, the delay prediction is seemingly not working properly
|
|
50
|
+
// when the vehicle is before the track, see https://gitlab.com/operator-ict/golemio/code/modules/pid/-/issues/371
|
|
51
|
+
if (this.shouldFallbackToScheduleTime(vehiclePosition)) {
|
|
52
|
+
for (let i = 0; i < stopTimes.length; i++) {
|
|
53
|
+
const stopTime = stopTimes[i];
|
|
54
|
+
stopTime.properties.realtime_arrival_time = stopTime.properties.arrival_time;
|
|
55
|
+
stopTime.properties.realtime_departure_time = stopTime.properties.departure_time;
|
|
56
|
+
}
|
|
57
|
+
output.stop_times = (0, Geo_1.buildGeojsonFeatureCollection)(stopTimes);
|
|
58
|
+
return output;
|
|
59
|
+
}
|
|
47
60
|
const stopTimesWithDelay = yield this.stopTimeRepository.getPublicStopTimeCache(vehiclePosition.vehicle_id);
|
|
48
61
|
if (stopTimesWithDelay.length > 0) {
|
|
49
62
|
for (const stopTimeWithDelay of stopTimesWithDelay) {
|
|
@@ -72,6 +85,11 @@ let StopTimesTripScopeHandler = exports.StopTimesTripScopeHandler = class StopTi
|
|
|
72
85
|
filterNoStopWaypoints(stopTimes) {
|
|
73
86
|
return stopTimes.filter((stopTime) => !stopTime.is_no_stop_waypoint);
|
|
74
87
|
}
|
|
88
|
+
shouldFallbackToScheduleTime(vehiclePosition) {
|
|
89
|
+
return ((vehiclePosition.state_position === const_1.StatePositionEnum.BEFORE_TRACK ||
|
|
90
|
+
vehiclePosition.state_position === const_1.StatePositionEnum.BEFORE_TRACK_DELAYED) &&
|
|
91
|
+
vehiclePosition.delay === 0);
|
|
92
|
+
}
|
|
75
93
|
};
|
|
76
94
|
exports.StopTimesTripScopeHandler = StopTimesTripScopeHandler = __decorate([
|
|
77
95
|
(0, tsyringe_1.injectable)(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StopTimesTripScopeHandler.js","sourceRoot":"","sources":["../../../../../../../src/output-gateway/public/service/helpers/trip-scope/strategy/StopTimesTripScopeHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAMA,iEAA6D;AAC7D,6HAAoI;AAEpI,+DAAsF;AAEtF,6EAAwE;AACxE,2DAA2D;AAC3D,iEAAwE;AACxE,yEAAsE;
|
|
1
|
+
{"version":3,"file":"StopTimesTripScopeHandler.js","sourceRoot":"","sources":["../../../../../../../src/output-gateway/public/service/helpers/trip-scope/strategy/StopTimesTripScopeHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAMA,iEAA6D;AAC7D,6HAAoI;AAEpI,+DAAsF;AAEtF,6EAAwE;AACxE,2DAA2D;AAC3D,iEAAwE;AACxE,yEAAsE;AAEtE,mDAA8C;AAGvC,IAAM,yBAAyB,uCAA/B,MAAM,yBAA0B,SAAQ,mDAAwB;IAGnE,YAC8D,0BAAuD,EACzD,kBAAuC;QAE/F,KAAK,EAAE,CAAC;QAHkD,+BAA0B,GAA1B,0BAA0B,CAA6B;QACzD,uBAAkB,GAAlB,kBAAkB,CAAqB;QAG/F,IAAI,CAAC,2BAA2B,GAAG,IAAI,yEAAmC,EAAE,CAAC;IACjF,CAAC;IAEY,MAAM,CAAC,MAA8B,EAAE,eAAmC;;YACnF,MAAM,qBAAqB,GAAG,MAAM,IAAI,CAAC,0BAA0B,CAAC,wBAAwB,CACxF,eAAe,CAAC,YAAY,CAC/B,CAAC;YAEF,IAAI,CAAC,qBAAqB,EAAE;gBACxB,MAAM,IAAI,6BAAY,CAAC,mCAAmC,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;aACtG;YAED,MAAM,iBAAiB,GAAG,IAAI,CAAC,qBAAqB,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;YACvF,MAAM,SAAS,GAAG,IAAI,CAA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