@golemio/pid 3.17.2-dev.1964072627 → 3.17.2-dev.1969248519
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/workers/vehicle-positions/data-access/PositionsRepository.js +2 -1
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/data-access/PositionsRepository.js.map +1 -1
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/helpers/BasePositionsManager.d.ts +90 -0
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/helpers/BasePositionsManager.js +316 -0
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/helpers/BasePositionsManager.js.map +1 -0
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/helpers/PositionsManager.d.ts +10 -61
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/helpers/PositionsManager.js +67 -280
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/helpers/PositionsManager.js.map +1 -1
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/helpers/regional-bus/RegionalBusPositionsManager.d.ts +10 -49
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/helpers/regional-bus/RegionalBusPositionsManager.js +16 -229
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/helpers/regional-bus/RegionalBusPositionsManager.js.map +1 -1
- package/package.json +1 -1
|
@@ -163,7 +163,7 @@ class PositionsRepository extends models_2.PostgresModel {
|
|
|
163
163
|
// Sequlize return with raw==true flatten array of results, nest==true is available for Sequelize ver >5 only
|
|
164
164
|
// We return objects of positions grouped by trips_id
|
|
165
165
|
try {
|
|
166
|
-
|
|
166
|
+
const positionsToReturn = results.reduce((p, c) => {
|
|
167
167
|
let pIndex = p.findIndex((e) => e.id === c.id);
|
|
168
168
|
if (pIndex === -1) {
|
|
169
169
|
p.push({
|
|
@@ -209,6 +209,7 @@ class PositionsRepository extends models_2.PostgresModel {
|
|
|
209
209
|
});
|
|
210
210
|
return p;
|
|
211
211
|
}, []);
|
|
212
|
+
return positionsToReturn;
|
|
212
213
|
}
|
|
213
214
|
catch (err) {
|
|
214
215
|
throw new golemio_errors_1.GeneralError(`Error while transforming data from db for batch. Trip count ${results.length}.`, this.name, err);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PositionsRepository.js","sourceRoot":"","sources":["../../../../../../src/integration-engine/vehicle-positions/workers/vehicle-positions/data-access/PositionsRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,mEAAuC;AACvC,2FAA0D;AAC1D,uFAA6D;AAC7D,wGAAwE;AAIxE,iFAAqF;AACrF,yEAAqF;AACrF,6EAAwE;AACxE,mFAAkF;AAClF,iFAAkF;AAClF,gDAAgE;AAGhE,gFAAwD;AAGxD,MAAa,mBAAoB,SAAQ,sBAAa;IAGlD;QACI,KAAK,CACD,uBAAuB,EACvB;YACI,yBAAyB,EAAE,yBAAW,CAAC,cAAc;YACrD,WAAW,EAAE,oCAAgB,CAAC,SAAS,CAAC,WAAW;YACnD,QAAQ,EAAE,iBAAS;YACnB,UAAU,EAAE,gBAAgB;YAC5B,2BAA2B,EAAE;gBACzB,OAAO,EAAE;oBACL;wBACI,MAAM,EAAE,CAAC,UAAU,CAAC;wBACpB,IAAI,EAAE,qCAAqC;qBAC9C;oBACD;wBACI,MAAM,EAAE,CAAC,aAAa,CAAC;wBACvB,IAAI,EAAE,wCAAwC;qBACjD;iBACJ;aACJ;SACJ,EACD,IAAI,uCAAmB,CAAC,oCAAgB,CAAC,SAAS,CAAC,IAAI,GAAG,gBAAgB,EAAE,yBAAW,CAAC,UAAU,CAAC,CACtG,CAAC;QAON;;;;;;;;;;;;;;WAcG;QACI,+BAA0B,GAAG,KAAK,EAAE,OAAiB,EAA6B,EAAE;YACvF,oEAAoE;YACpE,yEAAyE;YAEzE,wCAAwC;YACxC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;gBACtB,OAA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E;4CACf,wBAAgB,CAAC,KAAK;4CACtB,wBAAgB,CAAC,SAAS;4CAC1B,wBAAgB,CAAC,SAAS;yCAC7B;qCACJ;iCACJ;6BACJ;yBACJ;qBACJ;iBACJ;gBACD,KAAK,EAAE;oBACH,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,YAAY,EAAE,KAAK,CAAC;oBACrE,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,YAAY,EAAE,MAAM,CAAC;iBACzE;gBACD,GAAG,EAAE,IAAI;gBACT,KAAK,EAAE;oBACH,YAAY,EAAE,EAAE,CAAC,mBAAS,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE;oBACzC,EAAE,EAAE,EAAE,CAAC,mBAAS,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE;iBACtC;aACJ,CAAC,CAAC;YAEH,6GAA6G;YAC7G,qDAAqD;YACrD,IAAI;gBACA,
|
|
1
|
+
{"version":3,"file":"PositionsRepository.js","sourceRoot":"","sources":["../../../../../../src/integration-engine/vehicle-positions/workers/vehicle-positions/data-access/PositionsRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,mEAAuC;AACvC,2FAA0D;AAC1D,uFAA6D;AAC7D,wGAAwE;AAIxE,iFAAqF;AACrF,yEAAqF;AACrF,6EAAwE;AACxE,mFAAkF;AAClF,iFAAkF;AAClF,gDAAgE;AAGhE,gFAAwD;AAGxD,MAAa,mBAAoB,SAAQ,sBAAa;IAGlD;QACI,KAAK,CACD,uBAAuB,EACvB;YACI,yBAAyB,EAAE,yBAAW,CAAC,cAAc;YACrD,WAAW,EAAE,oCAAgB,CAAC,SAAS,CAAC,WAAW;YACnD,QAAQ,EAAE,iBAAS;YACnB,UAAU,EAAE,gBAAgB;YAC5B,2BAA2B,EAAE;gBACzB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AChB;YAAC,OAAO,GAAG,EAAE;gBACV,MAAM,IAAI,6BAAY,CAAC,gDAAgD,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;aAC5F;QACL,CAAC,CAAC;QA1QE,IAAI,CAAC,UAAU,GAAG,8BAAiB,CAAC,aAAa,EAAE,CAAC,MAAM,CAAC,qBAAY,CAAC,UAAU,EAAE,qBAAY,CAAC,cAAc,EAAE;YAC7G,MAAM,EAAE,iBAAS;SACpB,CAAC,CAAC;QACH,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9F,CAAC;CAuQJ;AArSD,kDAqSC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { IVPTripsPositionAttributes } from "../../../../../schema-definitions/vehicle-positions/models/interfaces/IVPTripsPositionAttributes";
|
|
2
|
+
import { IVPTripsLastPositionContext } from "../../../../../schema-definitions/vehicle-positions/models/interfaces/VPTripsLastPositionInterfaces";
|
|
3
|
+
import { IScheduleDto } from "../../../../../schema-definitions/vehicle-positions/redis/interfaces/IGtfsRunTripCacheDto";
|
|
4
|
+
import { Feature, Point } from "@turf/turf";
|
|
5
|
+
import { StatePositionEnum } from "../../../../../const";
|
|
6
|
+
import { GTFSRouteTypeEnum } from "../../../../../helpers/RouteTypeEnums";
|
|
7
|
+
import { IComputationTrip, ICurrentPositionProperties, IPositionToUpdate, IProcessedPositions, IShapeAnchorPoint, ITripPositionsWithGTFS, IUpdatePositionsIteratorOptions } from "../interfaces/VPInterfaces";
|
|
8
|
+
import { PositionHandlerEnum } from "./PositionHandlerEnum";
|
|
9
|
+
import { ValidToCalculator } from "./ValidToCalculator";
|
|
10
|
+
import { IStopTime } from "../../../../ropid-gtfs/interfaces/TripModelInterfaces";
|
|
11
|
+
export declare abstract class BasePositionsManager {
|
|
12
|
+
protected readonly useEndTimestamp: boolean;
|
|
13
|
+
protected readonly allowCancelState: boolean;
|
|
14
|
+
protected static sortByOriginTimestamp: (a: IVPTripsPositionAttributes, b: IVPTripsPositionAttributes) => 1 | 0 | -1;
|
|
15
|
+
protected abstract validToCalculator: ValidToCalculator;
|
|
16
|
+
constructor({ useEndTimestamp, allowCancelState }: {
|
|
17
|
+
useEndTimestamp?: boolean | undefined;
|
|
18
|
+
allowCancelState?: boolean | undefined;
|
|
19
|
+
});
|
|
20
|
+
abstract updatePositions(options: IUpdatePositionsIteratorOptions, schedule: IScheduleDto[] | undefined): IProcessedPositions;
|
|
21
|
+
protected abstract getClosestPoint(currentPosition: Feature<Point, ICurrentPositionProperties>, context: IVPTripsLastPositionContext | null, startDayTimestamp: number, thisClosestPoint: IShapeAnchorPoint, tripGtfsData: IComputationTrip, gtfsRouteType?: GTFSRouteTypeEnum): IPositionToUpdate;
|
|
22
|
+
private getCurrentContext;
|
|
23
|
+
/**
|
|
24
|
+
* Compute positions and return computed positions
|
|
25
|
+
*
|
|
26
|
+
* @param {ITripPositionsWithGTFS} tripPositions - Trip positions with shape anchors data
|
|
27
|
+
* @returns {IProcessedPositions} - Returns computed/updated positions
|
|
28
|
+
*/
|
|
29
|
+
computePositions: (tripPositions: ITripPositionsWithGTFS, schedule?: IScheduleDto[] | undefined) => IProcessedPositions;
|
|
30
|
+
/**
|
|
31
|
+
* Decide how to process input position data
|
|
32
|
+
*
|
|
33
|
+
* @param {IVPTripsPositionAttributes} position - Input vehiclepositions_positions row data
|
|
34
|
+
* @returns {PositionHandlerEnum} - Returns action handler enum
|
|
35
|
+
*/
|
|
36
|
+
protected setPositionUpdateHandler: (position: IVPTripsPositionAttributes) => PositionHandlerEnum;
|
|
37
|
+
/**
|
|
38
|
+
* Returns estimate of point on shape, where the trip should be with appropriate delay
|
|
39
|
+
*
|
|
40
|
+
* @param {IShapeAnchorPoint[]} tripShapePoints - Precalculated trip shape equidistant points with scheduled times
|
|
41
|
+
* @param {Feature<Point, ICurrentPositionProperties>} currentPosition - Current position of trip
|
|
42
|
+
* @param {IVPTripsLastPositionContext | null} context - Context state, holds information about previous positions
|
|
43
|
+
* @param {number} startDayTimestamp - Unix timestamp of midnight before trip starts
|
|
44
|
+
* @returns {IPositionToUpdate} - Position object to update
|
|
45
|
+
*/
|
|
46
|
+
protected getEstimatedPoint: (tripGtfsData: IComputationTrip, currentPosition: Feature<Point, ICurrentPositionProperties>, context: IVPTripsLastPositionContext | null, startDayTimestamp: number, gtfsRouteType?: GTFSRouteTypeEnum) => IPositionToUpdate;
|
|
47
|
+
/**
|
|
48
|
+
* Corrects time delay at stop with dwelling time
|
|
49
|
+
*
|
|
50
|
+
* @param {number} timeDelay - Initial computed delay in seconds, can be negative for trip ahead
|
|
51
|
+
* @param {IVPTripsLastPositionContext | null} context - Context state, holds information about previous positions
|
|
52
|
+
* @param {Feature<Point, ICurrentPositionProperties>} currentPosition - Feature Point of current position
|
|
53
|
+
* @param {IShapeAnchorPoint} thisClosestPoint - Closest point of shape anchors
|
|
54
|
+
* @param { departureTime: number; arrivalTime: number } stopTimes - departure and arrival stop times in seconds
|
|
55
|
+
* @returns {number} - Result delay in seconds, can be negative for trip ahead
|
|
56
|
+
*/
|
|
57
|
+
protected getCorrectedTimeDelay: (timeDelay: number, context: IVPTripsLastPositionContext | null, currentPosition: Feature<Point, ICurrentPositionProperties>, thisStopSequence: number, stopTimes: {
|
|
58
|
+
departureTime: number;
|
|
59
|
+
arrivalTime: number;
|
|
60
|
+
}) => number;
|
|
61
|
+
/**
|
|
62
|
+
* Compute UTC timestamp of start of day when trip starts
|
|
63
|
+
*
|
|
64
|
+
* @param {number} startTimestamp - Unix timestamp of start of the trip
|
|
65
|
+
* @param {number} firstStopTimeScheduledSeconds - Number of seconds from midnight of first stop departure
|
|
66
|
+
* @returns {number} - Returns unix timestamp in milliseconds.
|
|
67
|
+
*/
|
|
68
|
+
protected getStartDayTimestamp: (startTimestamp: number, firstStopTimeScheduledSeconds: number) => number;
|
|
69
|
+
protected disruptAtStopStreak(position: IVPTripsPositionAttributes, positionToUpdate?: IPositionToUpdate | null): boolean;
|
|
70
|
+
protected setFirstUniqueStopSequence(positionToUpdate: IPositionToUpdate | null, context: IVPTripsLastPositionContext, position: IVPTripsPositionAttributes): void;
|
|
71
|
+
protected defaultNonTrackingPositionToUpdate(position: IVPTripsPositionAttributes, firstStopTime: IStopTime, startDayTimestamp: number, setAsInvisible: boolean, lastPositionDelayed: 0 | {
|
|
72
|
+
delay: number | null;
|
|
73
|
+
origin_timestamp: Date;
|
|
74
|
+
} | null): IPositionToUpdate;
|
|
75
|
+
/**
|
|
76
|
+
* Get delay in seconds for positions before track to ensure correct delay propagation
|
|
77
|
+
*
|
|
78
|
+
* @param lastPositionDelay The last position delay in seconds
|
|
79
|
+
* @param firstStopDepartureTime The first stop departure time in seconds. The time is measured from "noon minus 12h" of the
|
|
80
|
+
* service day (effectively midnight except for days on which daylight savings time changes occur). For times occurring after
|
|
81
|
+
* midnight on the service day, enter the time as a value greater than 24:00:00 in seconds. See also
|
|
82
|
+
* <https://gtfs.org/schedule/reference/#:~:text=A%20phone%20number.-,Time,-%2D%20Time%20in%20the>.
|
|
83
|
+
* @param positionOriginUnixTimestamp The Unix Epoch timestamp of the current position, in milliseconds
|
|
84
|
+
* @param startDayUnixTimestamp The Unix Epoch timestamp of the start of the service day, in milliseconds
|
|
85
|
+
*/
|
|
86
|
+
private getDelayBeforeTrack;
|
|
87
|
+
protected isFreshNewVehicleInSystem(context: IVPTripsLastPositionContext, position: IVPTripsPositionAttributes, endTimestamp: Date | null): boolean;
|
|
88
|
+
protected setLastPositionTracking(position: IVPTripsPositionAttributes, context: IVPTripsLastPositionContext, positionToUpdate: IPositionToUpdate | null): void;
|
|
89
|
+
protected detectDuplicatePosition(position: IVPTripsPositionAttributes, lastPositionOriginTimestamp: number | null, positionsSource: IVPTripsPositionAttributes[]): StatePositionEnum.AFTER_TRACK | StatePositionEnum.DUPLICATE;
|
|
90
|
+
}
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.BasePositionsManager = void 0;
|
|
30
|
+
const moment_timezone_1 = __importDefault(require("@golemio/core/dist/shared/moment-timezone"));
|
|
31
|
+
const turf = __importStar(require("@turf/turf"));
|
|
32
|
+
const const_1 = require("../../../../../const");
|
|
33
|
+
const PositionHandlerEnum_1 = require("./PositionHandlerEnum");
|
|
34
|
+
const AnchorPointSegmenter_1 = require("./anchor-points/AnchorPointSegmenter");
|
|
35
|
+
const DateTimeUtils_1 = require("../../../../../helpers/DateTimeUtils");
|
|
36
|
+
const ONE_DAY_IN_SECONDS = 24 * 60 * 60;
|
|
37
|
+
const ONE_SECOND_IN_MILLIS = 1000;
|
|
38
|
+
class BasePositionsManager {
|
|
39
|
+
constructor({ useEndTimestamp = false, allowCancelState = false }) {
|
|
40
|
+
this.getCurrentContext = (tripPositions) => {
|
|
41
|
+
const context = tripPositions.last_position_context ?? {
|
|
42
|
+
atStopStreak: {
|
|
43
|
+
stop_sequence: null,
|
|
44
|
+
firstPositionTimestamp: null,
|
|
45
|
+
firstPositionDelay: null,
|
|
46
|
+
},
|
|
47
|
+
lastPositionLastStop: {
|
|
48
|
+
id: null,
|
|
49
|
+
sequence: null,
|
|
50
|
+
arrival_time: null,
|
|
51
|
+
arrival_delay: null,
|
|
52
|
+
departure_time: null,
|
|
53
|
+
departure_delay: null,
|
|
54
|
+
},
|
|
55
|
+
lastPositionDelay: null,
|
|
56
|
+
lastPositionId: null,
|
|
57
|
+
lastPositionLat: null,
|
|
58
|
+
lastPositionLng: null,
|
|
59
|
+
lastPositionOriginTimestamp: null,
|
|
60
|
+
lastPositionTracking: null,
|
|
61
|
+
lastPositionCanceled: null,
|
|
62
|
+
lastPositionBeforeTrackDelayed: null,
|
|
63
|
+
lastPositionState: null,
|
|
64
|
+
lastStopSequence: null,
|
|
65
|
+
lastPositionStateChange: null,
|
|
66
|
+
tripId: tripPositions.id,
|
|
67
|
+
};
|
|
68
|
+
return context;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Compute positions and return computed positions
|
|
72
|
+
*
|
|
73
|
+
* @param {ITripPositionsWithGTFS} tripPositions - Trip positions with shape anchors data
|
|
74
|
+
* @returns {IProcessedPositions} - Returns computed/updated positions
|
|
75
|
+
*/
|
|
76
|
+
this.computePositions = (tripPositions, schedule) => {
|
|
77
|
+
const startTimestamp = tripPositions.start_timestamp.getTime();
|
|
78
|
+
const startDayTimestamp = this.getStartDayTimestamp(startTimestamp, tripPositions.gtfsData.shapes_anchor_points[0].time_scheduled_seconds);
|
|
79
|
+
const gtfsRouteType = tripPositions.gtfs_route_type;
|
|
80
|
+
const context = this.getCurrentContext(tripPositions);
|
|
81
|
+
const computedPositions = [];
|
|
82
|
+
const endTimestamp = this.useEndTimestamp ? tripPositions.end_timestamp : null;
|
|
83
|
+
return this.updatePositions({
|
|
84
|
+
tripPositions,
|
|
85
|
+
startTimestamp,
|
|
86
|
+
startDayTimestamp,
|
|
87
|
+
endTimestamp,
|
|
88
|
+
context,
|
|
89
|
+
computedPositions,
|
|
90
|
+
gtfsRouteType,
|
|
91
|
+
}, schedule);
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Decide how to process input position data
|
|
95
|
+
*
|
|
96
|
+
* @param {IVPTripsPositionAttributes} position - Input vehiclepositions_positions row data
|
|
97
|
+
* @returns {PositionHandlerEnum} - Returns action handler enum
|
|
98
|
+
*/
|
|
99
|
+
this.setPositionUpdateHandler = (position) => {
|
|
100
|
+
if (position.state_process === const_1.StateProcessEnum.PROCESSED || position.state_process === const_1.StateProcessEnum.INVALIDATED)
|
|
101
|
+
return PositionHandlerEnum_1.PositionHandlerEnum.DO_NOTHING;
|
|
102
|
+
else if (this.allowCancelState && position.is_canceled)
|
|
103
|
+
return PositionHandlerEnum_1.PositionHandlerEnum.CANCELED;
|
|
104
|
+
else if (position.is_tracked)
|
|
105
|
+
return PositionHandlerEnum_1.PositionHandlerEnum.TRACKING;
|
|
106
|
+
else
|
|
107
|
+
return PositionHandlerEnum_1.PositionHandlerEnum.NOT_TRACKING;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Returns estimate of point on shape, where the trip should be with appropriate delay
|
|
111
|
+
*
|
|
112
|
+
* @param {IShapeAnchorPoint[]} tripShapePoints - Precalculated trip shape equidistant points with scheduled times
|
|
113
|
+
* @param {Feature<Point, ICurrentPositionProperties>} currentPosition - Current position of trip
|
|
114
|
+
* @param {IVPTripsLastPositionContext | null} context - Context state, holds information about previous positions
|
|
115
|
+
* @param {number} startDayTimestamp - Unix timestamp of midnight before trip starts
|
|
116
|
+
* @returns {IPositionToUpdate} - Position object to update
|
|
117
|
+
*/
|
|
118
|
+
this.getEstimatedPoint = (tripGtfsData, currentPosition, context, startDayTimestamp, gtfsRouteType) => {
|
|
119
|
+
const anchorPointSegmenter = new AnchorPointSegmenter_1.AnchorPointSegmenter(tripGtfsData.shapes_anchor_points, currentPosition);
|
|
120
|
+
const defaultStatePosition = const_1.StatePositionEnum.OFF_TRACK;
|
|
121
|
+
// Initial value
|
|
122
|
+
let estimatedPoint = {
|
|
123
|
+
id: currentPosition.properties.id,
|
|
124
|
+
state_position: defaultStatePosition,
|
|
125
|
+
state_process: const_1.StateProcessEnum.PROCESSED,
|
|
126
|
+
// origin_timestamp: currentPosition.properties.origin_timestamp,
|
|
127
|
+
tcp_event: currentPosition.properties.tcp_event,
|
|
128
|
+
valid_to: this.validToCalculator.getDefaultValidToAttribute(currentPosition.properties.origin_timestamp),
|
|
129
|
+
...(context?.lastPositionTracking?.properties.last_stop_sequence && {
|
|
130
|
+
shape_dist_traveled: context.lastPositionTracking?.properties.shape_dist_traveled,
|
|
131
|
+
last_stop_arrival_time: context.lastPositionTracking?.properties.last_stop_arrival_time
|
|
132
|
+
? new Date(context.lastPositionTracking?.properties.last_stop_arrival_time)
|
|
133
|
+
: undefined,
|
|
134
|
+
last_stop_departure_time: context.lastPositionTracking?.properties.last_stop_departure_time
|
|
135
|
+
? new Date(context.lastPositionTracking?.properties.last_stop_departure_time)
|
|
136
|
+
: undefined,
|
|
137
|
+
last_stop_sequence: context.lastPositionTracking?.properties.last_stop_sequence,
|
|
138
|
+
last_stop_id: context.lastPositionTracking?.properties.last_stop_id,
|
|
139
|
+
}),
|
|
140
|
+
};
|
|
141
|
+
let lastStopSequence = null;
|
|
142
|
+
if (context?.lastPositionState === const_1.StatePositionEnum.BEFORE_TRACK) {
|
|
143
|
+
lastStopSequence = 1;
|
|
144
|
+
}
|
|
145
|
+
else if (context?.lastPositionTracking) {
|
|
146
|
+
lastStopSequence = context.lastPositionTracking.properties.last_stop_sequence;
|
|
147
|
+
}
|
|
148
|
+
const closestPoint = anchorPointSegmenter.getClosesPoint(lastStopSequence);
|
|
149
|
+
if (!closestPoint) {
|
|
150
|
+
return estimatedPoint;
|
|
151
|
+
}
|
|
152
|
+
return this.getClosestPoint(currentPosition, context, startDayTimestamp, closestPoint, tripGtfsData, gtfsRouteType);
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Corrects time delay at stop with dwelling time
|
|
156
|
+
*
|
|
157
|
+
* @param {number} timeDelay - Initial computed delay in seconds, can be negative for trip ahead
|
|
158
|
+
* @param {IVPTripsLastPositionContext | null} context - Context state, holds information about previous positions
|
|
159
|
+
* @param {Feature<Point, ICurrentPositionProperties>} currentPosition - Feature Point of current position
|
|
160
|
+
* @param {IShapeAnchorPoint} thisClosestPoint - Closest point of shape anchors
|
|
161
|
+
* @param { departureTime: number; arrivalTime: number } stopTimes - departure and arrival stop times in seconds
|
|
162
|
+
* @returns {number} - Result delay in seconds, can be negative for trip ahead
|
|
163
|
+
*/
|
|
164
|
+
this.getCorrectedTimeDelay = (timeDelay, context, currentPosition, thisStopSequence, stopTimes) => {
|
|
165
|
+
// compute dwell time in stop, most common is zero
|
|
166
|
+
const stopDwellTimeSeconds = stopTimes.departureTime - stopTimes.arrivalTime;
|
|
167
|
+
// if dwell time is sheduled as zero, return initial computed delay
|
|
168
|
+
if (stopDwellTimeSeconds <= 0) {
|
|
169
|
+
return timeDelay;
|
|
170
|
+
}
|
|
171
|
+
// if last position was not in this same stop or there is no last position at all
|
|
172
|
+
if (!context || context.atStopStreak.stop_sequence !== thisStopSequence) {
|
|
173
|
+
// timeDelay >= 0 trip is DELAYED
|
|
174
|
+
// we presume it will lower delay by shortening its scheduled dwell time,
|
|
175
|
+
// cant go under zero of course, trip should not go ahead
|
|
176
|
+
// else trip is AHeAD
|
|
177
|
+
// left computed delay as it was
|
|
178
|
+
return timeDelay >= 0 ? Math.max(timeDelay - stopDwellTimeSeconds, 0) : timeDelay;
|
|
179
|
+
}
|
|
180
|
+
// we presume that first position at same stop is real arrival time
|
|
181
|
+
if (context.atStopStreak.firstPositionDelay >= 0) {
|
|
182
|
+
// trip was DELAYED before
|
|
183
|
+
// we presume it will lower delay by shortening its scheduled dwell time,
|
|
184
|
+
// cant go under zero of course, trip should not go ahead
|
|
185
|
+
return Math.max(timeDelay - stopDwellTimeSeconds, 0);
|
|
186
|
+
}
|
|
187
|
+
// trip was AHEAD before
|
|
188
|
+
// real dwell time so far
|
|
189
|
+
const realDwellTimeSeconds = Math.round((currentPosition.properties.origin_timestamp.getTime() - context.atStopStreak.firstPositionTimestamp) / 1000);
|
|
190
|
+
// if real dwell is longer than scheduled, then add to negative delay time
|
|
191
|
+
return context.atStopStreak.firstPositionDelay + Math.max(realDwellTimeSeconds - stopDwellTimeSeconds, 0);
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* Compute UTC timestamp of start of day when trip starts
|
|
195
|
+
*
|
|
196
|
+
* @param {number} startTimestamp - Unix timestamp of start of the trip
|
|
197
|
+
* @param {number} firstStopTimeScheduledSeconds - Number of seconds from midnight of first stop departure
|
|
198
|
+
* @returns {number} - Returns unix timestamp in milliseconds.
|
|
199
|
+
*/
|
|
200
|
+
this.getStartDayTimestamp = (startTimestamp, firstStopTimeScheduledSeconds) => {
|
|
201
|
+
let startDayTimestamp = moment_timezone_1.default.utc(startTimestamp).tz("Europe/Prague").startOf("day");
|
|
202
|
+
const stopTimeDayOverflow = Math.floor(firstStopTimeScheduledSeconds / ONE_DAY_IN_SECONDS);
|
|
203
|
+
// if trip has 24+ stop times set real startDay to yesterday
|
|
204
|
+
if (stopTimeDayOverflow > 0) {
|
|
205
|
+
startDayTimestamp.subtract(1, "day");
|
|
206
|
+
}
|
|
207
|
+
return startDayTimestamp.valueOf();
|
|
208
|
+
};
|
|
209
|
+
this.useEndTimestamp = useEndTimestamp;
|
|
210
|
+
this.allowCancelState = allowCancelState;
|
|
211
|
+
}
|
|
212
|
+
disruptAtStopStreak(position, positionToUpdate) {
|
|
213
|
+
if (!positionToUpdate && !position.this_stop_sequence) {
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
return !!(positionToUpdate &&
|
|
217
|
+
positionToUpdate.state_position !== const_1.StatePositionEnum.MISMATCHED &&
|
|
218
|
+
!positionToUpdate.this_stop_sequence);
|
|
219
|
+
}
|
|
220
|
+
setFirstUniqueStopSequence(positionToUpdate, context, position) {
|
|
221
|
+
if (positionToUpdate
|
|
222
|
+
? positionToUpdate.this_stop_sequence &&
|
|
223
|
+
context.atStopStreak.stop_sequence !== positionToUpdate.this_stop_sequence
|
|
224
|
+
: position.this_stop_sequence && context.atStopStreak.stop_sequence !== position.this_stop_sequence) {
|
|
225
|
+
context.atStopStreak.stop_sequence = positionToUpdate
|
|
226
|
+
? positionToUpdate.this_stop_sequence
|
|
227
|
+
: position.this_stop_sequence;
|
|
228
|
+
context.atStopStreak.firstPositionTimestamp = position.origin_timestamp.getTime();
|
|
229
|
+
context.atStopStreak.firstPositionDelay = positionToUpdate ? positionToUpdate.delay : position.delay;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
defaultNonTrackingPositionToUpdate(position, firstStopTime, startDayTimestamp, setAsInvisible, lastPositionDelayed) {
|
|
233
|
+
const positionToUpdate = {
|
|
234
|
+
id: position.id,
|
|
235
|
+
next_stop_arrival_time: DateTimeUtils_1.DateTimeUtils.getStopDateTimeForDayStart(firstStopTime.arrival_time_seconds, startDayTimestamp),
|
|
236
|
+
next_stop_departure_time: DateTimeUtils_1.DateTimeUtils.getStopDateTimeForDayStart(firstStopTime.departure_time_seconds, startDayTimestamp),
|
|
237
|
+
next_stop_id: firstStopTime.stop_id,
|
|
238
|
+
next_stop_sequence: firstStopTime.stop_sequence,
|
|
239
|
+
next_stop_name: firstStopTime.stop.stop_name,
|
|
240
|
+
shape_dist_traveled: firstStopTime.shape_dist_traveled,
|
|
241
|
+
state_position: setAsInvisible ? const_1.StatePositionEnum.INVISIBLE : const_1.StatePositionEnum.BEFORE_TRACK,
|
|
242
|
+
state_process: const_1.StateProcessEnum.PROCESSED,
|
|
243
|
+
...(firstStopTime.stop_headsign && {
|
|
244
|
+
last_stop_headsign: firstStopTime.stop_headsign,
|
|
245
|
+
}),
|
|
246
|
+
};
|
|
247
|
+
if (positionToUpdate.state_position === const_1.StatePositionEnum.BEFORE_TRACK) {
|
|
248
|
+
if (lastPositionDelayed === 0) {
|
|
249
|
+
positionToUpdate.delay = 0;
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
positionToUpdate.delay = this.getDelayBeforeTrack(lastPositionDelayed?.delay ?? position.delay, firstStopTime.departure_time_seconds, position.origin_timestamp.getTime(), startDayTimestamp);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return positionToUpdate;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Get delay in seconds for positions before track to ensure correct delay propagation
|
|
259
|
+
*
|
|
260
|
+
* @param lastPositionDelay The last position delay in seconds
|
|
261
|
+
* @param firstStopDepartureTime The first stop departure time in seconds. The time is measured from "noon minus 12h" of the
|
|
262
|
+
* service day (effectively midnight except for days on which daylight savings time changes occur). For times occurring after
|
|
263
|
+
* midnight on the service day, enter the time as a value greater than 24:00:00 in seconds. See also
|
|
264
|
+
* <https://gtfs.org/schedule/reference/#:~:text=A%20phone%20number.-,Time,-%2D%20Time%20in%20the>.
|
|
265
|
+
* @param positionOriginUnixTimestamp The Unix Epoch timestamp of the current position, in milliseconds
|
|
266
|
+
* @param startDayUnixTimestamp The Unix Epoch timestamp of the start of the service day, in milliseconds
|
|
267
|
+
*/
|
|
268
|
+
getDelayBeforeTrack(lastPositionDelay, firstStopDepartureTime, positionOriginUnixTimestamp, startDayUnixTimestamp) {
|
|
269
|
+
if (typeof lastPositionDelay !== "number") {
|
|
270
|
+
return null;
|
|
271
|
+
}
|
|
272
|
+
const startDayMoment = moment_timezone_1.default.utc(startDayUnixTimestamp).tz(DateTimeUtils_1.DateTimeUtils.TIMEZONE);
|
|
273
|
+
startDayMoment.hours(12).minutes(0).seconds(0).milliseconds(0);
|
|
274
|
+
startDayMoment.subtract(12, "hours");
|
|
275
|
+
startDayMoment.add(firstStopDepartureTime, "seconds");
|
|
276
|
+
const departureTimeInSeconds = Math.floor(startDayMoment.toDate().valueOf() / ONE_SECOND_IN_MILLIS);
|
|
277
|
+
const positionOriginTimeInSeconds = Math.floor(positionOriginUnixTimestamp / ONE_SECOND_IN_MILLIS);
|
|
278
|
+
return Math.max(lastPositionDelay, positionOriginTimeInSeconds - departureTimeInSeconds);
|
|
279
|
+
}
|
|
280
|
+
isFreshNewVehicleInSystem(context, position, endTimestamp) {
|
|
281
|
+
const noPreviousTrackingEver = context.lastPositionTracking === null;
|
|
282
|
+
const endTimestampAfterScheduled = endTimestamp === null || position.scheduled_timestamp === null || endTimestamp > position.scheduled_timestamp;
|
|
283
|
+
return noPreviousTrackingEver && endTimestampAfterScheduled;
|
|
284
|
+
}
|
|
285
|
+
setLastPositionTracking(position, context, positionToUpdate) {
|
|
286
|
+
if (position.state_position === const_1.StatePositionEnum.BEFORE_TRACK_DELAYED) {
|
|
287
|
+
context.lastPositionBeforeTrackDelayed = {
|
|
288
|
+
delay: positionToUpdate?.delay ?? position.delay,
|
|
289
|
+
origin_timestamp: positionToUpdate?.origin_timestamp ?? position.origin_timestamp,
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
if (positionToUpdate?.state_position === const_1.StatePositionEnum.AT_STOP ||
|
|
293
|
+
positionToUpdate?.state_position === const_1.StatePositionEnum.ON_TRACK ||
|
|
294
|
+
position.state_position === const_1.StatePositionEnum.AT_STOP ||
|
|
295
|
+
position.state_position === const_1.StatePositionEnum.ON_TRACK) {
|
|
296
|
+
context.lastPositionTracking = turf.point([position.lng, position.lat], {
|
|
297
|
+
...position,
|
|
298
|
+
...positionToUpdate,
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
detectDuplicatePosition(position, lastPositionOriginTimestamp, positionsSource) {
|
|
303
|
+
return position.origin_timestamp.getTime() === lastPositionOriginTimestamp ||
|
|
304
|
+
positionsSource.findIndex((positionItem) => positionItem.origin_timestamp.getTime() === position.origin_timestamp.getTime() && positionItem.is_tracked) >= 0
|
|
305
|
+
? const_1.StatePositionEnum.DUPLICATE
|
|
306
|
+
: const_1.StatePositionEnum.AFTER_TRACK;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
exports.BasePositionsManager = BasePositionsManager;
|
|
310
|
+
BasePositionsManager.sortByOriginTimestamp = function (a, b) {
|
|
311
|
+
if (!a.origin_timestamp || !b.origin_timestamp || a.origin_timestamp === b.origin_timestamp) {
|
|
312
|
+
return 0;
|
|
313
|
+
}
|
|
314
|
+
return a.origin_timestamp < b.origin_timestamp ? -1 : 1;
|
|
315
|
+
};
|
|
316
|
+
//# sourceMappingURL=BasePositionsManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BasePositionsManager.js","sourceRoot":"","sources":["../../../../../../src/integration-engine/vehicle-positions/workers/vehicle-positions/helpers/BasePositionsManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,gGAA+D;AAC/D,iDAAmC;AAEnC,gDAAgE;AAWhE,+DAA4D;AAE5D,+EAA4E;AAC5E,wEAAuD;AAGvD,MAAM,kBAAkB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AACxC,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAElC,MAAsB,oBAAoB;IAYtC,YAAY,EAAE,eAAe,GAAG,KAAK,EAAE,gBAAgB,GAAG,KAAK,EAAE;QAmBzD,sBAAiB,GAAG,CAAC,aAAqC,EAA+B,EAAE;YAC/F,MAAM,OAAO,GAAgC,aAAa,CA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oB,0CAAqB,GAAG,UAAU,CAA6B,EAAE,CAA6B;IAC3G,IAAI,CAAC,CAAC,CAAC,gBAAgB,IAAI,CAAC,CAAC,CAAC,gBAAgB,IAAI,CAAC,CAAC,gBAAgB,KAAK,CAAC,CAAC,gBAAgB,EAAE;QACzF,OAAO,CAAC,CAAC;KACZ;IACD,OAAO,CAAC,CAAC,gBAAgB,GAAG,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5D,CAAC,AALqC,CAKpC"}
|
|
@@ -1,43 +1,21 @@
|
|
|
1
|
+
import { IVPTripsLastPositionContext } from "../../../../../schema-definitions/vehicle-positions/models/interfaces/VPTripsLastPositionInterfaces";
|
|
1
2
|
import { IScheduleDto } from "../../../../../schema-definitions/vehicle-positions/redis/interfaces/IGtfsRunTripCacheDto";
|
|
2
|
-
import {
|
|
3
|
+
import { Feature, Point } from "@turf/turf";
|
|
4
|
+
import { GTFSRouteTypeEnum } from "../../../../../helpers/RouteTypeEnums";
|
|
5
|
+
import { IComputationTrip, ICurrentPositionProperties, IPositionToUpdate, IProcessedPositions, IShapeAnchorPoint, IUpdatePositionsIteratorOptions } from "../interfaces/VPInterfaces";
|
|
6
|
+
import { BasePositionsManager } from "./BasePositionsManager";
|
|
3
7
|
import { ValidToCalculator } from "./ValidToCalculator";
|
|
4
|
-
export declare class PositionsManager {
|
|
5
|
-
|
|
8
|
+
export declare class PositionsManager extends BasePositionsManager {
|
|
9
|
+
protected validToCalculator: ValidToCalculator;
|
|
6
10
|
constructor(validToCalculator: ValidToCalculator);
|
|
7
|
-
/**
|
|
8
|
-
* Compute positions and return computed positions
|
|
9
|
-
*
|
|
10
|
-
* @param {ITripPositionsWithGTFS} tripPositions - Trip positions with shape anchors data
|
|
11
|
-
* @returns {IProcessedPositions} - Returns computed/updated positions
|
|
12
|
-
*/
|
|
13
|
-
computePositions: (tripPositions: ITripPositionsWithGTFS, schedule: IScheduleDto[] | undefined) => IProcessedPositions;
|
|
14
11
|
/**
|
|
15
12
|
* Takes position one by one, set proper handler for type of position, and do the process of position
|
|
16
13
|
*
|
|
17
|
-
* @param {number} i - Iteration
|
|
18
14
|
* @param {IUpdatePositionsIteratorOptions} options - Initial options
|
|
19
15
|
* @param {number} cb - Callback function of iterator
|
|
20
16
|
* @returns {IProcessedPositions} - Returns computed/updated positions
|
|
21
17
|
*/
|
|
22
18
|
updatePositions: (options: IUpdatePositionsIteratorOptions, schedule: IScheduleDto[] | undefined) => IProcessedPositions;
|
|
23
|
-
private getCurrentContext;
|
|
24
|
-
/**
|
|
25
|
-
* Decide how to process input position data
|
|
26
|
-
*
|
|
27
|
-
* @param {IVPTripsPositionAttributes} position - Input vehiclepositions_positions row data
|
|
28
|
-
* @returns {PositionHandlerEnum} - Returns action handler enum
|
|
29
|
-
*/
|
|
30
|
-
private setPositionUpdateHandler;
|
|
31
|
-
/**
|
|
32
|
-
* Returns estimate of point on shape, where the trip should be with appropriate delay
|
|
33
|
-
*
|
|
34
|
-
* @param {IShapeAnchorPoint[]} tripShapePoints - Precalculated trip shape equidistant points with scheduled times
|
|
35
|
-
* @param {Feature<Point, ICurrentPositionProperties>} currentPosition - Current position of trip
|
|
36
|
-
* @param {IVPTripsLastPositionContext | null} context - Context state, holds information about previous positions
|
|
37
|
-
* @param {number} startDayTimestamp - Unix timestamp of midnight before trip starts
|
|
38
|
-
* @returns {IPositionToUpdate} - Position object to update
|
|
39
|
-
*/
|
|
40
|
-
private getEstimatedPoint;
|
|
41
19
|
/**
|
|
42
20
|
* Picks only one closest point for multiple possible points based on delay of last position and stop times
|
|
43
21
|
*
|
|
@@ -48,38 +26,9 @@ export declare class PositionsManager {
|
|
|
48
26
|
* @param {IComputationTrip} tripGtfsData - GTFS data and all set of known positions
|
|
49
27
|
* @returns {IPositionToUpdate} - Result point as position to update in DB
|
|
50
28
|
*/
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
* Corrects time delay at stop with dwelling time
|
|
54
|
-
*
|
|
55
|
-
* @param {number} timeDelay - Initial computed delay in seconds, can be negative for trip ahead
|
|
56
|
-
* @param {IVPTripsLastPositionContext | null} context - Context state, holds information about previous positions
|
|
57
|
-
* @param {Feature<Point, ICurrentPositionProperties>} currentPosition - Feature Point of current position
|
|
58
|
-
* @param {IShapeAnchorPoint} thisClosestPoint - Closest point of shape anchors
|
|
59
|
-
* @param { departureTime: number; arrivalTime: number } stopTimes - departure and arrival stop times in seconds
|
|
60
|
-
* @returns {number} - Result delay in seconds, can be negative for trip ahead
|
|
61
|
-
*/
|
|
62
|
-
private getCorrectedTimeDelay;
|
|
63
|
-
/**
|
|
64
|
-
* Get delay in seconds for positions before track to ensure correct delay propagation
|
|
65
|
-
*
|
|
66
|
-
* @param lastPositionDelay The last position delay in seconds
|
|
67
|
-
* @param firstStopDepartureTime The first stop departure time in seconds. The time is measured from "noon minus 12h" of the
|
|
68
|
-
* service day (effectively midnight except for days on which daylight savings time changes occur). For times occurring after
|
|
69
|
-
* midnight on the service day, enter the time as a value greater than 24:00:00 in seconds. See also
|
|
70
|
-
* <https://gtfs.org/schedule/reference/#:~:text=A%20phone%20number.-,Time,-%2D%20Time%20in%20the>.
|
|
71
|
-
* @param positionOriginUnixTimestamp The Unix Epoch timestamp of the current position, in milliseconds
|
|
72
|
-
* @param startDayUnixTimestamp The Unix Epoch timestamp of the start of the service day, in milliseconds
|
|
73
|
-
*/
|
|
74
|
-
private getDelayBeforeTrack;
|
|
75
|
-
/**
|
|
76
|
-
* Compute UTC timestamp of start of day when trip starts
|
|
77
|
-
*
|
|
78
|
-
* @param {number} startTimestamp - Unix timestamp of start of the trip
|
|
79
|
-
* @param {number} firstStopTimeScheduledSeconds - Number of seconds from midnight of first stop departure
|
|
80
|
-
* @returns {number} - Returns unix timestamp in milliseconds.
|
|
81
|
-
*/
|
|
82
|
-
private getStartDayTimestamp;
|
|
29
|
+
protected getClosestPoint: (currentPosition: Feature<Point, ICurrentPositionProperties>, context: IVPTripsLastPositionContext | null, startDayTimestamp: number, thisClosestPoint: IShapeAnchorPoint, tripGtfsData: IComputationTrip, gtfsRouteType: GTFSRouteTypeEnum) => IPositionToUpdate;
|
|
30
|
+
private detectBacktracking;
|
|
83
31
|
private getStateAndStopSequences;
|
|
32
|
+
private hasTcpEventOrCancel;
|
|
84
33
|
private isAfterTrack;
|
|
85
34
|
}
|