@golemio/pid 5.7.2-dev.2368357435 → 5.7.2-dev.2373103436

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.
@@ -21,17 +21,17 @@ class CommonMessageProcessor {
21
21
  this.processTransformedRun = async (element, firstMessageCreatedAt) => {
22
22
  this.logElementIssues(element);
23
23
  const record = await this.runsRepository.getRunRecordForUpdate(element.run);
24
+ // Read flag set by filter (avoids duplicate whitelist check)
25
+ const isNotPublic = element.isNotPublic === true ? true : undefined;
24
26
  let outputMsg;
25
27
  if (record) {
26
28
  // Data quality check: Ensure scheduled vehicles have timestamps
27
29
  // Not-public vehicles (replacement buses/trams) don't need scheduled timestamps
28
30
  // Regular scheduled vehicles MUST have a timestamp or be able to get one from history
29
31
  if (!element.run_message.actual_stop_timestamp_scheduled) {
30
- // Read flag set by filter (avoids duplicate whitelist check)
31
- const isNotPublicVehicle = element.isNotPublic === true;
32
32
  // If NOT a not-public vehicle, try to get timestamp from last message
33
33
  // If we can't get it, skip this message (data quality issue)
34
- if (!isNotPublicVehicle) {
34
+ if (!isNotPublic) {
35
35
  const lastRecordMessage = await this.runsRepository["runsMessagesRepository"].getLastMessage(record.id);
36
36
  if (!lastRecordMessage || !lastRecordMessage.actual_stop_timestamp_scheduled) {
37
37
  // Cannot process scheduled vehicle without timestamp
@@ -46,7 +46,7 @@ class CommonMessageProcessor {
46
46
  else {
47
47
  outputMsg = await this.runsRepository.createAndAssociate(element);
48
48
  }
49
- await queueprocessors_1.QueueManager.sendMessageToExchange(`${config_1.config.RABBIT_EXCHANGE_NAME}.${vehicle_positions_1.VehiclePositions.name.toLowerCase()}`, "updateRunsGTFSTripId", outputMsg, { timestamp: firstMessageCreatedAt });
49
+ await queueprocessors_1.QueueManager.sendMessageToExchange(`${config_1.config.RABBIT_EXCHANGE_NAME}.${vehicle_positions_1.VehiclePositions.name.toLowerCase()}`, "updateRunsGTFSTripId", { ...outputMsg, isNotPublic }, { timestamp: firstMessageCreatedAt });
50
50
  };
51
51
  this.logger = Di_1.PidContainer.resolve(CoreToken_1.CoreToken.Logger);
52
52
  }
@@ -1 +1 @@
1
- {"version":3,"file":"CommonMessageProcessor.js","sourceRoot":"","sources":["../../../../../../src/integration-engine/vehicle-positions/workers/runs/helpers/CommonMessageProcessor.ts"],"names":[],"mappings":";;;AAAA,2CAA0C;AAC1C,2FAA0D;AAE1D,wEAAqE;AAErE,yEAAsE;AACtE,2FAAqF;AACrF,6EAAwE;AAGxE,MAAM,kBAAkB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAC1C,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAEjC,MAAa,sBAAsB;IAG/B,YAA6B,cAAoC;QAApC,mBAAc,GAAd,cAAc,CAAsB;QAIjE;;;;;WAKG;QACI,0BAAqB,GAAG,KAAK,EAAE,OAAiC,EAAE,qBAA8B,EAAiB,EAAE;YACtH,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;YAC/B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,qBAAqB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAE5E,IAAI,SAAmC,CAAC;YACxC,IAAI,MAAM,EAAE,CAAC;gBACT,gEAAgE;gBAChE,gFAAgF;gBAChF,sFAAsF;gBACtF,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,+BAA+B,EAAE,CAAC;oBACvD,6DAA6D;oBAC7D,MAAM,kBAAkB,GAAG,OAAO,CAAC,WAAW,KAAK,IAAI,CAAC;oBAExD,sEAAsE;oBACtE,6DAA6D;oBAC7D,IAAI,CAAC,kBAAkB,EAAE,CAAC;wBACtB,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,wBAAwB,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;wBACxG,IAAI,CAAC,iBAAiB,IAAI,CAAC,iBAAiB,CAAC,+BAA+B,EAAE,CAAC;4BAC3E,qDAAqD;4BACrD,OAAO;wBACX,CAAC;wBACD,OAAO,CAAC,WAAW,CAAC,+BAA+B,GAAG,iBAAiB,CAAC,+BAA+B,CAAC;oBAC5G,CAAC;oBACD,4EAA4E;gBAChF,CAAC;gBAED,SAAS,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;YACjF,CAAC;iBAAM,CAAC;gBACJ,SAAS,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;YACtE,CAAC;YAED,MAAM,8BAAY,CAAC,qBAAqB,CACpC,GAAG,eAAM,CAAC,oBAAoB,IAAI,oCAAgB,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,EACvE,sBAAsB,EACtB,SAAS,EACT,EAAE,SAAS,EAAE,qBAAqB,EAAE,CACvC,CAAC;QACN,CAAC,CAAC;QA9CE,IAAI,CAAC,MAAM,GAAG,iBAAY,CAAC,OAAO,CAAU,qBAAS,CAAC,MAAM,CAAC,CAAC;IAClE,CAAC;IA+CO,gBAAgB,CAAC,OAAiC;QACtD,IACI,OAAO,CAAC,WAAW,CAAC,+BAA+B,YAAY,IAAI;YACnE,OAAO,CAAC,WAAW,CAAC,+BAA+B,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE;gBACtE,qBAAqB,GAAG,kBAAkB,EAChD,CAAC;YACC,IAAI,CAAC,MAAM,CAAC,KAAK,CACb,IAAI,6BAAY,CACZ,qCAAqC,OAAO,CAAC,WAAW,CAAC,+BAA+B,CAAC,WAAW,EAAE,GAAG;gBACrG,OAAO,qBAAqB,qBAAqB,OAAO,CAAC,GAAG,CAAC,eAAe,OAAO;gBACnF,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,GAAG,EACjC,IAAI,CAAC,WAAW,CAAC,IAAI,EACrB,SAAS,EACT,SAAS,EACT,KAAK,CACR,CACJ,CAAC;QACN,CAAC;IACL,CAAC;CACJ;AAvED,wDAuEC"}
1
+ {"version":3,"file":"CommonMessageProcessor.js","sourceRoot":"","sources":["../../../../../../src/integration-engine/vehicle-positions/workers/runs/helpers/CommonMessageProcessor.ts"],"names":[],"mappings":"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"}
@@ -707,8 +707,12 @@ components:
707
707
  type: string
708
708
  description: The timestamp when the message was last sent.
709
709
  wheelchair_accessible:
710
- type: boolean
711
- description: Indicates if the vehicle is wheelchair accessible.
710
+ type: [boolean, "null"]
711
+ description: |
712
+ Raw wheelchair accessibility flag from vehiclepositions_trips.
713
+ Mapped to wheelchairAccessible proto enum in GTFS-RT VehicleDescriptor:
714
+ null → WHEELCHAIR_ACCESSIBLE_UNSPECIFIED (0), true → WHEELCHAIR_ACCESSIBLE (1), false → WHEELCHAIR_INACCESSIBLE (2).
715
+ The OVAPI extension .transit_realtime.ovapiVehicleDescriptor.wheelchairAccessible retains the raw boolean/null value alongside the standard field.
712
716
  ICommonRunsMessagesModel:
713
717
  type: object
714
718
  properties:
@@ -275,6 +275,7 @@ flowchart TD
275
275
  - `vpPublicCache:$setId:canceled-trips-$gtfsTripId` - JSON jako string s informacemi o zrušeném spoji. Využití v public odjezdech
276
276
  - TTL 1 minuta
277
277
  - Nová datová sada se generuje přibližně jednou za 3 vteřiny a obsahuje všechny RT spoje (aktivní, budoucí a zrušené)
278
+ - Populace `future-trip-*`, `future-vehicle-*` a `canceled-trips-*` sub-klíčů je řízena stavem spoje (před trasou / zrušen) a nesouvisí s logikou deduplikace odjezdů v `/v2/public/departureboards` – ta pracuje nad `gtfsPublicDepartureCache` a tuto cache neovlivňuje
278
279
 
279
280
  ### vpPublicStopTimeCache:*
280
281
 
@@ -294,14 +295,29 @@ flowchart TD
294
295
  ### gtfsPublicDepartureCache:*
295
296
 
296
297
  - Klíč `gtfsPublicDepartureCache:*`, kde `*` je GTFS id zastávky
297
- - Hodnota je sorted set, kde score je unix timestamp odjezdu v sekundách a member jsou relevantní informace o odjezdu
298
+ - Hodnota je sorted set, kde score je unix timestamp odjezdu v sekundách a member je JSON string s informacemi o odjezdu:
299
+ - `stop_id` – GTFS id zastávky
300
+ - `departure_datetime` – plánovaný čas odjezdu (ISO 8601)
301
+ - `arrival_datetime` – plánovaný čas příjezdu (ISO 8601), nebo `null`
302
+ - `route_short_name` – název linky
303
+ - `route_type` – typ dopravy (GTFS route_type)
304
+ - `trip_id` – GTFS id spoje
305
+ - `stop_sequence` – pořadí zastávky v spoji
306
+ - `platform_code` – označení nástupiště, nebo `null`
307
+ - `trip_headsign` – cílová zastávka spoje (nebo `stop_headsign`, pokud je definován)
308
+ - `trip_headsign_icons` – ikony přestupů u cílové zastávky jako řetězec dvouznaková kódů (např. `"MbMcSb"`), nebo `null`
309
+ - `connections` – seznam garantovaných přestupů čekajících na tento spoj, nebo `null`; každý záznam obsahuje:
310
+ - `from_trip_id` – GTFS id spoje, na který se čeká
311
+ - `max_wait_sec` – maximální čekací doba v sekundách
312
+ - Přednačítá se z tabulky `ropidgtfs_precomputed_trip_connections` (původně z `transfers.txt` kde `transfer_type = 1`), JOIN na odjezdy přes `to_trip_id` a `to_stop_id`
313
+ - `wheelchair_accessible` – přístupnost vozidla pro vozíčkáře z GTFS `trips.txt` (`0` = bez informace, `1` = přístupné, `2` = nepřístupné), nebo `null`
298
314
  - Existuje záznam pro každou zastávku v GTFS. Pokud v ní ale není žádný odjezd, je vyplněný pouze jeden prázdný member - detekce validní zastávky bez odjezdu
299
315
  - TTL 7 hodin
300
316
  - Retence dat aktivní, jednou za hodinu se smažou všechny odjezdy starší než 3 hodiny
301
317
  - Jednou za hodinu se vygenerují nové odjezdy pro všechny zastávky v intervalu +5 hodin až +7 hodin, po přenačtení JŘ se přegenerují všechny odjezdy v interval -3 hodiny až +7 hodin
302
318
  - Ukládá se pomocí `ZADD`, čte se pomocí `ZRANGEBYSCORE` (-inf, now + `minutesAfter`)
303
319
  - Využití v public odjezdech
304
- - Využití v endpointu přestupních tabulí
320
+ - Využití v endpointu přestupních tabulí (`/v4/pid/transferboards`)
305
321
 
306
322
  ### Flowchart (refresh)
307
323
 
@@ -528,3 +544,15 @@ flowchart LR
528
544
  ![flowchart.svg](../../assets/V4Transferboards.svg)
529
545
 
530
546
  link na .drawio [soubor](../../assets/V4Transferboards.drawio)
547
+
548
+ ## Cache pro konfiguraci
549
+
550
+ ### config:notPublicVehicles
551
+
552
+ - Klíč `config:notPublicVehicles` (jednoduchý klíč, žádný wildcard)
553
+ - Hodnota je JSON string struktury `INotPublicVehicles`:
554
+ - `tram.registrationNumbers` – seznam evidenčních čísel tramvají bez platného GTFS spoje
555
+ - `road.registrationNumbers` – seznam evidenčních čísel autobusů a trolejbusů bez platného GTFS spoje (`road` pokrývá obě kategorie, protože sdílejí číselnou řadu)
556
+ - `routeIds` – whitelist čísel linek (např. `"861"` pro náhradní autobus X-C při výluce metra C) zobrazovaných i bez platného JŘ spoje
557
+ - TTL žádné – hodnota se přepíše při každém spuštění `SaveStaticDataTask` (po načtení nových JŘ)
558
+ - Zapisuje `NotPublicVehiclesRedisRepository` (IE), čte `TripsRepository` / `PositionsMapper` (IE) a `UpdateRunsGtfsTripIdTask` (IE) pro povolení průchodu vozidel bez GTFS spoje
@@ -264,12 +264,14 @@ _:warning: Původním záměrem bylo využití OIS číselníku během zpracová
264
264
  - baseUrl: module.pid.staticData.baseUrl
265
265
  - departure directions url: module.pid.staticData.departuresDirection.path
266
266
  - metro rail track url: module.pid.staticData.metroRailTracks.path
267
+ - not public vehicles url: module.pid.staticData.notPublicVehicles.path
267
268
  - formát dat
268
269
  - protokol: http
269
- - datový typ: csv
270
+ - datový typ: csv (DeparturesDirection, MetroRailTrack), json (NotPublicVehicles)
270
271
  - validační schéma:
271
272
  - [MetroRailTrack](../src/schema-definitions/datasources/static-data/MetroRailTrackJsonSchema.ts)
272
273
  - [DeparturesDirection](../src/schema-definitions/datasources/static-data/DeparturesDirectionsJsonSchema.ts)
274
+ - [NotPublicVehicles](../src/schema-definitions/datasources/static-data/interfaces/NotPublicVehiclesDataInterface.ts) – interface `INotPublicVehicles`
273
275
  - příklad vstupnich dat: viz zdroj data
274
276
  - frekvence stahování
275
277
  - Po nacteni jizdnich radu (fronta: vehicle-positions.ropidgtfs.checkForNewData)
@@ -512,6 +514,9 @@ Všechny tabulky se nachází ve schématu `pid`
512
514
  - [RopidGTFSRunNumbersTransformation](https://gitlab.com/operator-ict/golemio/code/modules/pid/-/blob/development/src/integration-engine/ropid-gtfs/transformations/RopidGTFSRunNumbersTransformation.ts)
513
515
  - [RopidGtfsRouteSubAgencyTransformation](https://gitlab.com/operator-ict/golemio/code/modules/pid/-/blob/development/src/integration-engine/ropid-gtfs/transformations/RopidGtfsRouteSubAgencyTransformation.ts)
514
516
  - on top of transformation functionality it also removes duplicates. Rule: If there are multiple rows with same `route_id` and `sub_agency_id` only the first with filled licence number is kept.
517
+ - rozšířené sloupce GTFS souborů (nestandardní rozšíření ROPID)
518
+ - `trips.txt` – sloupec `headsign_icons`: řetězec dvouznakových kódů ikon (např. `"MbSb"`), uložen do `ropidgtfs_trips.headsign_icons`
519
+ - `stop_times.txt` – sloupec `headsign_icons`: přepis na úrovni zastávky, uložen do `ropidgtfs_stop_times.headsign_icons`; má přednost před hodnotou z `trips.txt` pokud je zároveň vyplněn `stop_headsign`
515
520
  - data modely
516
521
  - RopidGTFSMetadataModel `ropidgtfs_metadata`
517
522
  - RopidGTFSAgencyModel `ropidgtfs_agency`
@@ -562,6 +567,7 @@ Všechny tabulky se nachází ve schématu `pid`
562
567
  - RopidGTFSPrecomputedMinMaxStopSequencesModel `ropidgtfs_precomputed_minmax_stop_sequences`
563
568
  - RopidGTFSPrecomputedDeparturesModel `ropidgtfs_precomputed_departures`
564
569
  - RopidGTFSPrecomputedTripScheduleModel `ropidgtfs_precomputed_trip_schedule`
570
+ - RopidGTFSPrecomputedTripConnectionsModel `ropidgtfs_precomputed_trip_connections`
565
571
 
566
572
  #### task _RefreshPrecomputedTables_
567
573
 
@@ -581,6 +587,7 @@ Všechny tabulky se nachází ve schématu `pid`
581
587
  - RopidGTFSPrecomputedMinMaxStopSequencesModel `ropidgtfs_precomputed_minmax_stop_sequences`
582
588
  - RopidGTFSPrecomputedDeparturesModel `ropidgtfs_precomputed_departures`
583
589
  - RopidGTFSPrecomputedTripScheduleModel `ropidgtfs_precomputed_trip_schedule`
590
+ - RopidGTFSPrecomputedTripConnectionsModel `ropidgtfs_precomputed_trip_connections`
584
591
 
585
592
  #### task _RefreshPublicGtfsDepartureCacheTask_
586
593
 
@@ -596,8 +603,10 @@ Task se stará o aktualizaci cache pro public odjezdy. Pouští se pravidelně c
596
603
  - ROPID FTP
597
604
  - transformace
598
605
  - [PublicDepartureCacheTransformation](../src/integration-engine/ropid-gtfs/transformations/PublicDepartureCacheTransformation.ts)
606
+ - výsledný cache záznam obsahuje pole `connections` (garantované přestupy – přednačtené z `ropidgtfs_precomputed_trip_connections`, původně z `transfers.txt` kde `transfer_type = 1`) a pole `wheelchair_accessible` (přístupnost vozidla pro vozíčkáře z GTFS `trips.txt`)
607
+ - pole `trip_headsign_icons`: pokud je pro danou zastávku spoje vyplněn `stop_headsign`, použije se `stop_headsign_icons` z `ropidgtfs_stop_times`; jinak se použije `headsign_icons` z `ropidgtfs_trips`; výsledek je řetězec dvouznakových kódů (např. `"MbMcSb"`) nebo `null`
599
608
  - data modely
600
- - RopidGTFSPrecomputedDeparturesModel `ropidgtfs_precomputed_departures`
609
+ - RopidGTFSPrecomputedDeparturesModel `ropidgtfs_precomputed_departures` (obsahuje JOIN na `ropidgtfs_precomputed_trip_connections_tmp` přes `to_trip_id` a `to_stop_id`)
601
610
 
602
611
  #### task _SaveStaticData_
603
612
 
@@ -613,9 +622,19 @@ Task se stará o aktualizaci statickych dat. Pouští se po dokončení načten
613
622
  - transformace
614
623
  - [DeparturesDirectionTransformation](../src/integration-engine/ropid-gtfs/workers/timetables/tasks/transformations/DeparturesDirectionTransformation.ts)
615
624
  - [MetroRailtrackDataTransformation](../src/integration-engine/ropid-gtfs/workers/timetables/tasks/transformations/MetroRailtrackDataTransformation.ts)
625
+ - `NotPublicVehicles` – data se ukládají přímo do cache klíče `config:notPublicVehicles` přes `NotPublicVehiclesRedisRepository` (žádná DB tabulka)
616
626
  - data modely
617
627
  - RopidDeparturesDirections `ropid_departures_directions`
618
628
  - RopidGtfsMetroRailtrackGps `ropidgtfs_metro_railtrack_gps`
629
+ - Cache `config:notPublicVehicles` – JSON blob struktury `INotPublicVehicles`:
630
+ ```json
631
+ {
632
+ "tram": { "registrationNumbers": ["string"] },
633
+ "road": { "registrationNumbers": ["string"] },
634
+ "routeIds": ["string"]
635
+ }
636
+ ```
637
+ `road` pokrývá autobusy i trolejbusy (evidenční čísla se mohou překrývat s tramvajemi, proto jsou oddělena). `routeIds` je whitelist číselných identifikátorů náhradních nebo dočasných linek (např. náhradní autobus za metro při výluce nebo mimořádné události), které se mají zobrazovat i bez platného JŘ spoje.
619
638
 
620
639
 
621
640
 
@@ -1062,6 +1081,18 @@ Worker má na starost generování souborů s realtime daty pro `gtfsrt` endpoin
1062
1081
  - VPTripsModel `vehiclepositions_trips`
1063
1082
  - VPPositionsModel `vehiclepositions_positions`
1064
1083
 
1084
+ **`wheelchairAccessible` ve VehicleDescriptor**
1085
+
1086
+ Pole `wheelchairAccessible` je součástí standardního `VehicleDescriptor` ve feedech `vehicle_positions.pb` a `pid_feed.pb`:
1087
+
1088
+ | Interní hodnota | Proto enum |
1089
+ |---|---|
1090
+ | `null` | `WHEELCHAIR_ACCESSIBLE_UNSPECIFIED = 0` |
1091
+ | `true` | `WHEELCHAIR_ACCESSIBLE = 1` |
1092
+ | `false` | `WHEELCHAIR_INACCESSIBLE = 2` |
1093
+
1094
+ Zdrojem je pole `wheelchair_accessible` z tabulky `vehiclepositions_trips` (přenášené přes `IGtfsRtTripDto`). Vedle standardního pole zůstává zachováno rozšíření `.transit_realtime.ovapiVehicleDescriptor.wheelchairAccessible` s původní boolean/null hodnotou.
1095
+
1065
1096
  **Určení zpoždění v trip_updates.pb**
1066
1097
 
1067
1098
  Predikce odjezdů probíhá podle vzorce:
@@ -1167,6 +1198,10 @@ Worker má na starost stahování VYMI (JIS) událostí a infotextů, jejich tra
1167
1198
  - data modely
1168
1199
  - JISEventsModel `jis_events`
1169
1200
  - JISEventsRopidGTFSRoutesModel `jis_events_ropidgtfs_routes`
1201
+ - poznámky k datovému modelu
1202
+ - pole `effects` je pole až 3 unikátních řetězců; v GTFS-RT `Alert.effect` se použije pouze `effects[0]`, zbývající hodnoty jsou dostupné pouze v custom-format exportu
1203
+ - pole `cause_detail` je volný text zpřesňující příčinu události; může být `null`
1204
+ - pole `cause` obsahuje překlady do češtiny i angličtiny; anglické hodnoty jsou zahrnuty i ve výstupu GTFS-RT alert feedu
1170
1205
 
1171
1206
  #### _task: RefreshJISInfotextsTask_
1172
1207
 
@@ -1261,7 +1296,7 @@ Worker má na starost stahování VYMI (JIS) událostí a infotextů, jejich tra
1261
1296
  - retence dat
1262
1297
  - jízdní řády se generují 1-2x denně na 14 dní dopředu
1263
1298
  - polohová data si uchováváme 24 hodin (30 minut od poslední aktualizace, poté v historických tabulkách)
1264
- - popis vozidel si uchováváme 24 hodin
1299
+ - popis vozidel se nepromazává přetrvávají do přepsání novými daty (fixní TTL bylo odstraněno)
1265
1300
  - preset logy si uchováváme 8 hodin
1266
1301
  - JIS události a infotexty si uchováváme neomezeně
1267
1302
 
@@ -1404,6 +1439,12 @@ Worker má na starost stahování VYMI (JIS) událostí a infotextů, jejich tra
1404
1439
 
1405
1440
  - zdrojové tabulky
1406
1441
  - `ropidgtfs_precomputed_departures`, `ropidgtfs_stops`, `ropidgtfs_cis_stops`, `jis_infotexts`, `jis_infotexts_ropidgtfs_stops`, `ropid_departures_directions`, `vehiclepositions_positions`, `vehiclepositions_trips`
1442
+ - odpověď obsahuje hlavičku `X-Golemio-Preset-Metadata: airConditionPossible=0|1`
1443
+ - `1` pokud byl zadán query parametr `airCondition` s pravdivou hodnotou, `0` jinak
1444
+ - slouží monitorovacím systémům (preset systémy monitorovacího centra ROPID) k detekci aktivního filtrování dle klimatizace
1445
+ - kód nástupiště (`platform_code`)
1446
+ - **vlaky**: preferuje se CIS hodnota `cis_stop_platform_code` uložená z MPVNet zpráv (`PlatformCodeResolver`); MPVNet atribut `$.stan` je před uložením oříznut na první platný segment (viz [parsování `stan` u vlaků](../processing/input_realtime_data/http_mpvnet.md#parsování-stanoviště-stan-u-vlaků))
1447
+ - **ostatní typy**: používá se GTFS `platform_code` ze `stop_times.txt`
1407
1448
 
1408
1449
  ### PID Departure Boards v3
1409
1450
 
@@ -1411,6 +1452,42 @@ Worker má na starost stahování VYMI (JIS) událostí a infotextů, jejich tra
1411
1452
 
1412
1453
  - načte odjezdy pro přestupní tabule ve vozidlech a aktivní infotexty exportované z aplikace VYMI (JIS) Infotexty
1413
1454
 
1455
+ ### PID Departure Boards v4
1456
+
1457
+ #### _/v4/pid/transferboards_
1458
+
1459
+ - načte odjezdy pro přestupní tabule ve vozidlech na základě aktuální polohy vozidla a aktivní infotexty exportované z aplikace VYMI (JIS) Infotexty
1460
+ - parametry
1461
+ - `aswId` + `vehicleRegistrationNumber` + `routeType` – identifikace zastávky a vozidla přes ASW číselník (vzájemně se vylučuje s `cisId`+`tripNumber`)
1462
+ - `cisId` + `tripNumber` – identifikace zastávky a spoje přes CIS číselník (zatím neimplementováno, vrací 501)
1463
+ - `timeFrom` – volitelný ISO8601 čas příjezdu (pokud není zadán, použije se reálný čas příjezdu z RT dat)
1464
+ - `limit` – volitelný počet odjezdů (výchozí 8, max 30)
1465
+ - cachováno na 5 sekund (stale-while-revalidate 5 sekund)
1466
+ - zdrojové cache záznamy
1467
+ - `gtfsStopsCache:*` – převod ASW node ID na GTFS stop_id
1468
+ - `gtfsDelayComputation:*` – zjištění zastávek spoje a predikovaného času příjezdu
1469
+ - `vpPublicCache:*` – aktuální poloha a zpoždění vozidla
1470
+ - `gtfsPublicDepartureCache:*` – statické odjezdy ze zastávek (vč. `connections` a `wheelchair_accessible`)
1471
+ - `vpPublicStopTimeCache:*` – live zastávkové časy pro spoje se známou polohou
1472
+ - `jisCache:*` – aktivní infotexty pro dané zastávky
1473
+ - načítání odjezdů z cache (`gtfsPublicDepartureCache`)
1474
+ - z každé zastávky se načte `max(80, min(120, limit × 10))` položek v časovém okně `[plannedTimeFrom − 61 min, plannedTimeFrom + 60 min + delay]`; lookback 61 minut zajišťuje, že se zachytí i navazující spoj, jehož plánovaný odjezd je v minulosti, ale díky vlastnímu zpoždění (až 60 minut) dorazí na zastávku až po příjezdu aktuálního vozidla
1475
+ - ihned po načtení se aplikuje pre-filter: odjezdy autobusů, tramvají a trolejbusů ze zastávek s jiným názvem než aktuální zastávka jsou zahozeny; metro/vlak/přívoz/lanovka procházejí vždy; odjezdy s neprázdným polem `connections[]` jsou zachovány bez ohledu na název zastávky (potenciální garantovaný přestup)
1476
+ - garantované přestupy (`is_guaranteed_transfer`)
1477
+ - označují odjezdy, které na příjezd aktuálního spoje čekají – detekováno z pole `connections` v `gtfsPublicDepartureCache`, kde `from_trip_id` odpovídá aktuálnímu spoji a `arrivalTime < departure_datetime + max_wait_sec`
1478
+ - zobrazované minuty u garantovaného přestupu jsou nastaveny na čas příjezdu aktuálního spoje (ne na plánovaný odjezd navazujícího spoje)
1479
+ - garantované přestupy jsou vyjmuty z filtru opačného směru a filtru podskupiny linky – jsou přidány do `tripIdsToKeep` před spuštěním `findRelevantTripIdsFromLines`, takže projdou bez ohledu na zastávkovou sekvenci
1480
+ - typy "vždy zobrazit" (metro, vlak, přívoz, lanovka) filtr `findRelevantTripIdsFromLines` zcela přeskakují
1481
+ - dostupnost pro vozíčkáře (`is_wheelchair_accessible`)
1482
+ - **metro**: určeno výhradně podle `wheelchair_boarding` zastávky (hodnota `1` = přístupná)
1483
+ - **ostatní typy dopravy**: primárně z RT dat vozidla (`detailed_info.is_wheelchair_accessible`); pokud RT data nejsou k dispozici, použije se GTFS příznak `wheelchair_accessible` z `trips.txt` (`1` = přístupné vozidlo)
1484
+ - seskupování a omezení výstupu (`TransferDepartureCacheTransformation`)
1485
+ - **metro**: seskupuje se podle `route_short_name + stop_id`; na jeden záznam výstupu připadají až 2 hodnoty v poli `departure_timestamp.minutes[]`
1486
+ - **ostatní typy**: seskupuje se podle `route_short_name + direction_id`; na skupinu připadají nejvýše 2 samostatné záznamy odjezdů; `direction_id` se získává z cache poloh vozidel (klíč `route_short_name + trip_headsign`), výchozí hodnota je `0`
1487
+ - konfigurace filtrování opačného směru (backtracking)
1488
+ - `module.pid.vehicle-positions.transferboards.isOppositeDirectionFilterStopNameStrict` (boolean, výchozí `true`) – pokud `true`, zastávka je považována za "zpětnou" pouze pokud se shoduje `stop_id` i `stop_name`; pokud `false`, stačí shoda `stop_id`
1489
+ - `module.pid.vehicle-positions.transferboards.countPreviousStopsToAllow` (integer, výchozí `0`) – kolik předchozích zastávek aktuálního spoje smí kandidátní spoj sdílet ve svých nadcházejících zastávkách, než je považován za zpětný směr a odfiltrován; `0` znamená žádná shoda není povolena
1490
+
1414
1491
  #### _/v3/pid/infotexts_
1415
1492
 
1416
1493
  - načte aktivní infotexty exportované z aplikace VYMI (JIS) Infotexty
@@ -1458,4 +1535,20 @@ Worker má na starost stahování VYMI (JIS) událostí a infotextů, jejich tra
1458
1535
  - podle názvů linek a jak daleko do budoucnosti se mají odjezdy navracet
1459
1536
  - limitování počtu odjezdů v každé skupině
1460
1537
  - EP je optimalizován pro vyšší zátěž z mobilní aplikace PID lítačka - požadavek do databáze z OG pouze v případě nutnosti obnovit cache s vehicle descriptory (klimatizace, usb nabíječky), jinak je vše z Redisu
1538
+ - deduplikace odjezdů (pro seskupení "jeden za linka+směr") se provádí podle klíče `route_id + trip_headsign + platform_code`; toto se liší od původního přístupu deduplikace podle `stop_id` a správně pokrývá situace, kdy jeden ASW uzel odpovídá více GTFS `stop_id`
1539
+ - dostupnost pro vozíčkáře (`is_wheelchair_accessible`) se určuje v pořadí priority:
1540
+ 1. RT descriptor vozidla (`detailed_info.is_wheelchair_accessible` z vehicle positions)
1541
+ 2. GTFS statický příznak `wheelchair_accessible` z `trips.txt` (`1` = přístupné), pokud RT data nejsou k dispozici
1461
1542
  - je použit `CompressionByDefaultMiddleware` a odpovědi jsou tak na output gateway komprimovány i pokud klient explicitně nepovolí komprimaci vhodnou hodnotou hlavičky `Accept-Encoding` (lze však komprimaci explicitně zakázat hodnotou `identity`)
1543
+
1544
+ ### JIS v1
1545
+
1546
+ #### _/v1/jis/events/custom-format_
1547
+
1548
+ - vrátí seznam publikovaných událostí ve vlastním formátu pro externí konzumenty (fallback endpoint pro webhooky)
1549
+ - parametry
1550
+ - `displayPeriodStart` / `displayPeriodEnd` – filtrování podle překryvu zobrazovacího okna události s požadovaným rozsahem (ISO 8601)
1551
+ - `organizationNames` – filtrování podle organizace (pole řetězců)
1552
+ - `type` – filtrování podle typu události (`INCIDENT`, `DISRUPTION`, `SERVICE_CHANGE`)
1553
+ - zdrojové tabulky: `jis_events`, `jis_events_ropidgtfs_routes`
1554
+ - formát odpovědi: viz schéma `EventCustomFormat` v [openapi-output.yaml](./openapi-output.yaml)
package/docs/jis/index.md CHANGED
@@ -246,3 +246,20 @@ flowchart TB
246
246
  ```
247
247
 
248
248
  Zdroj a formát dat pro aktivní stahování jsou dále více popsány v implementační dokumentaci ([události](../implementation_documentation.md#jis-events), [infotexty](../implementation_documentation.md#jis-infotexts)), stejně tak jako [worker a tasky](../implementation_documentation.md#jisworker) a popis [uložení dat](../implementation_documentation.md#uložení-dat) včetně databázového schema a popisu retence.
249
+
250
+ ## Datový model událostí — vybraná pole
251
+
252
+ ### `cause_detail`
253
+
254
+ Volitelné textové upřesnění příčiny události (`cause_detail`). Může být `null`. Dostupné v custom-format exportu (`/v1/jis/events/custom-format`) i v GTFS-RT alert feedu jako rozšíření. Struktura:
255
+ ```json
256
+ { "cs": "Nehoda na křižovatce", "en": null }
257
+ ```
258
+
259
+ ### `cause` — anglický překlad
260
+
261
+ Pole `cause` obsahuje překlad příčiny události do češtiny i do angličtiny. Anglická hodnota je zahrnuta i ve výstupu GTFS-RT alert feedu (pole `Alert.cause` v `pid_feed.pb` i `alerts.pb`).
262
+
263
+ ### `effects` (pole příčin dopadu)
264
+
265
+ Pole `effects` může obsahovat 1–3 unikátní řetězcové hodnoty. Pouze `effects[0]` se mapuje na standardní GTFS-RT `Alert.effect`; zbývající hodnoty jsou dostupné výhradně v custom-format exportu.
@@ -92,6 +92,27 @@
92
92
  ```
93
93
 
94
94
  ## Vlaky
95
+
96
+ ### Parsování stanoviště (`stan`) u vlaků
97
+
98
+ Atribut `stan` v elementu `<zast>` u vlaků může obsahovat složený řetězec ve formátu `část1/část2` nebo `část1 část2` (např. `5S/22S`, `-/6`, `2/3`). Jako kanonický kód nástupiště se použije **první platný segment** – první token oddělený lomítkem nebo mezerou, pokud není prázdný nebo `-`.
99
+
100
+ Příklady výsledků po parsování:
101
+
102
+ | Vstup (`stan`) | Výsledný `platform_code` |
103
+ |---|---|
104
+ | `1/3` | `1` |
105
+ | `-/BUS` | `BUS` |
106
+ | `2/100V` | `2` |
107
+ | `5A/- A C` | `5A` |
108
+ | `5S/22S` | `5S` |
109
+
110
+ Parsování provádí `MpvStopParser.parsePlatformCode()`. Výsledný kód je uložen jako `cis_stop_platform_code` v tabulce `vehiclepositions_positions` a na výstupu se pro vlaky preferuje před GTFS `platform_code` (viz `PlatformCodeResolver`).
111
+
112
+ ### Zprávy s informací o nástupišti jako syntetická poloha
113
+
114
+ Pokud MPVNet zpráva vlaku obsahuje informaci o nástupišti (`$.stan`) pro budoucí zastávku a vlak ještě nemá žádnou aktivní RT polohu, vytvoří se syntetická poloha ve stavu `before_track` na základě dat z této zastávky. Díky tomu lze zobrazit kód nástupiště ještě před fyzickým příjezdem vlaku na stanoviště. Kód nástupiště se parsuje stejným způsobem jako výše (`MpvStopParser.parsePlatformCode()`).
115
+
95
116
  ```xml
96
117
  <?xml version="1.0" encoding="utf-8"?>
97
118
 
@@ -13,6 +13,7 @@
13
13
  - duplikace vlakových spojů a pozic podle block id (určení tracking podle cis stop id)
14
14
  - obohacení spojů GTFS daty (včetně oběhu a kmenové linky)
15
15
  - upsert asociovaných pozic
16
+ - **syntetická poloha z informace o nástupišti**: pokud zpráva obsahuje atribut `$.stan` pro budoucí zastávku a vlak ještě nemá aktivní RT polohu, vytvoří se syntetická pozice ve stavu `before_track` pro tuto zastávku – umožňuje zobrazit kód nástupiště před fyzickým příjezdem vlaku
16
17
  - spoje se pošlou do fronty `updateDelay`
17
18
  - updateDelay
18
19
  - opět duplikace vlakových spojů, upsert asociovaných pozic
@@ -33,6 +33,7 @@
33
33
  - pokud je pozice duplicitní (existuje pozice se stejným `origin_timestamp`), stav je `duplicate`
34
34
  - pokud vozidlo jede do garáže, je stav `invisible`
35
35
  - jinak je stav `after_track`
36
+ - **zvláštní případ**: pokud má pozice `cis_last_stop_id = null`, stav se znovu nevyhodnocuje – pozice si zachovává poslední známý stav (zmrazení stavu); to zabraňuje nežádoucímu cyklování zpět do `untracked` pouze kvůli chybějící CIS zastávce
36
37
  - Tracking (`tracking` je `2`)
37
38
  - pokud je vozidlo 200 metrů od nejblizšího bodu na trase, stav je `off_track`
38
39
  - pokud je vozidlo v zastávce, je stav `at_stop`
@@ -0,0 +1,312 @@
1
+ ## v4/pid/transferboards filtering pipeline (newcomer guide)
2
+
3
+ This section documents every filtering and transformation step executed by the `GET /v4/pid/transferboards` endpoint, in the order they actually run. The goal is to help a developer who is new to the codebase understand **what** each stage does, **why** it exists, and **where** the code lives.
4
+
5
+ ---
6
+
7
+ ### Overview
8
+
9
+ The endpoint answers the question: _"Given that I am on vehicle X arriving at stop Y, which onward connections should I show on the transfer board?"_
10
+
11
+ The answer is not simply "all departures from stop Y in the next hour" — many departures must be filtered out because they go back the way the passenger just came, or depart too soon to catch, or are irrelevant in-network transfers. The pipeline also specially handles **guaranteed transfers** (connections the operator has contractually promised to wait for).
12
+
13
+ **Primary source files:**
14
+ - `src/output-gateway/pid/controllers/v4/V4TransferBoardsController.ts` — orchestrates the full pipeline
15
+ - `src/output-gateway/pid/service/facade/TransferFacade.ts` — fetches the cache, runs line-direction filters
16
+ - `src/output-gateway/pid/helpers/TransferBoardFilter.ts` — static filter methods (time, name, deduplication)
17
+ - `src/output-gateway/pid/helpers/TransferBoardSorter.ts` — sort pipeline
18
+ - `src/output-gateway/pid/service/transformations/TransferDepartureCacheTransformation.ts` — output grouping/capping
19
+
20
+ ---
21
+
22
+ ### Stage 1 — Request validation and parameter parsing
23
+
24
+ **Where:** `V4PIDRouter.ts` (validation middleware) + `V4TransferBoardsController.ts` (top of `getTransferBoards`)
25
+
26
+ The endpoint accepts two mutually exclusive identification modes:
27
+
28
+ - **ASW mode** — `aswId` + `vehicleRegistrationNumber` + `routeType`
29
+ - **CIS mode** — `cisId` + `tripNumber` (returns HTTP 501; not yet implemented)
30
+
31
+ If neither set of params is provided, or both are, validation rejects the request early. CIS mode always returns `501 Not Implemented`.
32
+
33
+ ---
34
+
35
+ ### Stage 2 — Stop resolution (ASW → GTFS stop IDs)
36
+
37
+ **Where:** `TransferFacade.getTransferCache()` → `gtfsStopsCache:*`
38
+
39
+ A single ASW node can map to multiple GTFS `stop_id` values (e.g. platforms A and B at the same tram stop). The facade:
40
+
41
+ 1. Looks up all GTFS `stop_id` values for the given `aswId` from `gtfsStopsCache:{aswId}`.
42
+ 2. Fetches the stop names for those `stop_id` values.
43
+ 3. Groups them into **same-name clusters** — stops that share a `stop_name` (e.g. both platforms of "Náměstí Míru") are treated as one logical transfer point.
44
+
45
+ This grouping matters later: only departures from stops in the same cluster pass the same-stop-name filters.
46
+
47
+ ---
48
+
49
+ ### Stage 3 — Current vehicle lookup
50
+
51
+ **Where:** `V4TransferBoardsController.ts` + `vpPublicStopTimeCache:*`
52
+
53
+ The controller looks up the arriving vehicle's trip data using `service-{routeType}-{registrationNumber}` as the key into `vpPublicStopTimeCache`. For buses, a fallback to the trolleybus key is tried if the bus key is missing (registration numbers are shared between the two types).
54
+
55
+ This gives the controller the vehicle's **current `trip_id`** (called `currentTripId` throughout the codebase), which is central to guaranteed transfer detection and direction filtering.
56
+
57
+ If the vehicle is not found in the stop-time cache, the response is `404 Not Found`.
58
+
59
+ ---
60
+
61
+ ### Stage 4 — Arrival time detection
62
+
63
+ **Where:** `V4TransferBoardsController.ts` → `gtfsDelayComputation:{tripId}`
64
+
65
+ The controller reads the vehicle's current trip from `gtfsDelayComputation`, which contains a per-stop array with both planned and predicted (delayed) times. It finds the entry for the target stop and extracts:
66
+
67
+ - `plannedTimeFrom` — the GTFS scheduled arrival time at this stop
68
+ - `delayedTimeFrom` — the real-time predicted arrival time (may differ due to delays)
69
+
70
+ Both values are used to set the departure cache query window in the next stage.
71
+
72
+ ---
73
+
74
+ ### Stage 5 — Departure cache fetch
75
+
76
+ **Where:** `TransferFacade.getTransferCache()` → `gtfsPublicDepartureCache:*`
77
+
78
+ The facade fetches candidates from `gtfsPublicDepartureCache:{stopId}` (a Redis sorted set, scored by planned departure timestamp) for each GTFS `stop_id` in scope.
79
+
80
+ **Time window:**
81
+ ```
82
+ from = plannedTimeFrom − 61 minutes
83
+ to = plannedTimeFrom + 60 minutes + delayMinutes
84
+ ```
85
+
86
+ The 61-minute lookback exists to catch transfer lines whose scheduled departure is in the past but which may still arrive at the stop after the current vehicle due to their own delay of up to 60 minutes.
87
+
88
+ **Fetch limit:** `max(80, min(120, limit × 10))` items per stop. The wide over-fetch ensures that enough candidates survive later filtering to fill the requested `limit`.
89
+
90
+ ---
91
+
92
+ ### Stage 6 — Self-removal
93
+
94
+ **Where:** `V4TransferBoardsController.ts`
95
+
96
+ The current vehicle's own trip (`currentTripId`) is removed from the candidate list. It should never appear as a "transfer option" for itself.
97
+
98
+ ---
99
+
100
+ ### Stage 7 — Pre-filter: bus/tram/trolleybus at wrong-name stops
101
+
102
+ **Where:** `TransferFacade.getTransferCache()` (inline, before returning)
103
+
104
+ Before the expensive line-direction filter runs, a cheap pre-filter drops departures that are:
105
+ - Route type **bus, tram, or trolleybus** (metro/train/ferry/funicular pass through unconditionally)
106
+ - From a stop whose `stop_name` differs from the current stop's name
107
+
108
+ **Exception:** if the departure has a non-empty `connections[]` array (meaning it is a possible guaranteed transfer), it is kept regardless of stop name. This is because a guaranteed transfer bus might legitimately be at a different-named stop.
109
+
110
+ This pre-filter is a performance optimization — it eliminates obviously irrelevant candidates before the costlier stages.
111
+
112
+ ---
113
+
114
+ ### Stage 8 — Sort + real-time vehicle position join
115
+
116
+ **Where:** `V4TransferBoardsController.ts`
117
+
118
+ Remaining candidates are sorted by `departure_datetime` ascending, then each is joined with live vehicle positions from `vpPublicCache` (if the trip has an active vehicle). This enriches each candidate with:
119
+
120
+ - `predictedDepartureDate` / `predictedDepartureTimestamp` — the RT-adjusted departure time
121
+ - `is_wheelchair_accessible` — resolved from the RT vehicle descriptor if available (see Stage 9)
122
+
123
+ ---
124
+
125
+ ### Stage 9 — Wheelchair accessibility resolution
126
+
127
+ **Where:** `DepartureBoardMapper.determineWheelchairAccessibility()`
128
+
129
+ For each candidate departure, accessibility is determined differently by mode:
130
+
131
+ | Mode | Source |
132
+ |---|---|
133
+ | **Metro** | `wheelchair_boarding` from the GTFS stop (stop-level, static) |
134
+ | **All other** | `real_wheelchair_accessible` from the RT vehicle descriptor (boolean), or if absent: GTFS static `wheelchair_accessible` (trip-level, `GtfsTripWheelchairAccessEnum`) |
135
+
136
+ The fallback to GTFS static data is the fix introduced in v5.7.1 (item 3 above).
137
+
138
+ ---
139
+
140
+ ### Stage 10 — Guaranteed transfer detection
141
+
142
+ **Where:** `V4TransferBoardsController.ts` (`havingConnectionFromTripId`)
143
+
144
+ A departure is a **guaranteed transfer** (Czech: _zaručený přestup_) when:
145
+
146
+ 1. Its `connections[]` array contains an entry where `from_trip_id === currentTripId`, AND
147
+ 2. The current vehicle's predicted arrival time is within the wait window:
148
+ ```
149
+ vehicleArrivalMs < departurePlannedMs + max_wait_sec × 1000
150
+ ```
151
+
152
+ Guaranteed transfers receive special treatment in all subsequent stages — they can bypass nearly every filter and are always shown if time constraints allow.
153
+
154
+ The result is two sets: `guaranteedTripIds` and `guaranteedConnections`.
155
+
156
+ ---
157
+
158
+ ### Stage 11 — Minimal transfer time filter
159
+
160
+ **Where:** `TransferBoardFilter.minimalTransferTime()`
161
+
162
+ Departures whose scheduled time is too close to the vehicle's arrival are dropped — there is not enough time for passengers to board. Thresholds differ by mode:
163
+
164
+ | Mode | Minimum gap |
165
+ |---|---|
166
+ | Bus, tram, trolleybus | 60 seconds |
167
+ | Metro, train, ferry, funicular | 120 seconds |
168
+
169
+ **Guaranteed transfers are exempt** from this filter — the operator has guaranteed the connection, so time is irrelevant.
170
+
171
+ ---
172
+
173
+ ### Stage 12 — Same-stop-name filter (Stage 2)
174
+
175
+ **Where:** `TransferBoardFilter.sameStopNameTransfer()`
176
+
177
+ A second pass of the stop-name check, applied after guaranteed transfers are identified. Rules:
178
+
179
+ - Bus/tram/trolleybus at a stop with a different name than the arrival stop → **dropped**
180
+ - Metro/train/ferry/funicular → **kept** (they serve different physical locations by design)
181
+ - Any trip in `guaranteedTripIds` → **kept** (guaranteed transfer exemption)
182
+ - Any trip in `keepAlwaysTripIds` (see Stage 14) → **kept**
183
+
184
+ This stage is separate from the Stage 7 pre-filter because at Stage 7 we did not yet know which trips were guaranteed.
185
+
186
+ ---
187
+
188
+ ### Stage 13 — Categorise trips for line-direction filter
189
+
190
+ **Where:** `V4TransferBoardsController.ts`
191
+
192
+ Before running the expensive direction filter, the controller categorises remaining candidates:
193
+
194
+ - **Always keep:** guaranteed transfers + "keep always" types (metro, train, ferry, funicular)
195
+ - **Needs filtering:** everything else (bus, tram, trolleybus that are not guaranteed)
196
+
197
+ Only the "needs filtering" set is passed to `findRelevantTripIdsFromLines`. This avoids running direction analysis on trips that will be kept unconditionally.
198
+
199
+ ---
200
+
201
+ ### Stage 14 — Guaranteed transfer time adjustment
202
+
203
+ **Where:** `V4TransferBoardsController.ts`
204
+
205
+ For guaranteed transfers, the displayed departure time is **replaced** with the arriving vehicle's own predicted arrival time. This is the time the bus/tram will actually wait until, so showing the vehicle's arrival time as the "departure" is more useful to passengers than the originally scheduled departure time.
206
+
207
+ ---
208
+
209
+ ### Stage 15 — Sort (pre-output)
210
+
211
+ **Where:** `TransferBoardSorter.sort()`
212
+
213
+ A four-criterion stable sort applied before the direction filter:
214
+
215
+ 1. **Metro first** — metro departures before all others
216
+ 2. **Metro name ascending** — within metro, sort by `route_short_name` (A before B before C)
217
+ 3. **Departure time ascending** — earlier departures first
218
+ 4. **`direction_id` ascending** — tiebreaker for trips with identical departure times
219
+
220
+ ---
221
+
222
+ ### Stage 16 — Line-direction filter (`findRelevantTripIdsFromLines`)
223
+
224
+ **Where:** `TransferFacade.findRelevantTripIdsFromLines()`
225
+
226
+ This is the most complex stage. It determines whether each candidate trip is going somewhere _new_ for the passenger, or whether it is effectively doubling back along the route the passenger just arrived on.
227
+
228
+ For each candidate trip, the facade loads its stop sequence from `gtfsDelayComputation` or `vpPublicStopTimeCache`. It then applies two sequential sub-filters:
229
+
230
+ #### Sub-filter A: Forward-subset check (`filterOutForwardSubgroupOfLine`)
231
+
232
+ **Question:** Does this candidate trip's future stops form a strict subset of the current vehicle's future stops?
233
+
234
+ If every stop the candidate will visit is also a future stop on the current vehicle's route, then there is no point transferring — the passenger will get there anyway without changing. Such trips are **dropped**.
235
+
236
+ **Example:** Current vehicle is bus 207 going A→B→C→D. Candidate bus 150 goes B→C. Since B and C are both future stops of 207, transferring to 150 is redundant → dropped.
237
+
238
+ #### Sub-filter B: Backtracking conflict check (`filterOutLinesWithBacktrackingConflict`)
239
+
240
+ **Question:** Do this candidate trip's next N stops overlap with the current vehicle's previous N stops in a way that suggests it is heading back the same way?
241
+
242
+ Configured by `countPreviousStopsToAllow` (default `0`). The value defines how many of the current vehicle's previous stops the candidate trip is allowed to share in its upcoming stops. If the candidate shares more than that number, it is **dropped** (it's going backwards). `0` means no overlap is permitted at all.
243
+
244
+ The strictness of the stop matching is controlled by `isOppositeDirectionFilterStopNameStrict` (default `true`): when true, both `stop_id` AND `stop_name` must match; when false, only `stop_id`.
245
+
246
+ ---
247
+
248
+ ### Stage 17 — Combine approved trip IDs
249
+
250
+ **Where:** `TransferBoardFilter.keepAlwaysLinesAndTripIds()`
251
+
252
+ The final set of approved trip IDs is the union of:
253
+ - `guaranteedTripIds` (from Stage 10)
254
+ - `keepAlwaysTripIds` (metro/train/ferry/funicular, from Stage 13)
255
+ - Trips that passed the direction filter (from Stage 16)
256
+
257
+ All other trips are discarded from the candidate list here.
258
+
259
+ ---
260
+
261
+ ### Stage 18 — Output grouping and per-route cap
262
+
263
+ **Where:** `TransferDepartureCacheTransformation.transform()`
264
+
265
+ Before the final limit is applied, departures are grouped by route and capped to prevent one line from dominating the board:
266
+
267
+ | Mode | Grouping key | Cap |
268
+ |---|---|---|
269
+ | **Metro** | `route_short_name + stop_id` | 2 departure times merged into one `departure_timestamp.minutes[]` entry |
270
+ | **Non-metro** | `route_short_name + direction_id` | 2 separate departure entries per group |
271
+
272
+ For non-metro, `direction_id` is taken from the live vehicle positions cache (keyed by `route_short_name + trip_headsign`), defaulting to `0` when not available.
273
+
274
+ ---
275
+
276
+ ### Stage 19 — Final filter: limit, time window, deduplication
277
+
278
+ **Where:** `TransferBoardFilter.filterDepartures()`
279
+
280
+ The last stage applies three rules:
281
+
282
+ 1. **Time window cut:** departures after `arrivalTime + 1 hour` are dropped.
283
+ 2. **Trip deduplication:** if two entries share the same `trip_id`, only the first (earliest) is kept.
284
+ 3. **Limit:** the result is truncated to the requested `limit` (query parameter, default typically 10).
285
+
286
+ **Guaranteed transfers are exempt from the time window and limit** — they always appear regardless of how many other results there are, as long as they are still within the `max_wait_sec` window.
287
+
288
+ ---
289
+
290
+ ### Quick reference: which filter each vehicle type is subject to
291
+
292
+ | Filter | Bus/Tram/Trolleybus | Metro/Train/Ferry/Funicular | Guaranteed transfer |
293
+ |---|---|---|---|
294
+ | Stage 7 pre-filter (wrong stop name) | Yes | No | No (exempt) |
295
+ | Stage 11 min transfer time | Yes (60 s) | Yes (120 s) | **No** |
296
+ | Stage 12 same-stop-name | Yes | No | **No** |
297
+ | Stage 16 direction filter | Yes | **No** | **No** |
298
+ | Stage 17 combine | All types pass via their category | — | — |
299
+ | Stage 18 per-route cap (2 entries) | Yes | Yes (metro grouped differently) | Yes |
300
+ | Stage 19 limit | Yes | Yes | **No** |
301
+
302
+ ---
303
+
304
+ ### Key Redis keys used
305
+
306
+ | Key pattern | Purpose |
307
+ |---|---|
308
+ | `gtfsStopsCache:{aswId}` | ASW node → GTFS stop_id mapping |
309
+ | `gtfsPublicDepartureCache:{stopId}` | Sorted set of precomputed departures (score = departure Unix timestamp) |
310
+ | `gtfsDelayComputation:{tripId}` | Per-trip RT stop times, delay, shapes |
311
+ | `vpPublicStopTimeCache:{vehicleKey}` | Per-vehicle stop time lookup (used to identify current trip) |
312
+ | `vpPublicCache:*` | Geo-indexed real-time vehicle positions |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@golemio/pid",
3
- "version": "5.7.2-dev.2368357435",
3
+ "version": "5.7.2-dev.2373103436",
4
4
  "description": "Golemio PID Module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",