@golemio/pid 2.2.12-dev.638695203 → 2.2.12-dev.639574289
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/integration-engine/vehicle-positions/helpers/compute-positions/strategy/AbstractDelayAtStop.d.ts +1 -0
- package/dist/integration-engine/vehicle-positions/helpers/compute-positions/strategy/AbstractDelayAtStop.js +9 -2
- package/dist/integration-engine/vehicle-positions/helpers/compute-positions/strategy/AbstractDelayAtStop.js.map +1 -1
- package/dist/integration-engine/vehicle-positions/helpers/compute-positions/strategy/BusDelayAtStop.js +1 -1
- package/dist/integration-engine/vehicle-positions/helpers/compute-positions/strategy/BusDelayAtStop.js.map +1 -1
- package/dist/integration-engine/vehicle-positions/helpers/compute-positions/strategy/TramDelayAtStop.js +1 -1
- package/dist/integration-engine/vehicle-positions/helpers/compute-positions/strategy/TramDelayAtStop.js.map +1 -1
- package/package.json +1 -1
|
@@ -5,5 +5,6 @@ export default abstract class AbstractDelayAtStop {
|
|
|
5
5
|
abstract updatePosition(context: IPositionsContext, positionToUpdate: IPositionToUpdate, position: ITripPositionAttributes): IPositionToUpdate;
|
|
6
6
|
protected calcDelayAtStop(actualTimestamp: number | string, scheduledTimstamp: number): number;
|
|
7
7
|
protected resetContext(context: IPositionsContext, positionToUpdate: IPositionToUpdate | null, position: ITripPositionAttributes | undefined): IPositionsContext;
|
|
8
|
+
protected isContextChange(context: IPositionsContext, positionToUpdate: IPositionToUpdate | null, position: ITripPositionAttributes | undefined): boolean;
|
|
8
9
|
protected updatePositionBasedOnContext(context: IPositionsContext, positionToUpdate: IPositionToUpdate): IPositionToUpdate;
|
|
9
10
|
}
|
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const const_1 = require("../../../../../const");
|
|
4
|
+
/* In some cases both position and positionToUpdate are checked for values.
|
|
5
|
+
* If position state is 'input' then expect value in positionToUpdate instance.
|
|
6
|
+
* If position was already processed positionToUpdate is null so position instance should be checked.
|
|
7
|
+
*/
|
|
4
8
|
class AbstractDelayAtStop {
|
|
5
9
|
calcDelayAtStop(actualTimestamp, scheduledTimstamp) {
|
|
6
10
|
return (new Date(actualTimestamp).valueOf() - new Date(scheduledTimstamp).valueOf()) / 1000;
|
|
7
11
|
}
|
|
8
12
|
resetContext(context, positionToUpdate, position) {
|
|
9
|
-
|
|
10
|
-
if (context.lastPositionLastStop.sequence !== ((_a = positionToUpdate === null || positionToUpdate === void 0 ? void 0 : positionToUpdate.last_stop_sequence) !== null && _a !== void 0 ? _a : position === null || position === void 0 ? void 0 : position.last_stop_sequence)) {
|
|
13
|
+
if (this.isContextChange(context, positionToUpdate, position)) {
|
|
11
14
|
context.lastPositionLastStop.arrival_time = null;
|
|
12
15
|
context.lastPositionLastStop.sequence = null;
|
|
13
16
|
context.lastPositionLastStop.departure_time = null;
|
|
14
17
|
}
|
|
15
18
|
return context;
|
|
16
19
|
}
|
|
20
|
+
isContextChange(context, positionToUpdate, position) {
|
|
21
|
+
var _a;
|
|
22
|
+
return context.lastPositionLastStop.sequence !== ((_a = positionToUpdate === null || positionToUpdate === void 0 ? void 0 : positionToUpdate.last_stop_sequence) !== null && _a !== void 0 ? _a : position === null || position === void 0 ? void 0 : position.last_stop_sequence);
|
|
23
|
+
}
|
|
17
24
|
updatePositionBasedOnContext(context, positionToUpdate) {
|
|
18
25
|
if (context.lastPositionLastStop.arrival_time && positionToUpdate.last_stop_arrival_time) {
|
|
19
26
|
positionToUpdate.delay_stop_arrival = this.calcDelayAtStop(context.lastPositionLastStop.arrival_time, positionToUpdate.last_stop_arrival_time);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractDelayAtStop.js","sourceRoot":"","sources":["../../../../../../src/integration-engine/vehicle-positions/helpers/compute-positions/strategy/AbstractDelayAtStop.ts"],"names":[],"mappings":";;AAEA,gDAA8C;AAE9C,MAA8B,mBAAmB;IAanC,eAAe,CAAC,eAAgC,EAAE,iBAAyB;QACjF,OAAO,CAAC,IAAI,IAAI,CAAC,eAAe,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,IAAI,CAAC,iBAAiB,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC;IAChG,CAAC;IAES,YAAY,CAClB,OAA0B,EAC1B,gBAA0C,EAC1C,QAA6C
|
|
1
|
+
{"version":3,"file":"AbstractDelayAtStop.js","sourceRoot":"","sources":["../../../../../../src/integration-engine/vehicle-positions/helpers/compute-positions/strategy/AbstractDelayAtStop.ts"],"names":[],"mappings":";;AAEA,gDAA8C;AAE9C;;;GAGG;AACH,MAA8B,mBAAmB;IAanC,eAAe,CAAC,eAAgC,EAAE,iBAAyB;QACjF,OAAO,CAAC,IAAI,IAAI,CAAC,eAAe,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,IAAI,CAAC,iBAAiB,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC;IAChG,CAAC;IAES,YAAY,CAClB,OAA0B,EAC1B,gBAA0C,EAC1C,QAA6C;QAE7C,IAAI,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,CAAC,EAAE;YAC3D,OAAO,CAAC,oBAAoB,CAAC,YAAY,GAAG,IAAI,CAAC;YACjD,OAAO,CAAC,oBAAoB,CAAC,QAAQ,GAAG,IAAI,CAAC;YAC7C,OAAO,CAAC,oBAAoB,CAAC,cAAc,GAAG,IAAI,CAAC;SACtD;QAED,OAAO,OAAO,CAAC;IACnB,CAAC;IAES,eAAe,CACrB,OAA0B,EAC1B,gBAA0C,EAC1C,QAA6C;;QAE7C,OAAO,OAAO,CAAC,oBAAoB,CAAC,QAAQ,KAAK,CAAC,MAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,kBAAkB,mCAAI,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,kBAAkB,CAAC,CAAC;IAC5H,CAAC;IAES,4BAA4B,CAAC,OAA0B,EAAE,gBAAmC;QAClG,IAAI,OAAO,CAAC,oBAAoB,CAAC,YAAY,IAAI,gBAAgB,CAAC,sBAAsB,EAAE;YACtF,gBAAgB,CAAC,kBAAkB,GAAG,IAAI,CAAC,eAAe,CACtD,OAAO,CAAC,oBAAoB,CAAC,YAAY,EACzC,gBAAgB,CAAC,sBAAsB,CAC1C,CAAC;SACL;QACD,IACI,OAAO,CAAC,oBAAoB,CAAC,cAAc;YAC3C,gBAAgB,CAAC,wBAAwB;YACzC,gBAAgB,CAAC,cAAc,KAAK,yBAAiB,CAAC,OAAO;YAC7D,gBAAgB,CAAC,cAAc,KAAK,yBAAiB,CAAC,WAAW,EACnE;YACE,gBAAgB,CAAC,oBAAoB,GAAG,IAAI,CAAC,eAAe,CACxD,OAAO,CAAC,oBAAoB,CAAC,cAAc,EAC3C,gBAAgB,CAAC,wBAAwB,CAC5C,CAAC;SACL;QAED,OAAO,gBAAgB,CAAC;IAC5B,CAAC;CACJ;AA5DD,sCA4DC"}
|
|
@@ -8,7 +8,6 @@ const AbstractDelayAtStop_1 = __importDefault(require("./AbstractDelayAtStop"));
|
|
|
8
8
|
class BusDelayAtStop extends AbstractDelayAtStop_1.default {
|
|
9
9
|
updateContext(context, positionToUpdate, position) {
|
|
10
10
|
var _a, _b, _c;
|
|
11
|
-
context = this.resetContext(context, positionToUpdate, position);
|
|
12
11
|
if (position && position.state_position === const_1.StatePositionEnum.AT_STOP) {
|
|
13
12
|
context.lastPositionLastStop.arrival_time = (_a = context.lastPositionLastStop.arrival_time) !== null && _a !== void 0 ? _a : position.origin_timestamp;
|
|
14
13
|
context.lastPositionLastStop.sequence = (_c = (_b = positionToUpdate === null || positionToUpdate === void 0 ? void 0 : positionToUpdate.this_stop_sequence) !== null && _b !== void 0 ? _b : position.this_stop_sequence) !== null && _c !== void 0 ? _c : null;
|
|
@@ -17,6 +16,7 @@ class BusDelayAtStop extends AbstractDelayAtStop_1.default {
|
|
|
17
16
|
return context;
|
|
18
17
|
}
|
|
19
18
|
updatePosition(context, positionToUpdate, position) {
|
|
19
|
+
context = this.resetContext(context, positionToUpdate, position);
|
|
20
20
|
positionToUpdate = this.updatePositionBasedOnContext(context, positionToUpdate);
|
|
21
21
|
if (position && positionToUpdate.state_position === const_1.StatePositionEnum.AT_STOP && !positionToUpdate.delay_stop_arrival) {
|
|
22
22
|
positionToUpdate.delay_stop_arrival = this.calcDelayAtStop(position.origin_timestamp, positionToUpdate.last_stop_arrival_time);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BusDelayAtStop.js","sourceRoot":"","sources":["../../../../../../src/integration-engine/vehicle-positions/helpers/compute-positions/strategy/BusDelayAtStop.ts"],"names":[],"mappings":";;;;;AAEA,gDAA8C;AAC9C,gFAAwD;AAExD,MAAqB,cAAe,SAAQ,6BAAmB;IACpD,aAAa,CAChB,OAA0B,EAC1B,gBAA0C,EAC1C,QAA6C;;QAE7C,
|
|
1
|
+
{"version":3,"file":"BusDelayAtStop.js","sourceRoot":"","sources":["../../../../../../src/integration-engine/vehicle-positions/helpers/compute-positions/strategy/BusDelayAtStop.ts"],"names":[],"mappings":";;;;;AAEA,gDAA8C;AAC9C,gFAAwD;AAExD,MAAqB,cAAe,SAAQ,6BAAmB;IACpD,aAAa,CAChB,OAA0B,EAC1B,gBAA0C,EAC1C,QAA6C;;QAE7C,IAAI,QAAQ,IAAI,QAAQ,CAAC,cAAc,KAAK,yBAAiB,CAAC,OAAO,EAAE;YACnE,OAAO,CAAC,oBAAoB,CAAC,YAAY,GAAG,MAAA,OAAO,CAAC,oBAAoB,CAAC,YAAY,mCAAI,QAAQ,CAAC,gBAAgB,CAAC;YACnH,OAAO,CAAC,oBAAoB,CAAC,QAAQ,GAAG,MAAA,MAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,kBAAkB,mCAAI,QAAQ,CAAC,kBAAkB,mCAAI,IAAI,CAAC;YACpH,OAAO,CAAC,oBAAoB,CAAC,cAAc,GAAG,QAAQ,CAAC,gBAAgB,CAAC;SAC3E;QAED,OAAO,OAAO,CAAC;IACnB,CAAC;IAEM,cAAc,CACjB,OAA0B,EAC1B,gBAAmC,EACnC,QAA6C;QAE7C,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,CAAC,CAAC;QACjE,gBAAgB,GAAG,IAAI,CAAC,4BAA4B,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;QAEhF,IAAI,QAAQ,IAAI,gBAAgB,CAAC,cAAc,KAAK,yBAAiB,CAAC,OAAO,IAAI,CAAC,gBAAgB,CAAC,kBAAkB,EAAE;YACnH,gBAAgB,CAAC,kBAAkB,GAAG,IAAI,CAAC,eAAe,CACtD,QAAQ,CAAC,gBAAgB,EACzB,gBAAgB,CAAC,sBAAuB,CAC3C,CAAC;SACL;QAED,OAAO,gBAAgB,CAAC;IAC5B,CAAC;CACJ;AAhCD,iCAgCC"}
|
|
@@ -8,7 +8,6 @@ const AbstractDelayAtStop_1 = __importDefault(require("./AbstractDelayAtStop"));
|
|
|
8
8
|
class TramDelayAtStop extends AbstractDelayAtStop_1.default {
|
|
9
9
|
updateContext(context, positionToUpdate, position) {
|
|
10
10
|
var _a, _b;
|
|
11
|
-
context = this.resetContext(context, positionToUpdate, position);
|
|
12
11
|
if (this.didTramArrive(position)) {
|
|
13
12
|
context.lastPositionLastStop.arrival_time = position.origin_timestamp;
|
|
14
13
|
context.lastPositionLastStop.sequence = (_b = (_a = positionToUpdate === null || positionToUpdate === void 0 ? void 0 : positionToUpdate.this_stop_sequence) !== null && _a !== void 0 ? _a : position === null || position === void 0 ? void 0 : position.this_stop_sequence) !== null && _b !== void 0 ? _b : null;
|
|
@@ -20,6 +19,7 @@ class TramDelayAtStop extends AbstractDelayAtStop_1.default {
|
|
|
20
19
|
return context;
|
|
21
20
|
}
|
|
22
21
|
updatePosition(context, positionToUpdate, position) {
|
|
22
|
+
context = this.resetContext(context, positionToUpdate, position);
|
|
23
23
|
positionToUpdate = this.updatePositionBasedOnContext(context, positionToUpdate);
|
|
24
24
|
if (position && this.didTramArrive(position)) {
|
|
25
25
|
positionToUpdate.delay_stop_arrival = this.calcDelayAtStop(position.origin_timestamp, positionToUpdate.last_stop_arrival_time);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TramDelayAtStop.js","sourceRoot":"","sources":["../../../../../../src/integration-engine/vehicle-positions/helpers/compute-positions/strategy/TramDelayAtStop.ts"],"names":[],"mappings":";;;;;AAEA,gDAA+D;AAC/D,gFAAwD;AAExD,MAAqB,eAAgB,SAAQ,6BAAmB;IACrD,aAAa,CAChB,OAA0B,EAC1B,gBAA0C,EAC1C,QAAiC;;QAEjC,
|
|
1
|
+
{"version":3,"file":"TramDelayAtStop.js","sourceRoot":"","sources":["../../../../../../src/integration-engine/vehicle-positions/helpers/compute-positions/strategy/TramDelayAtStop.ts"],"names":[],"mappings":";;;;;AAEA,gDAA+D;AAC/D,gFAAwD;AAExD,MAAqB,eAAgB,SAAQ,6BAAmB;IACrD,aAAa,CAChB,OAA0B,EAC1B,gBAA0C,EAC1C,QAAiC;;QAEjC,IAAI,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE;YAC9B,OAAO,CAAC,oBAAoB,CAAC,YAAY,GAAG,QAAQ,CAAC,gBAAgB,CAAC;YACtE,OAAO,CAAC,oBAAoB,CAAC,QAAQ,GAAG,MAAA,MAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,kBAAkB,mCAAI,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,kBAAkB,mCAAI,IAAI,CAAC;YACrH,OAAO,CAAC,oBAAoB,CAAC,cAAc,GAAG,IAAI,CAAC;SACtD;aAAM,IAAI,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,gBAAgB,EAAE,OAAO,CAAC,EAAE;YACnE,OAAO,CAAC,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