@golemio/pid 4.2.1-dev.2118800259 → 4.3.0-rc.2122247958
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/cache/PublicStopTimeCacheRepository.js +2 -6
- package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/data-access/cache/PublicStopTimeCacheRepository.js.map +1 -1
- package/dist/output-gateway/pid/index.d.ts +0 -1
- package/dist/output-gateway/pid/index.js.map +1 -1
- package/dist/output-gateway/pid/models/helpers/SkipHelper.js +2 -9
- package/dist/output-gateway/pid/models/helpers/SkipHelper.js.map +1 -1
- package/dist/output-gateway/public/service/facade/DepartureBoardFacade.d.ts +0 -2
- package/dist/output-gateway/public/service/facade/DepartureBoardFacade.js +1 -3
- package/dist/output-gateway/public/service/facade/DepartureBoardFacade.js.map +1 -1
- package/docs/openapi-output.yaml +1 -1
- package/package.json +2 -2
- package/db/migrations/postgresql/20251020110708-get-departures-add-aftertrack.js +0 -53
- package/db/migrations/postgresql/sqls/20251020110708-get-departures-add-aftertrack-down.sql +0 -284
- package/db/migrations/postgresql/sqls/20251020110708-get-departures-add-aftertrack-up.sql +0 -289
|
@@ -30,17 +30,13 @@ let PublicStopTimeCacheRepository = exports.PublicStopTimeCacheRepository = Publ
|
|
|
30
30
|
this.log = log;
|
|
31
31
|
}
|
|
32
32
|
async createOrUpdate(data, ttlInSeconds) {
|
|
33
|
-
let currentStopTimes;
|
|
34
|
-
let currentTripId;
|
|
35
33
|
try {
|
|
36
|
-
for (const
|
|
37
|
-
currentStopTimes = stopTimes;
|
|
38
|
-
currentTripId = id;
|
|
34
|
+
for (const stopTimes of data.values()) {
|
|
39
35
|
await this.validator.Validate(stopTimes);
|
|
40
36
|
}
|
|
41
37
|
}
|
|
42
38
|
catch (err) {
|
|
43
|
-
throw new golemio_errors_1.GeneralError(`PublicStopTimeCacheRepository: data validation failed: ${err.message}`, this.constructor.name,
|
|
39
|
+
throw new golemio_errors_1.GeneralError(`PublicStopTimeCacheRepository: data validation failed: ${err.message}`, this.constructor.name, err);
|
|
44
40
|
}
|
|
45
41
|
try {
|
|
46
42
|
const stringifiedData = new Map();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PublicStopTimeCacheRepository.js","sourceRoot":"","sources":["../../../../../../../src/integration-engine/vehicle-positions/workers/vehicle-positions/data-access/cache/PublicStopTimeCacheRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8FAA6F;AAE7F,oJAAiH;AAEjH,wEAAqE;AACrE,wFAAqF;AACrF,6EAAwE;AACxE,mFAAkF;AAClF,iEAAwE;AAGjE,IAAM,6BAA6B,6EAAnC,MAAM,6BAA8B,SAAQ,uBAAU;IAGzD,YAA8C,GAAY;QACtD,KAAK,CACD,+BAA+B,EAC/B;YACI,wBAAwB,EAAE,KAAK;YAC/B,MAAM,EAAE,+BAA6B,CAAC,gBAAgB;SACzD,EACD,IAAI,uCAAmB,CAAC,+BAA+B,EAAE,2DAA4B,CAAC,CACzF,CAAC;QARwC,QAAG,GAAH,GAAG,CAAS;IAS1D,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,IAA4C,EAAE,YAAoB;QAC1F,IAAI
|
|
1
|
+
{"version":3,"file":"PublicStopTimeCacheRepository.js","sourceRoot":"","sources":["../../../../../../../src/integration-engine/vehicle-positions/workers/vehicle-positions/data-access/cache/PublicStopTimeCacheRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8FAA6F;AAE7F,oJAAiH;AAEjH,wEAAqE;AACrE,wFAAqF;AACrF,6EAAwE;AACxE,mFAAkF;AAClF,iEAAwE;AAGjE,IAAM,6BAA6B,6EAAnC,MAAM,6BAA8B,SAAQ,uBAAU;IAGzD,YAA8C,GAAY;QACtD,KAAK,CACD,+BAA+B,EAC/B;YACI,wBAAwB,EAAE,KAAK;YAC/B,MAAM,EAAE,+BAA6B,CAAC,gBA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OAAO,CAAC;IACnB,CAAC;;AAnFa,8CAAgB,GAAG,+CAAuC,AAA1C,CAA2C;wCADhE,6BAA6B;IADzC,IAAA,qBAAU,GAAE;IAII,WAAA,IAAA,iBAAM,EAAC,qBAAS,CAAC,MAAM,CAAC,CAAA;;GAH5B,6BAA6B,CAqFzC"}
|
|
@@ -45,7 +45,6 @@ export interface IPIDDeparture {
|
|
|
45
45
|
"trip.last_position.this_stop_sequence": number | null;
|
|
46
46
|
"trip.cis_stop_platform_code": string | null;
|
|
47
47
|
"trip.vehicle_descriptor.is_air_conditioned"?: boolean | null;
|
|
48
|
-
"trip.last_position.state_position"?: string | null;
|
|
49
48
|
planned_start_timestamp: string | null;
|
|
50
49
|
}
|
|
51
50
|
export interface ITransferAccessibility {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/output-gateway/pid/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAQA,4CAA0B;AAC1B,2CAAyB;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/output-gateway/pid/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAQA,4CAA0B;AAC1B,2CAAyB;AA6KzB,IAAY,aAIX;AAJD,WAAY,aAAa;IACrB,0CAAyB,CAAA;IACzB,sCAAqB,CAAA;IACrB,gCAAe,CAAA;AACnB,CAAC,EAJW,aAAa,6BAAb,aAAa,QAIxB;AAED,IAAY,cAGX;AAHD,WAAY,cAAc;IACtB,+BAAa,CAAA;IACb,yCAAuB,CAAA;AAC3B,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB;AAED,IAAY,eAQX;AARD,WAAY,eAAe;IACvB,gCAAa,CAAA;IACb,2CAAwB,CAAA;IACxB,0DAAuC,CAAA;IACvC,oDAAiC,CAAA;IACjC,mEAAgD,CAAA;IAChD,qEAAkD,CAAA;IAClD,8EAA2D,CAAA;AAC/D,CAAC,EARW,eAAe,+BAAf,eAAe,QAQ1B;AAED,IAAY,aAMX;AAND,WAAY,aAAa;IACrB,wCAAuB,CAAA;IACvB,oCAAmB,CAAA;IACnB,sCAAqB,CAAA;IACrB,mCAAkB,CAAA;IAClB,8BAA8B;AAClC,CAAC,EANW,aAAa,6BAAb,aAAa,QAMxB"}
|
|
@@ -24,12 +24,7 @@ class SkipHelper {
|
|
|
24
24
|
return !!lastNumber && lastNumber === tripNumber;
|
|
25
25
|
}
|
|
26
26
|
static hasNoDelayInfo(departure) {
|
|
27
|
-
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
const statePosition = departure["trip.last_position.state_position"];
|
|
31
|
-
const isFinished = statePosition === "after_track" || statePosition === "after_track_delayed";
|
|
32
|
-
return !departure.is_delay_available || isFinished;
|
|
27
|
+
return !departure.is_delay_available;
|
|
33
28
|
}
|
|
34
29
|
/**
|
|
35
30
|
* Used exclusively in departure boards when skip[]=missing is requested (without untracked)
|
|
@@ -104,12 +99,10 @@ class SkipHelper {
|
|
|
104
99
|
if (!("arrival_datetime" in departure)) {
|
|
105
100
|
return false;
|
|
106
101
|
}
|
|
107
|
-
const statePosition = departure["trip.last_position.state_position"];
|
|
108
102
|
const isAtStop = departure.stop_sequence === departure["trip.last_position.this_stop_sequence"];
|
|
109
103
|
const isPassStop = !!departure["trip.last_position.last_stop_sequence"] &&
|
|
110
104
|
departure.stop_sequence <= departure["trip.last_position.last_stop_sequence"];
|
|
111
|
-
|
|
112
|
-
return isAtStop || isPassStop || isFinished;
|
|
105
|
+
return isAtStop || isPassStop;
|
|
113
106
|
}
|
|
114
107
|
static isOutsideStartThreshold(minutesToStart, routeType) {
|
|
115
108
|
const isMetro = routeType === RouteTypeEnums_1.GTFSRouteTypeEnum.METRO;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SkipHelper.js","sourceRoot":"","sources":["../../../../../src/output-gateway/pid/models/helpers/SkipHelper.ts"],"names":[],"mappings":";;;AAAA,uEAA4D;AAG5D,2CAAwC;AACxC,mCAKiB;AAEjB;;;;GAIG;AACH,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAE1C,MAAa,UAAU;IACnB;;;OAGG;IACI,MAAM,CAAC,oBAAoB,CAAC,SAAyB,EAAE,UAAkB;QAC5E,MAAM,aAAa,GAAG,SAAS,CAAC,eAAe,CAAC;QAChD,IAAI,CAAC,aAAa,EAAE;YAChB,OAAO,KAAK,CAAC;SAChB;QAED,MAAM,UAAU,GAAG,aAAa,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC/D,OAAO,CAAC,CAAC,UAAU,IAAI,UAAU,KAAK,UAAU,CAAC;IACrD,CAAC;IAEM,MAAM,CAAC,cAAc,CAAC,SAAyB;QAClD,
|
|
1
|
+
{"version":3,"file":"SkipHelper.js","sourceRoot":"","sources":["../../../../../src/output-gateway/pid/models/helpers/SkipHelper.ts"],"names":[],"mappings":";;;AAAA,uEAA4D;AAG5D,2CAAwC;AACxC,mCAKiB;AAEjB;;;;GAIG;AACH,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAE1C,MAAa,UAAU;IACnB;;;OAGG;IACI,MAAM,CAAC,oBAAoB,CAAC,SAAyB,EAAE,UAAkB;QAC5E,MAAM,aAAa,GAAG,SAAS,CAAC,eAAe,CAAC;QAChD,IAAI,CAAC,aAAa,EAAE;YAChB,OAAO,KAAK,CAAC;SAChB;QAED,MAAM,UAAU,GAAG,aAAa,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC/D,OAAO,CAAC,CAAC,UAAU,IAAI,UAAU,KAAK,UAAU,CAAC;IACrD,CAAC;IAEM,MAAM,CAAC,cAAc,CAAC,SAAyB;QAClD,OAAO,CAAC,SAAS,CAAC,kBAAkB,CAAC;IACzC,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,gBAAgB,CAC1B,SAAyB,EACzB,cAAkD,EAClD,cAAkC,EAClC,OAAO,GAAG,IA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CAAC,CAAC,SAAS,CAAC,WAAW,CAAC;IACnC,CAAC;IAEM,MAAM,CAAC,eAAe,CAAC,SAAyB;QACnD,IAAI,CAAC,CAAC,kBAAkB,IAAI,SAAS,CAAC,EAAE;YACpC,OAAO,KAAK,CAAC;SAChB;QAED,MAAM,QAAQ,GAAG,SAAS,CAAC,aAAa,KAAK,SAAS,CAAC,uCAAuC,CAAC,CAAC;QAChG,MAAM,UAAU,GACZ,CAAC,CAAC,SAAS,CAAC,uCAAuC,CAAC;YACpD,SAAS,CAAC,aAAa,IAAI,SAAS,CAAC,uCAAuC,CAAC,CAAC;QAElF,OAAO,QAAQ,IAAI,UAAU,CAAC;IAClC,CAAC;IAEO,MAAM,CAAC,uBAAuB,CAAC,cAAsB,EAAE,SAA4B;QACvF,MAAM,OAAO,GAAG,SAAS,KAAK,kCAAiB,CAAC,KAAK,CAAC;QACtD,OAAO,OAAO,CAAC,CAAC,CAAC,cAAc,IAAI,0CAAkC,CAAC,CAAC,CAAC,cAAc,IAAI,oCAA4B,CAAC;IAC3H,CAAC;IAEO,MAAM,CAAC,kBAAkB,CAAC,cAAsB;QACpD,OAAO,cAAc,GAAG,oCAA4B,CAAC;IACzD,CAAC;IAEO,MAAM,CAAC,2BAA2B,CAAC,YAAkB,EAAE,cAAoB;QAC/E,MAAM,oBAAoB,GAAG,CAAC,cAAc,CAAC,OAAO,EAAE,GAAG,YAAY,CAAC,OAAO,EAAE,CAAC,GAAG,KAAK,CAAC;QACzF,OAAO,oBAAoB,IAAI,kCAA0B,CAAC;IAC9D,CAAC;CACJ;AAxID,gCAwIC"}
|
|
@@ -10,8 +10,6 @@ export declare class DepartureBoardFacade {
|
|
|
10
10
|
private readonly stopTimeRepository;
|
|
11
11
|
private readonly descriptorRepository;
|
|
12
12
|
private readonly transformation;
|
|
13
|
-
private static readonly OPEN_MINUTES_IN_PAST;
|
|
14
|
-
private static readonly OPEN_MINUTES_IN_PAST_MS;
|
|
15
13
|
constructor(departureRepository: IGtfsDepartureRepository, tripRepository: IVehiclePositionsRepository, stopTimeRepository: IStopTimeRepository, descriptorRepository: VehicleDescriptorCachedRepository);
|
|
16
14
|
getAll(stopIds: Set<IDepartureBoardsStopIdGroups>, limit: number, routeShortNames: string[] | null, minutesAfter: number, minutesBefore: number): Promise<PublicApiDepartureBoardGroup[] | null>;
|
|
17
15
|
private handleStopGroupDepartures;
|
|
@@ -45,7 +45,7 @@ class DepartureBoardFacade {
|
|
|
45
45
|
let outputGroup = [];
|
|
46
46
|
const spanDepartures = (0, trace_provider_1.createChildSpan)(`Departures.${stopGroup.priority}.getPublicDepartureCache`);
|
|
47
47
|
const timeFrom = new Date(Date.now() - minutesBefore * 60 * 1000);
|
|
48
|
-
const departures = await this.departureRepository.getPublicGtfsDepartureCache(stopGroup.stopIds, minutesAfter
|
|
48
|
+
const departures = await this.departureRepository.getPublicGtfsDepartureCache(stopGroup.stopIds, minutesAfter, timeFrom);
|
|
49
49
|
spanDepartures?.end();
|
|
50
50
|
if (departures.length === 0) {
|
|
51
51
|
return null;
|
|
@@ -127,6 +127,4 @@ class DepartureBoardFacade {
|
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
exports.DepartureBoardFacade = DepartureBoardFacade;
|
|
130
|
-
DepartureBoardFacade.OPEN_MINUTES_IN_PAST = 30;
|
|
131
|
-
DepartureBoardFacade.OPEN_MINUTES_IN_PAST_MS = DepartureBoardFacade.OPEN_MINUTES_IN_PAST * 60 * 1000;
|
|
132
130
|
//# sourceMappingURL=DepartureBoardFacade.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DepartureBoardFacade.js","sourceRoot":"","sources":["../../../../../src/output-gateway/public/service/facade/DepartureBoardFacade.ts"],"names":[],"mappings":";;;AAAA,uEAA4D;AAU5D,+FAA6F;AAC7F,6EAA8F;AAC9F,4EAAyE;AACzE,oGAAiG;AAEjG,MAAa,oBAAoB;
|
|
1
|
+
{"version":3,"file":"DepartureBoardFacade.js","sourceRoot":"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AAC;IACvB,CAAC;IAEO,wBAAwB,CAAC,OAA0C;QACvE,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;IACvE,CAAC;CACJ;AAzKD,oDAyKC"}
|
package/docs/openapi-output.yaml
CHANGED
|
@@ -1964,7 +1964,7 @@ paths:
|
|
|
1964
1964
|
type: integer
|
|
1965
1965
|
minimum: -359
|
|
1966
1966
|
maximum: 30
|
|
1967
|
-
description:
|
|
1967
|
+
description: Set the starting point of the departure retrieval window, in minutes, relative to now (or to timeFrom, if used). Positive values will return departures starting earlier in the past. Negative values will return departures starting later in the future. This setting helps account for walking time to the stop. Example: 2 returns departures that left 2 minutes ago. -10 returns departures no earlier then 10 minutes from now. Default is set to 0. Maximum value is 30. Minimum value is -359.
|
|
1968
1968
|
example: 0
|
|
1969
1969
|
- in: header
|
|
1970
1970
|
name: Accept-Encoding
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@golemio/pid",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0-rc.2122247958",
|
|
4
4
|
"description": "Golemio PID Module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"@golemio/core": ">=1.16.0-rc.1551191551"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
|
-
"@golemio/ovapi-gtfs-realtime-bindings": "1.2.
|
|
78
|
+
"@golemio/ovapi-gtfs-realtime-bindings": "1.2.3",
|
|
79
79
|
"@turf/turf": "^6.5.0",
|
|
80
80
|
"cheap-ruler": "^3.0.2",
|
|
81
81
|
"csv-parser": "^3.0.0",
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var dbm;
|
|
4
|
-
var type;
|
|
5
|
-
var seed;
|
|
6
|
-
var fs = require('fs');
|
|
7
|
-
var path = require('path');
|
|
8
|
-
var Promise;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* We receive the dbmigrate dependency from dbmigrate initially.
|
|
12
|
-
* This enables us to not have to rely on NODE_PATH.
|
|
13
|
-
*/
|
|
14
|
-
exports.setup = function(options, seedLink) {
|
|
15
|
-
dbm = options.dbmigrate;
|
|
16
|
-
type = dbm.dataType;
|
|
17
|
-
seed = seedLink;
|
|
18
|
-
Promise = options.Promise;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
exports.up = function(db) {
|
|
22
|
-
var filePath = path.join(__dirname, 'sqls', '20251020110708-get-departures-add-aftertrack-up.sql');
|
|
23
|
-
return new Promise( function( resolve, reject ) {
|
|
24
|
-
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
|
|
25
|
-
if (err) return reject(err);
|
|
26
|
-
console.log('received data: ' + data);
|
|
27
|
-
|
|
28
|
-
resolve(data);
|
|
29
|
-
});
|
|
30
|
-
})
|
|
31
|
-
.then(function(data) {
|
|
32
|
-
return db.runSql(data);
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
exports.down = function(db) {
|
|
37
|
-
var filePath = path.join(__dirname, 'sqls', '20251020110708-get-departures-add-aftertrack-down.sql');
|
|
38
|
-
return new Promise( function( resolve, reject ) {
|
|
39
|
-
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
|
|
40
|
-
if (err) return reject(err);
|
|
41
|
-
console.log('received data: ' + data);
|
|
42
|
-
|
|
43
|
-
resolve(data);
|
|
44
|
-
});
|
|
45
|
-
})
|
|
46
|
-
.then(function(data) {
|
|
47
|
-
return db.runSql(data);
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
exports._meta = {
|
|
52
|
-
"version": 1
|
|
53
|
-
};
|
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
drop function get_departures;
|
|
2
|
-
drop view v_vehiclepositions_trip_position_vehicle_info;
|
|
3
|
-
|
|
4
|
-
create view v_vehiclepositions_trip_position_vehicle_info as
|
|
5
|
-
select
|
|
6
|
-
"trip->last_position"."delay" as "delay_seconds",
|
|
7
|
-
"trip"."wheelchair_accessible" as "real_wheelchair_accessible",
|
|
8
|
-
"trip->last_position"."is_canceled" as "is_canceled",
|
|
9
|
-
"trip"."agency_name_real" as "trip.agency_name_real",
|
|
10
|
-
"trip"."agency_name_scheduled" as "trip.agency_name_scheduled",
|
|
11
|
-
"trip"."cis_line_id" as "trip.cis_line_id",
|
|
12
|
-
"trip"."cis_line_short_name" as "trip.cis_line_short_name",
|
|
13
|
-
"trip"."cis_trip_number" as "trip.cis_trip_number",
|
|
14
|
-
"trip"."gtfs_block_id" as "trip.gtfs_block_id",
|
|
15
|
-
"trip"."gtfs_route_id" as "trip.gtfs_route_id",
|
|
16
|
-
"trip"."gtfs_route_short_name" as "trip.gtfs_route_short_name",
|
|
17
|
-
"trip"."gtfs_route_type" as "trip.gtfs_route_type",
|
|
18
|
-
"trip"."gtfs_trip_headsign" as "trip.gtfs_trip_headsign",
|
|
19
|
-
"trip"."gtfs_trip_short_name" as "trip.gtfs_trip_short_name",
|
|
20
|
-
"trip"."gtfs_trip_id" as "trip.gtfs_trip_id",
|
|
21
|
-
"trip"."gtfs_date" as "trip.gtfs_date",
|
|
22
|
-
"trip"."id" as "trip.id",
|
|
23
|
-
"trip"."is_canceled" as "trip.is_canceled",
|
|
24
|
-
"trip"."last_position_id" as "trip.last_position_id",
|
|
25
|
-
"trip"."origin_route_name" as "trip.origin_route_name",
|
|
26
|
-
"trip"."run_number" as "trip.run_number",
|
|
27
|
-
"trip"."start_asw_stop_id" as "trip.start_asw_stop_id",
|
|
28
|
-
"trip"."start_cis_stop_id" as "trip.start_cis_stop_id",
|
|
29
|
-
"trip"."start_cis_stop_platform_code" as "trip.start_cis_stop_platform_code",
|
|
30
|
-
"trip"."start_time" as "trip.start_time",
|
|
31
|
-
"trip"."start_timestamp" as "trip.start_timestamp",
|
|
32
|
-
"trip"."end_timestamp" as "trip.end_timestamp",
|
|
33
|
-
"trip"."vehicle_registration_number" as "trip.vehicle_registration_number",
|
|
34
|
-
"trip"."vehicle_type_id" as "trip.vehicle_type_id",
|
|
35
|
-
"trip"."wheelchair_accessible" as "trip.wheelchair_accessible",
|
|
36
|
-
"trip"."internal_route_name" as "trip.internal_route_name",
|
|
37
|
-
"trip"."internal_run_number" as "trip.internal_run_number",
|
|
38
|
-
"trip->last_position"."asw_last_stop_id" as "trip.last_position.asw_last_stop_id",
|
|
39
|
-
"trip->last_position"."bearing" as "trip.last_position.bearing",
|
|
40
|
-
"trip->last_position"."cis_last_stop_id" as "trip.last_position.cis_last_stop_id",
|
|
41
|
-
"trip->last_position"."cis_last_stop_sequence" as "trip.last_position.cis_last_stop_sequence",
|
|
42
|
-
"trip->last_position"."delay" as "trip.last_position.delay",
|
|
43
|
-
"trip->last_position"."delay_stop_arrival" as "trip.last_position.delay_stop_arrival",
|
|
44
|
-
"trip->last_position"."delay_stop_departure" as "trip.last_position.delay_stop_departure",
|
|
45
|
-
"trip->last_position"."id" as "trip.last_position.id",
|
|
46
|
-
"trip->last_position"."is_canceled" as "trip.last_position.is_canceled",
|
|
47
|
-
"trip->last_position"."last_stop_arrival_time" as "trip.last_position.last_stop_arrival_time",
|
|
48
|
-
"trip->last_position"."last_stop_departure_time" as "trip.last_position.last_stop_departure_time",
|
|
49
|
-
"trip->last_position"."last_stop_id" as "trip.last_position.last_stop_id",
|
|
50
|
-
"trip->last_position"."last_stop_sequence" as "trip.last_position.last_stop_sequence",
|
|
51
|
-
"trip->last_position"."lat" as "trip.last_position.lat",
|
|
52
|
-
"trip->last_position"."lng" as "trip.last_position.lng",
|
|
53
|
-
"trip->last_position"."next_stop_arrival_time" as "trip.last_position.next_stop_arrival_time",
|
|
54
|
-
"trip->last_position"."next_stop_departure_time" as "trip.last_position.next_stop_departure_time",
|
|
55
|
-
"trip->last_position"."next_stop_id" as "trip.last_position.next_stop_id",
|
|
56
|
-
"trip->last_position"."next_stop_sequence" as "trip.last_position.next_stop_sequence",
|
|
57
|
-
"trip->last_position"."origin_time" as "trip.last_position.origin_time",
|
|
58
|
-
"trip->last_position"."origin_timestamp" as "trip.last_position.origin_timestamp",
|
|
59
|
-
"trip->last_position"."shape_dist_traveled" as "trip.last_position.shape_dist_traveled",
|
|
60
|
-
"trip->last_position"."speed" as "trip.last_position.speed",
|
|
61
|
-
"trip->last_position"."state_position" as "trip.last_position.state_position",
|
|
62
|
-
"trip->last_position"."state_process" as "trip.last_position.state_process",
|
|
63
|
-
"trip->last_position"."this_stop_id" as "trip.last_position.this_stop_id",
|
|
64
|
-
"trip->last_position"."this_stop_sequence" as "trip.last_position.this_stop_sequence",
|
|
65
|
-
"trip->last_position"."is_tracked" as "trip.last_position.is_tracked",
|
|
66
|
-
"trip->last_position"."trips_id" as "trip.last_position.trips_id",
|
|
67
|
-
"trip->last_position"."tcp_event" as "trip.last_position.tcp_event",
|
|
68
|
-
"trip->last_position"."last_stop_headsign" as "trip.last_position.last_stop_headsign",
|
|
69
|
-
"trip->last_position"."last_stop_name" as "trip.last_position.last_stop_name",
|
|
70
|
-
"trip->last_position"."valid_to" as "trip.last_position.valid_to",
|
|
71
|
-
"trip->last_position"."scheduled_timestamp" as "trip.last_position.scheduled_timestamp",
|
|
72
|
-
"trip->vehicle_descriptor"."id" as "trip.vehicle_descriptor.id",
|
|
73
|
-
"trip->vehicle_descriptor"."is_air_conditioned" as "trip.vehicle_descriptor.is_air_conditioned"
|
|
74
|
-
from
|
|
75
|
-
"vehiclepositions_trips" as "trip"
|
|
76
|
-
inner join "vehiclepositions_positions" as "trip->last_position" on
|
|
77
|
-
"trip"."last_position_id" = "trip->last_position"."id"
|
|
78
|
-
and ("trip->last_position"."valid_to" is null or "trip->last_position"."valid_to" >= current_timestamp)
|
|
79
|
-
and "trip->last_position"."state_position" in ('at_stop', 'before_track', 'before_track_delayed', 'canceled', 'off_track', 'on_track')
|
|
80
|
-
left outer join "vehiclepositions_vehicle_descriptors" as "trip->vehicle_descriptor" on
|
|
81
|
-
"trip"."vehicle_registration_number" = "trip->vehicle_descriptor"."registration_number"
|
|
82
|
-
and trip.gtfs_route_type = "trip->vehicle_descriptor".gtfs_route_type;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
create function get_departures (
|
|
86
|
-
stopsIds varchar,
|
|
87
|
-
mode int,
|
|
88
|
-
dateDepartureBetweenStart timestamptz,
|
|
89
|
-
dateDepartureBetweenEnd timestamptz,
|
|
90
|
-
isNegativeMinutesBefore int,
|
|
91
|
-
dateCanceledDepartureBetweenStart timestamptz,
|
|
92
|
-
dateCanceledDepartureBetweenEnd timestamptz,
|
|
93
|
-
airconditioninfoenabled int
|
|
94
|
-
)
|
|
95
|
-
returns table (
|
|
96
|
-
departure_datetime_real timestamptz,
|
|
97
|
-
arrival_datetime_real timestamptz,
|
|
98
|
-
stop_sequence int2,
|
|
99
|
-
stop_headsign varchar(70),
|
|
100
|
-
arrival_datetime timestamptz,
|
|
101
|
-
departure_datetime timestamptz,
|
|
102
|
-
stop_id varchar(25),
|
|
103
|
-
platform_code varchar(10),
|
|
104
|
-
wheelchair_boarding int2,
|
|
105
|
-
min_stop_sequence int2,
|
|
106
|
-
max_stop_sequence int2,
|
|
107
|
-
trip_id varchar(50),
|
|
108
|
-
trip_headsign varchar(100),
|
|
109
|
-
trip_short_name varchar(30),
|
|
110
|
-
wheelchair_accessible int2,
|
|
111
|
-
route_short_name varchar(50),
|
|
112
|
-
route_type int2,
|
|
113
|
-
route_id varchar(20),
|
|
114
|
-
is_night bpchar(1),
|
|
115
|
-
is_regional bpchar(1),
|
|
116
|
-
is_substitute_transport bpchar(1),
|
|
117
|
-
next_stop_id varchar(30),
|
|
118
|
-
delay_seconds int4,
|
|
119
|
-
real_wheelchair_accessible bool,
|
|
120
|
-
is_canceled bool,
|
|
121
|
-
"trip.gtfs_trip_short_name" varchar(255),
|
|
122
|
-
"trip.gtfs_date" date,
|
|
123
|
-
"trip.internal_route_name" varchar(50),
|
|
124
|
-
"trip.internal_run_number" int4,
|
|
125
|
-
"trip.start_timestamp" timestamptz,
|
|
126
|
-
"trip.last_position.last_stop_id" varchar(255),
|
|
127
|
-
"trip.last_position.last_stop_sequence" int4,
|
|
128
|
-
"trip.last_position.last_stop_name" varchar(255),
|
|
129
|
-
"trip.last_position.this_stop_sequence" int4,
|
|
130
|
-
"trip.cis_stop_platform_code" varchar(15),
|
|
131
|
-
"trip.vehicle_descriptor.is_air_conditioned" bool,
|
|
132
|
-
delay_minutes int4,
|
|
133
|
-
is_delay_available bool,
|
|
134
|
-
run_number int4,
|
|
135
|
-
planned_start_timestamp timestamptz
|
|
136
|
-
|
|
137
|
-
)
|
|
138
|
-
language SQL
|
|
139
|
-
set search_path from current
|
|
140
|
-
as $$
|
|
141
|
-
select
|
|
142
|
-
departure_boards_detailed."computed.departure_datetime_real",
|
|
143
|
-
departure_boards_detailed."computed.arrival_datetime_real",
|
|
144
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.stop_sequence",
|
|
145
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.stop_headsign",
|
|
146
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.arrival_datetime",
|
|
147
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.departure_datetime",
|
|
148
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.stop_id",
|
|
149
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.platform_code",
|
|
150
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.wheelchair_boarding",
|
|
151
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.min_stop_sequence",
|
|
152
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.max_stop_sequence",
|
|
153
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.trip_id",
|
|
154
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.trip_headsign",
|
|
155
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.trip_short_name",
|
|
156
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.wheelchair_accessible",
|
|
157
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.route_short_name",
|
|
158
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.route_type",
|
|
159
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.route_id",
|
|
160
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.is_night",
|
|
161
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.is_regional",
|
|
162
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.is_substitute_transport",
|
|
163
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.next_stop_id",
|
|
164
|
-
departure_boards_detailed."delay_seconds",
|
|
165
|
-
departure_boards_detailed."real_wheelchair_accessible",
|
|
166
|
-
departure_boards_detailed."is_canceled",
|
|
167
|
-
departure_boards_detailed."trip.gtfs_trip_short_name",
|
|
168
|
-
departure_boards_detailed."trip.gtfs_date",
|
|
169
|
-
departure_boards_detailed."trip.internal_route_name",
|
|
170
|
-
departure_boards_detailed."trip.internal_run_number",
|
|
171
|
-
departure_boards_detailed."trip.start_timestamp",
|
|
172
|
-
departure_boards_detailed."trip.last_position.last_stop_id",
|
|
173
|
-
departure_boards_detailed."trip.last_position.last_stop_sequence",
|
|
174
|
-
departure_boards_detailed."trip.last_position.last_stop_name",
|
|
175
|
-
departure_boards_detailed."trip.last_position.this_stop_sequence",
|
|
176
|
-
departure_boards_detailed.cis_stop_platform_code as "trip.cis_stop_platform_code",
|
|
177
|
-
case when airconditioninfoenabled = 1 then departure_boards_detailed."trip.vehicle_descriptor.is_air_conditioned" else NULL end,
|
|
178
|
-
TRUNC(departure_boards_detailed."trip.last_position.delay"::DECIMAL / 60, 0)::int as "delay_minutes",
|
|
179
|
-
case when departure_boards_detailed."trip.last_position.delay" is null then false else true end as "is_delay_available",
|
|
180
|
-
departure_boards_detailed."run.run_number",
|
|
181
|
-
departure_boards_detailed.planned_start_timestamp
|
|
182
|
-
|
|
183
|
-
from (
|
|
184
|
-
select
|
|
185
|
-
("departure_datetime"
|
|
186
|
-
+ MAKE_INTERVAL(secs => (case when "trip.last_position.delay" is null then 0 else "trip.last_position.delay" end))
|
|
187
|
-
- case when (MAKE_INTERVAL(secs => (case when "trip.last_position.delay" is null then 0 else "trip.last_position.delay" end)) > MAKE_INTERVAL())
|
|
188
|
-
then least (
|
|
189
|
-
MAKE_INTERVAL(secs => (case when "trip.last_position.delay" is null then 0 else "trip.last_position.delay" end)),
|
|
190
|
-
("departure_datetime" - "arrival_datetime")::interval
|
|
191
|
-
)
|
|
192
|
-
else MAKE_INTERVAL()
|
|
193
|
-
end
|
|
194
|
-
) "computed.departure_datetime_real",
|
|
195
|
-
"arrival_datetime" + MAKE_INTERVAL(secs => (
|
|
196
|
-
CASE WHEN "trip.last_position.delay" IS NULL THEN 0 ELSE "trip.last_position.delay" end
|
|
197
|
-
)) "computed.arrival_datetime_real",
|
|
198
|
-
"ropidgtfs_precomputed_departures"."stop_sequence" as "ropidgtfs_precomputed_departures.stop_sequence",
|
|
199
|
-
"ropidgtfs_precomputed_departures"."stop_headsign" as "ropidgtfs_precomputed_departures.stop_headsign",
|
|
200
|
-
"ropidgtfs_precomputed_departures"."pickup_type" as "ropidgtfs_precomputed_departures.pickup_type",
|
|
201
|
-
"ropidgtfs_precomputed_departures"."drop_off_type" as "ropidgtfs_precomputed_departures.drop_off_type",
|
|
202
|
-
"ropidgtfs_precomputed_departures"."arrival_time" as "ropidgtfs_precomputed_departures.arrival_time",
|
|
203
|
-
"ropidgtfs_precomputed_departures"."arrival_datetime" as "ropidgtfs_precomputed_departures.arrival_datetime",
|
|
204
|
-
"ropidgtfs_precomputed_departures"."departure_time" as "ropidgtfs_precomputed_departures.departure_time",
|
|
205
|
-
"ropidgtfs_precomputed_departures"."departure_datetime" as "ropidgtfs_precomputed_departures.departure_datetime",
|
|
206
|
-
"ropidgtfs_precomputed_departures"."stop_id" as "ropidgtfs_precomputed_departures.stop_id",
|
|
207
|
-
"ropidgtfs_precomputed_departures"."stop_name" as "ropidgtfs_precomputed_departures.stop_name",
|
|
208
|
-
"ropidgtfs_precomputed_departures"."platform_code" as "ropidgtfs_precomputed_departures.platform_code",
|
|
209
|
-
"ropidgtfs_precomputed_departures"."wheelchair_boarding" as "ropidgtfs_precomputed_departures.wheelchair_boarding",
|
|
210
|
-
"ropidgtfs_precomputed_departures"."min_stop_sequence" as "ropidgtfs_precomputed_departures.min_stop_sequence",
|
|
211
|
-
"ropidgtfs_precomputed_departures"."max_stop_sequence" as "ropidgtfs_precomputed_departures.max_stop_sequence",
|
|
212
|
-
"ropidgtfs_precomputed_departures"."trip_id" as "ropidgtfs_precomputed_departures.trip_id",
|
|
213
|
-
"ropidgtfs_precomputed_departures"."trip_headsign" as "ropidgtfs_precomputed_departures.trip_headsign",
|
|
214
|
-
"ropidgtfs_precomputed_departures"."trip_short_name" as "ropidgtfs_precomputed_departures.trip_short_name",
|
|
215
|
-
"ropidgtfs_precomputed_departures"."wheelchair_accessible" as "ropidgtfs_precomputed_departures.wheelchair_accessible",
|
|
216
|
-
"ropidgtfs_precomputed_departures"."service_id" as "ropidgtfs_precomputed_departures.service_id",
|
|
217
|
-
"ropidgtfs_precomputed_departures"."date" as "ropidgtfs_precomputed_departures.date",
|
|
218
|
-
"ropidgtfs_precomputed_departures"."route_short_name" as "ropidgtfs_precomputed_departures.route_short_name",
|
|
219
|
-
"ropidgtfs_precomputed_departures"."route_type" as "ropidgtfs_precomputed_departures.route_type",
|
|
220
|
-
"ropidgtfs_precomputed_departures"."route_id" as "ropidgtfs_precomputed_departures.route_id",
|
|
221
|
-
"ropidgtfs_precomputed_departures"."is_night" as "ropidgtfs_precomputed_departures.is_night",
|
|
222
|
-
"ropidgtfs_precomputed_departures"."is_regional" as "ropidgtfs_precomputed_departures.is_regional",
|
|
223
|
-
"ropidgtfs_precomputed_departures"."is_substitute_transport" as "ropidgtfs_precomputed_departures.is_substitute_transport",
|
|
224
|
-
"ropidgtfs_precomputed_departures"."next_stop_sequence" as "ropidgtfs_precomputed_departures.next_stop_sequence",
|
|
225
|
-
"ropidgtfs_precomputed_departures"."next_stop_id" as "ropidgtfs_precomputed_departures.next_stop_id",
|
|
226
|
-
"ropidgtfs_precomputed_departures"."last_stop_sequence" as "ropidgtfs_precomputed_departures.last_stop_sequence",
|
|
227
|
-
"ropidgtfs_precomputed_departures"."last_stop_id" as "ropidgtfs_precomputed_departures.last_stop_id",
|
|
228
|
-
plan_start.planned_departure AS planned_start_timestamp,
|
|
229
|
-
x.*,
|
|
230
|
-
cis_stop.cis_stop_platform_code as "cis_stop_platform_code",
|
|
231
|
-
run.run_number as "run.run_number"
|
|
232
|
-
from
|
|
233
|
-
"ropidgtfs_precomputed_departures" as "ropidgtfs_precomputed_departures"
|
|
234
|
-
left join "ropidgtfs_run_numbers" as run on
|
|
235
|
-
"ropidgtfs_precomputed_departures"."trip_id" = run.trip_id
|
|
236
|
-
and "ropidgtfs_precomputed_departures"."service_id" = run.service_id
|
|
237
|
-
left outer join v_vehiclepositions_trip_position_vehicle_info as x on
|
|
238
|
-
"ropidgtfs_precomputed_departures"."trip_id" = x."trip.gtfs_trip_id"
|
|
239
|
-
left join lateral (
|
|
240
|
-
select pd.departure_datetime as planned_departure
|
|
241
|
-
from ropidgtfs_precomputed_departures pd
|
|
242
|
-
where pd.trip_id = "ropidgtfs_precomputed_departures".trip_id
|
|
243
|
-
and pd.date = "ropidgtfs_precomputed_departures".date
|
|
244
|
-
and pd.stop_sequence = 1
|
|
245
|
-
limit 1
|
|
246
|
-
) as plan_start on true
|
|
247
|
-
left join vehiclepositions_cis_stops as cis_stop on
|
|
248
|
-
cis_stop.rt_trip_id = x."trip.id"
|
|
249
|
-
and cis_stop.cis_stop_group_id = "ropidgtfs_precomputed_departures"."cis_stop_group_id"
|
|
250
|
-
) departure_boards_detailed
|
|
251
|
-
where
|
|
252
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.stop_id" = ANY(STRING_TO_ARRAY(stopsIds,','))
|
|
253
|
-
and (
|
|
254
|
-
(
|
|
255
|
-
(
|
|
256
|
-
(mode = 1 and departure_boards_detailed."computed.arrival_datetime_real" between dateDepartureBetweenStart and dateDepartureBetweenEnd)
|
|
257
|
-
or (mode != 1 and departure_boards_detailed."computed.departure_datetime_real" between dateDepartureBetweenStart and dateDepartureBetweenEnd)
|
|
258
|
-
)
|
|
259
|
-
and
|
|
260
|
-
(
|
|
261
|
-
0 = isNegativeMinutesBefore
|
|
262
|
-
or ( -- pro záporné minutes before
|
|
263
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.stop_sequence" >= departure_boards_detailed."trip.last_position.last_stop_sequence"
|
|
264
|
-
or departure_boards_detailed."trip.last_position.last_stop_sequence" IS null
|
|
265
|
-
)
|
|
266
|
-
)
|
|
267
|
-
|
|
268
|
-
)
|
|
269
|
-
or (
|
|
270
|
-
departure_boards_detailed."trip.is_canceled" = true
|
|
271
|
-
and
|
|
272
|
-
(
|
|
273
|
-
(mode = 1 and departure_boards_detailed."computed.arrival_datetime_real" between dateCanceledDepartureBetweenStart and dateCanceledDepartureBetweenEnd)
|
|
274
|
-
or (mode != 1 and departure_boards_detailed."computed.departure_datetime_real" between dateCanceledDepartureBetweenStart and dateCanceledDepartureBetweenEnd)
|
|
275
|
-
)
|
|
276
|
-
)
|
|
277
|
-
) and
|
|
278
|
-
(
|
|
279
|
-
(mode = 1 and (departure_boards_detailed."ropidgtfs_precomputed_departures.pickup_type" != '1' and departure_boards_detailed."ropidgtfs_precomputed_departures.stop_sequence" != departure_boards_detailed."ropidgtfs_precomputed_departures.max_stop_sequence")) -- mode default/departures
|
|
280
|
-
or (mode=2 and (departure_boards_detailed."ropidgtfs_precomputed_departures.drop_off_type" != '1' and departure_boards_detailed."ropidgtfs_precomputed_departures.stop_sequence" != departure_boards_detailed."ropidgtfs_precomputed_departures.min_stop_sequence")) -- mode arrivals
|
|
281
|
-
or (mode=3 and (departure_boards_detailed."ropidgtfs_precomputed_departures.pickup_type" != '1')) -- mode mixed
|
|
282
|
-
);
|
|
283
|
-
$$;
|
|
284
|
-
|
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
drop function get_departures;
|
|
2
|
-
drop view v_vehiclepositions_trip_position_vehicle_info;
|
|
3
|
-
|
|
4
|
-
create view v_vehiclepositions_trip_position_vehicle_info as
|
|
5
|
-
select
|
|
6
|
-
"trip->last_position"."delay" as "delay_seconds",
|
|
7
|
-
"trip"."wheelchair_accessible" as "real_wheelchair_accessible",
|
|
8
|
-
"trip->last_position"."is_canceled" as "is_canceled",
|
|
9
|
-
"trip"."agency_name_real" as "trip.agency_name_real",
|
|
10
|
-
"trip"."agency_name_scheduled" as "trip.agency_name_scheduled",
|
|
11
|
-
"trip"."cis_line_id" as "trip.cis_line_id",
|
|
12
|
-
"trip"."cis_line_short_name" as "trip.cis_line_short_name",
|
|
13
|
-
"trip"."cis_trip_number" as "trip.cis_trip_number",
|
|
14
|
-
"trip"."gtfs_block_id" as "trip.gtfs_block_id",
|
|
15
|
-
"trip"."gtfs_route_id" as "trip.gtfs_route_id",
|
|
16
|
-
"trip"."gtfs_route_short_name" as "trip.gtfs_route_short_name",
|
|
17
|
-
"trip"."gtfs_route_type" as "trip.gtfs_route_type",
|
|
18
|
-
"trip"."gtfs_trip_headsign" as "trip.gtfs_trip_headsign",
|
|
19
|
-
"trip"."gtfs_trip_short_name" as "trip.gtfs_trip_short_name",
|
|
20
|
-
"trip"."gtfs_trip_id" as "trip.gtfs_trip_id",
|
|
21
|
-
"trip"."gtfs_date" as "trip.gtfs_date",
|
|
22
|
-
"trip"."id" as "trip.id",
|
|
23
|
-
"trip"."is_canceled" as "trip.is_canceled",
|
|
24
|
-
"trip"."last_position_id" as "trip.last_position_id",
|
|
25
|
-
"trip"."origin_route_name" as "trip.origin_route_name",
|
|
26
|
-
"trip"."run_number" as "trip.run_number",
|
|
27
|
-
"trip"."start_asw_stop_id" as "trip.start_asw_stop_id",
|
|
28
|
-
"trip"."start_cis_stop_id" as "trip.start_cis_stop_id",
|
|
29
|
-
"trip"."start_cis_stop_platform_code" as "trip.start_cis_stop_platform_code",
|
|
30
|
-
"trip"."start_time" as "trip.start_time",
|
|
31
|
-
"trip"."start_timestamp" as "trip.start_timestamp",
|
|
32
|
-
"trip"."end_timestamp" as "trip.end_timestamp",
|
|
33
|
-
"trip"."vehicle_registration_number" as "trip.vehicle_registration_number",
|
|
34
|
-
"trip"."vehicle_type_id" as "trip.vehicle_type_id",
|
|
35
|
-
"trip"."wheelchair_accessible" as "trip.wheelchair_accessible",
|
|
36
|
-
"trip"."internal_route_name" as "trip.internal_route_name",
|
|
37
|
-
"trip"."internal_run_number" as "trip.internal_run_number",
|
|
38
|
-
"trip->last_position"."asw_last_stop_id" as "trip.last_position.asw_last_stop_id",
|
|
39
|
-
"trip->last_position"."bearing" as "trip.last_position.bearing",
|
|
40
|
-
"trip->last_position"."cis_last_stop_id" as "trip.last_position.cis_last_stop_id",
|
|
41
|
-
"trip->last_position"."cis_last_stop_sequence" as "trip.last_position.cis_last_stop_sequence",
|
|
42
|
-
"trip->last_position"."delay" as "trip.last_position.delay",
|
|
43
|
-
"trip->last_position"."delay_stop_arrival" as "trip.last_position.delay_stop_arrival",
|
|
44
|
-
"trip->last_position"."delay_stop_departure" as "trip.last_position.delay_stop_departure",
|
|
45
|
-
"trip->last_position"."id" as "trip.last_position.id",
|
|
46
|
-
"trip->last_position"."is_canceled" as "trip.last_position.is_canceled",
|
|
47
|
-
"trip->last_position"."last_stop_arrival_time" as "trip.last_position.last_stop_arrival_time",
|
|
48
|
-
"trip->last_position"."last_stop_departure_time" as "trip.last_position.last_stop_departure_time",
|
|
49
|
-
"trip->last_position"."last_stop_id" as "trip.last_position.last_stop_id",
|
|
50
|
-
"trip->last_position"."last_stop_sequence" as "trip.last_position.last_stop_sequence",
|
|
51
|
-
"trip->last_position"."lat" as "trip.last_position.lat",
|
|
52
|
-
"trip->last_position"."lng" as "trip.last_position.lng",
|
|
53
|
-
"trip->last_position"."next_stop_arrival_time" as "trip.last_position.next_stop_arrival_time",
|
|
54
|
-
"trip->last_position"."next_stop_departure_time" as "trip.last_position.next_stop_departure_time",
|
|
55
|
-
"trip->last_position"."next_stop_id" as "trip.last_position.next_stop_id",
|
|
56
|
-
"trip->last_position"."next_stop_sequence" as "trip.last_position.next_stop_sequence",
|
|
57
|
-
"trip->last_position"."origin_time" as "trip.last_position.origin_time",
|
|
58
|
-
"trip->last_position"."origin_timestamp" as "trip.last_position.origin_timestamp",
|
|
59
|
-
"trip->last_position"."shape_dist_traveled" as "trip.last_position.shape_dist_traveled",
|
|
60
|
-
"trip->last_position"."speed" as "trip.last_position.speed",
|
|
61
|
-
"trip->last_position"."state_position" as "trip.last_position.state_position",
|
|
62
|
-
"trip->last_position"."state_process" as "trip.last_position.state_process",
|
|
63
|
-
"trip->last_position"."this_stop_id" as "trip.last_position.this_stop_id",
|
|
64
|
-
"trip->last_position"."this_stop_sequence" as "trip.last_position.this_stop_sequence",
|
|
65
|
-
"trip->last_position"."is_tracked" as "trip.last_position.is_tracked",
|
|
66
|
-
"trip->last_position"."trips_id" as "trip.last_position.trips_id",
|
|
67
|
-
"trip->last_position"."tcp_event" as "trip.last_position.tcp_event",
|
|
68
|
-
"trip->last_position"."last_stop_headsign" as "trip.last_position.last_stop_headsign",
|
|
69
|
-
"trip->last_position"."last_stop_name" as "trip.last_position.last_stop_name",
|
|
70
|
-
"trip->last_position"."valid_to" as "trip.last_position.valid_to",
|
|
71
|
-
"trip->last_position"."scheduled_timestamp" as "trip.last_position.scheduled_timestamp",
|
|
72
|
-
"trip->vehicle_descriptor"."id" as "trip.vehicle_descriptor.id",
|
|
73
|
-
"trip->vehicle_descriptor"."is_air_conditioned" as "trip.vehicle_descriptor.is_air_conditioned"
|
|
74
|
-
from
|
|
75
|
-
"vehiclepositions_trips" as "trip"
|
|
76
|
-
inner join "vehiclepositions_positions" as "trip->last_position" on
|
|
77
|
-
"trip"."last_position_id" = "trip->last_position"."id"
|
|
78
|
-
and (
|
|
79
|
-
"trip->last_position"."valid_to" is null
|
|
80
|
-
or "trip->last_position"."valid_to" >= current_timestamp
|
|
81
|
-
or "trip->last_position"."state_position" in ('after_track', 'after_track_delayed')
|
|
82
|
-
)
|
|
83
|
-
and "trip->last_position"."state_position" in ('at_stop', 'before_track', 'before_track_delayed', 'canceled', 'off_track', 'on_track', 'after_track', 'after_track_delayed')
|
|
84
|
-
left outer join "vehiclepositions_vehicle_descriptors" as "trip->vehicle_descriptor" on
|
|
85
|
-
"trip"."vehicle_registration_number" = "trip->vehicle_descriptor"."registration_number"
|
|
86
|
-
and trip.gtfs_route_type = "trip->vehicle_descriptor".gtfs_route_type;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
create function get_departures (
|
|
90
|
-
stopsIds varchar,
|
|
91
|
-
mode int,
|
|
92
|
-
dateDepartureBetweenStart timestamptz,
|
|
93
|
-
dateDepartureBetweenEnd timestamptz,
|
|
94
|
-
isNegativeMinutesBefore int,
|
|
95
|
-
dateCanceledDepartureBetweenStart timestamptz,
|
|
96
|
-
dateCanceledDepartureBetweenEnd timestamptz,
|
|
97
|
-
airconditioninfoenabled int
|
|
98
|
-
)
|
|
99
|
-
returns table (
|
|
100
|
-
departure_datetime_real timestamptz,
|
|
101
|
-
arrival_datetime_real timestamptz,
|
|
102
|
-
stop_sequence int2,
|
|
103
|
-
stop_headsign varchar(70),
|
|
104
|
-
arrival_datetime timestamptz,
|
|
105
|
-
departure_datetime timestamptz,
|
|
106
|
-
stop_id varchar(25),
|
|
107
|
-
platform_code varchar(10),
|
|
108
|
-
wheelchair_boarding int2,
|
|
109
|
-
min_stop_sequence int2,
|
|
110
|
-
max_stop_sequence int2,
|
|
111
|
-
trip_id varchar(50),
|
|
112
|
-
trip_headsign varchar(100),
|
|
113
|
-
trip_short_name varchar(30),
|
|
114
|
-
wheelchair_accessible int2,
|
|
115
|
-
route_short_name varchar(50),
|
|
116
|
-
route_type int2,
|
|
117
|
-
route_id varchar(20),
|
|
118
|
-
is_night bpchar(1),
|
|
119
|
-
is_regional bpchar(1),
|
|
120
|
-
is_substitute_transport bpchar(1),
|
|
121
|
-
next_stop_id varchar(30),
|
|
122
|
-
delay_seconds int4,
|
|
123
|
-
real_wheelchair_accessible bool,
|
|
124
|
-
is_canceled bool,
|
|
125
|
-
"trip.gtfs_trip_short_name" varchar(255),
|
|
126
|
-
"trip.gtfs_date" date,
|
|
127
|
-
"trip.internal_route_name" varchar(50),
|
|
128
|
-
"trip.internal_run_number" int4,
|
|
129
|
-
"trip.start_timestamp" timestamptz,
|
|
130
|
-
"trip.last_position.state_position" varchar(50),
|
|
131
|
-
"trip.last_position.last_stop_id" varchar(255),
|
|
132
|
-
"trip.last_position.last_stop_sequence" int4,
|
|
133
|
-
"trip.last_position.last_stop_name" varchar(255),
|
|
134
|
-
"trip.last_position.this_stop_sequence" int4,
|
|
135
|
-
"trip.cis_stop_platform_code" varchar(15),
|
|
136
|
-
"trip.vehicle_descriptor.is_air_conditioned" bool,
|
|
137
|
-
delay_minutes int4,
|
|
138
|
-
is_delay_available bool,
|
|
139
|
-
run_number int4,
|
|
140
|
-
planned_start_timestamp timestamptz
|
|
141
|
-
|
|
142
|
-
)
|
|
143
|
-
language SQL
|
|
144
|
-
set search_path from current
|
|
145
|
-
as $$
|
|
146
|
-
select
|
|
147
|
-
departure_boards_detailed."computed.departure_datetime_real",
|
|
148
|
-
departure_boards_detailed."computed.arrival_datetime_real",
|
|
149
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.stop_sequence",
|
|
150
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.stop_headsign",
|
|
151
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.arrival_datetime",
|
|
152
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.departure_datetime",
|
|
153
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.stop_id",
|
|
154
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.platform_code",
|
|
155
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.wheelchair_boarding",
|
|
156
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.min_stop_sequence",
|
|
157
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.max_stop_sequence",
|
|
158
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.trip_id",
|
|
159
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.trip_headsign",
|
|
160
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.trip_short_name",
|
|
161
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.wheelchair_accessible",
|
|
162
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.route_short_name",
|
|
163
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.route_type",
|
|
164
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.route_id",
|
|
165
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.is_night",
|
|
166
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.is_regional",
|
|
167
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.is_substitute_transport",
|
|
168
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.next_stop_id",
|
|
169
|
-
departure_boards_detailed."delay_seconds",
|
|
170
|
-
departure_boards_detailed."real_wheelchair_accessible",
|
|
171
|
-
departure_boards_detailed."is_canceled",
|
|
172
|
-
departure_boards_detailed."trip.gtfs_trip_short_name",
|
|
173
|
-
departure_boards_detailed."trip.gtfs_date",
|
|
174
|
-
departure_boards_detailed."trip.internal_route_name",
|
|
175
|
-
departure_boards_detailed."trip.internal_run_number",
|
|
176
|
-
departure_boards_detailed."trip.start_timestamp",
|
|
177
|
-
departure_boards_detailed."trip.last_position.state_position",
|
|
178
|
-
departure_boards_detailed."trip.last_position.last_stop_id",
|
|
179
|
-
departure_boards_detailed."trip.last_position.last_stop_sequence",
|
|
180
|
-
departure_boards_detailed."trip.last_position.last_stop_name",
|
|
181
|
-
departure_boards_detailed."trip.last_position.this_stop_sequence",
|
|
182
|
-
departure_boards_detailed.cis_stop_platform_code as "trip.cis_stop_platform_code",
|
|
183
|
-
case when airconditioninfoenabled = 1 then departure_boards_detailed."trip.vehicle_descriptor.is_air_conditioned" else NULL end,
|
|
184
|
-
TRUNC(departure_boards_detailed."trip.last_position.delay"::DECIMAL / 60, 0)::int as "delay_minutes",
|
|
185
|
-
case when departure_boards_detailed."trip.last_position.delay" is null then false else true end as "is_delay_available",
|
|
186
|
-
departure_boards_detailed."run.run_number",
|
|
187
|
-
departure_boards_detailed.planned_start_timestamp
|
|
188
|
-
|
|
189
|
-
from (
|
|
190
|
-
select
|
|
191
|
-
("departure_datetime"
|
|
192
|
-
+ MAKE_INTERVAL(secs => (case when "trip.last_position.delay" is null then 0 else "trip.last_position.delay" end))
|
|
193
|
-
- case when (MAKE_INTERVAL(secs => (case when "trip.last_position.delay" is null then 0 else "trip.last_position.delay" end)) > MAKE_INTERVAL())
|
|
194
|
-
then least (
|
|
195
|
-
MAKE_INTERVAL(secs => (case when "trip.last_position.delay" is null then 0 else "trip.last_position.delay" end)),
|
|
196
|
-
("departure_datetime" - "arrival_datetime")::interval
|
|
197
|
-
)
|
|
198
|
-
else MAKE_INTERVAL()
|
|
199
|
-
end
|
|
200
|
-
) "computed.departure_datetime_real",
|
|
201
|
-
"arrival_datetime" + MAKE_INTERVAL(secs => (
|
|
202
|
-
CASE WHEN "trip.last_position.delay" IS NULL THEN 0 ELSE "trip.last_position.delay" end
|
|
203
|
-
)) "computed.arrival_datetime_real",
|
|
204
|
-
"ropidgtfs_precomputed_departures"."stop_sequence" as "ropidgtfs_precomputed_departures.stop_sequence",
|
|
205
|
-
"ropidgtfs_precomputed_departures"."stop_headsign" as "ropidgtfs_precomputed_departures.stop_headsign",
|
|
206
|
-
"ropidgtfs_precomputed_departures"."pickup_type" as "ropidgtfs_precomputed_departures.pickup_type",
|
|
207
|
-
"ropidgtfs_precomputed_departures"."drop_off_type" as "ropidgtfs_precomputed_departures.drop_off_type",
|
|
208
|
-
"ropidgtfs_precomputed_departures"."arrival_time" as "ropidgtfs_precomputed_departures.arrival_time",
|
|
209
|
-
"ropidgtfs_precomputed_departures"."arrival_datetime" as "ropidgtfs_precomputed_departures.arrival_datetime",
|
|
210
|
-
"ropidgtfs_precomputed_departures"."departure_time" as "ropidgtfs_precomputed_departures.departure_time",
|
|
211
|
-
"ropidgtfs_precomputed_departures"."departure_datetime" as "ropidgtfs_precomputed_departures.departure_datetime",
|
|
212
|
-
"ropidgtfs_precomputed_departures"."stop_id" as "ropidgtfs_precomputed_departures.stop_id",
|
|
213
|
-
"ropidgtfs_precomputed_departures"."stop_name" as "ropidgtfs_precomputed_departures.stop_name",
|
|
214
|
-
"ropidgtfs_precomputed_departures"."platform_code" as "ropidgtfs_precomputed_departures.platform_code",
|
|
215
|
-
"ropidgtfs_precomputed_departures"."wheelchair_boarding" as "ropidgtfs_precomputed_departures.wheelchair_boarding",
|
|
216
|
-
"ropidgtfs_precomputed_departures"."min_stop_sequence" as "ropidgtfs_precomputed_departures.min_stop_sequence",
|
|
217
|
-
"ropidgtfs_precomputed_departures"."max_stop_sequence" as "ropidgtfs_precomputed_departures.max_stop_sequence",
|
|
218
|
-
"ropidgtfs_precomputed_departures"."trip_id" as "ropidgtfs_precomputed_departures.trip_id",
|
|
219
|
-
"ropidgtfs_precomputed_departures"."trip_headsign" as "ropidgtfs_precomputed_departures.trip_headsign",
|
|
220
|
-
"ropidgtfs_precomputed_departures"."trip_short_name" as "ropidgtfs_precomputed_departures.trip_short_name",
|
|
221
|
-
"ropidgtfs_precomputed_departures"."wheelchair_accessible" as "ropidgtfs_precomputed_departures.wheelchair_accessible",
|
|
222
|
-
"ropidgtfs_precomputed_departures"."service_id" as "ropidgtfs_precomputed_departures.service_id",
|
|
223
|
-
"ropidgtfs_precomputed_departures"."date" as "ropidgtfs_precomputed_departures.date",
|
|
224
|
-
"ropidgtfs_precomputed_departures"."route_short_name" as "ropidgtfs_precomputed_departures.route_short_name",
|
|
225
|
-
"ropidgtfs_precomputed_departures"."route_type" as "ropidgtfs_precomputed_departures.route_type",
|
|
226
|
-
"ropidgtfs_precomputed_departures"."route_id" as "ropidgtfs_precomputed_departures.route_id",
|
|
227
|
-
"ropidgtfs_precomputed_departures"."is_night" as "ropidgtfs_precomputed_departures.is_night",
|
|
228
|
-
"ropidgtfs_precomputed_departures"."is_regional" as "ropidgtfs_precomputed_departures.is_regional",
|
|
229
|
-
"ropidgtfs_precomputed_departures"."is_substitute_transport" as "ropidgtfs_precomputed_departures.is_substitute_transport",
|
|
230
|
-
"ropidgtfs_precomputed_departures"."next_stop_sequence" as "ropidgtfs_precomputed_departures.next_stop_sequence",
|
|
231
|
-
"ropidgtfs_precomputed_departures"."next_stop_id" as "ropidgtfs_precomputed_departures.next_stop_id",
|
|
232
|
-
"ropidgtfs_precomputed_departures"."last_stop_sequence" as "ropidgtfs_precomputed_departures.last_stop_sequence",
|
|
233
|
-
"ropidgtfs_precomputed_departures"."last_stop_id" as "ropidgtfs_precomputed_departures.last_stop_id",
|
|
234
|
-
plan_start.planned_departure AS planned_start_timestamp,
|
|
235
|
-
x.*,
|
|
236
|
-
cis_stop.cis_stop_platform_code as "cis_stop_platform_code",
|
|
237
|
-
run.run_number as "run.run_number"
|
|
238
|
-
from
|
|
239
|
-
"ropidgtfs_precomputed_departures" as "ropidgtfs_precomputed_departures"
|
|
240
|
-
left join "ropidgtfs_run_numbers" as run on
|
|
241
|
-
"ropidgtfs_precomputed_departures"."trip_id" = run.trip_id
|
|
242
|
-
and "ropidgtfs_precomputed_departures"."service_id" = run.service_id
|
|
243
|
-
left outer join v_vehiclepositions_trip_position_vehicle_info as x on
|
|
244
|
-
"ropidgtfs_precomputed_departures"."trip_id" = x."trip.gtfs_trip_id"
|
|
245
|
-
left join lateral (
|
|
246
|
-
select pd.departure_datetime as planned_departure
|
|
247
|
-
from ropidgtfs_precomputed_departures pd
|
|
248
|
-
where pd.trip_id = "ropidgtfs_precomputed_departures".trip_id
|
|
249
|
-
and pd.date = "ropidgtfs_precomputed_departures".date
|
|
250
|
-
and pd.stop_sequence = 1
|
|
251
|
-
limit 1
|
|
252
|
-
) as plan_start on true
|
|
253
|
-
left join vehiclepositions_cis_stops as cis_stop on
|
|
254
|
-
cis_stop.rt_trip_id = x."trip.id"
|
|
255
|
-
and cis_stop.cis_stop_group_id = "ropidgtfs_precomputed_departures"."cis_stop_group_id"
|
|
256
|
-
) departure_boards_detailed
|
|
257
|
-
where
|
|
258
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.stop_id" = ANY(STRING_TO_ARRAY(stopsIds,','))
|
|
259
|
-
and (
|
|
260
|
-
(
|
|
261
|
-
(
|
|
262
|
-
(mode = 1 and departure_boards_detailed."computed.arrival_datetime_real" between dateDepartureBetweenStart and dateDepartureBetweenEnd)
|
|
263
|
-
or (mode != 1 and departure_boards_detailed."computed.departure_datetime_real" between dateDepartureBetweenStart and dateDepartureBetweenEnd)
|
|
264
|
-
)
|
|
265
|
-
and
|
|
266
|
-
(
|
|
267
|
-
0 = isNegativeMinutesBefore
|
|
268
|
-
or ( -- pro záporné minutes before
|
|
269
|
-
departure_boards_detailed."ropidgtfs_precomputed_departures.stop_sequence" >= departure_boards_detailed."trip.last_position.last_stop_sequence"
|
|
270
|
-
or departure_boards_detailed."trip.last_position.last_stop_sequence" IS null
|
|
271
|
-
)
|
|
272
|
-
)
|
|
273
|
-
|
|
274
|
-
)
|
|
275
|
-
or (
|
|
276
|
-
departure_boards_detailed."trip.is_canceled" = true
|
|
277
|
-
and
|
|
278
|
-
(
|
|
279
|
-
(mode = 1 and departure_boards_detailed."computed.arrival_datetime_real" between dateCanceledDepartureBetweenStart and dateCanceledDepartureBetweenEnd)
|
|
280
|
-
or (mode != 1 and departure_boards_detailed."computed.departure_datetime_real" between dateCanceledDepartureBetweenStart and dateCanceledDepartureBetweenEnd)
|
|
281
|
-
)
|
|
282
|
-
)
|
|
283
|
-
) and
|
|
284
|
-
(
|
|
285
|
-
(mode = 1 and (departure_boards_detailed."ropidgtfs_precomputed_departures.pickup_type" != '1' and departure_boards_detailed."ropidgtfs_precomputed_departures.stop_sequence" != departure_boards_detailed."ropidgtfs_precomputed_departures.max_stop_sequence")) -- mode default/departures
|
|
286
|
-
or (mode=2 and (departure_boards_detailed."ropidgtfs_precomputed_departures.drop_off_type" != '1' and departure_boards_detailed."ropidgtfs_precomputed_departures.stop_sequence" != departure_boards_detailed."ropidgtfs_precomputed_departures.min_stop_sequence")) -- mode arrivals
|
|
287
|
-
or (mode=3 and (departure_boards_detailed."ropidgtfs_precomputed_departures.pickup_type" != '1')) -- mode mixed
|
|
288
|
-
);
|
|
289
|
-
$$;
|