Skip to content

Commit

Permalink
load ATOC code from Z trains (#75)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Tsang <michael.tsang@jnction.co.uk>
  • Loading branch information
miklcct and Michael Tsang committed Nov 9, 2023
1 parent 2f2b072 commit 20775f2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
14 changes: 13 additions & 1 deletion config/timetable/file/ZTR.ts
@@ -1,5 +1,5 @@

import {RecordWithManualIdentifier} from "../../../src/feed/record/FixedWidthRecord";
import {FixedWidthRecord, RecordWithManualIdentifier} from "../../../src/feed/record/FixedWidthRecord";
import {TextField, VariableLengthText} from "../../../src/feed/field/TextField";
import {MultiRecordFile} from "../../../src/feed/file/MultiRecordFile";
import {BooleanField} from "../../../src/feed/field/BooleanField";
Expand Down Expand Up @@ -45,6 +45,17 @@ const schedule = new RecordWithManualIdentifier(
["runs_from"]
);

export const extraDetails = new FixedWidthRecord(
"z_schedule_extra",
[], {
"schedule": new ForeignKeyField(schedule),
"atoc_code": new TextField(11, 2, true),
},
["schedule"]
);



const stopRecordTypes = {
"LO": {
"z_schedule": new ForeignKeyField(schedule),
Expand Down Expand Up @@ -110,6 +121,7 @@ const stop = new MultiFormatRecord(

const ZTR = new MultiRecordFile({
"BS": schedule,
"BX": extraDetails,
"LO": stop,
"LI": stop,
"LT": stop
Expand Down
3 changes: 2 additions & 1 deletion src/gtfs/repository/CIFRepository.ts
Expand Up @@ -107,8 +107,9 @@ export class CIFRepository {
monday, tuesday, wednesday, thursday, friday, saturday, sunday,
stp_indicator, location AS crs_code, train_category,
public_arrival_time, public_departure_time, scheduled_arrival_time, scheduled_departure_time,
platform, NULL AS atoc_code, z_stop_time.id AS stop_id, activity, NULL AS reservations, "S" AS train_class
platform, atoc_code, z_stop_time.id AS stop_id, activity, NULL AS reservations, "S" AS train_class
FROM z_schedule
LEFT JOIN z_schedule_extra ON z_schedule.id = z_schedule_extra.schedule
JOIN z_stop_time ON z_schedule.id = z_stop_time.z_schedule
WHERE runs_from < CURDATE() + INTERVAL 3 MONTH
AND runs_to >= CURDATE()
Expand Down

0 comments on commit 20775f2

Please sign in to comment.