Commit c3660d39 authored by Volker Krause's avatar Volker Krause
Browse files

Extract Amtrak station identifiers

parent 4cf1aea4
Pipeline #139131 failed with stages
in 3 minutes and 16 seconds
......@@ -29,6 +29,18 @@ function parseTicket(pdf, node, triggerNode) {
legs.push(leg);
}
// station codes
const codes = text.match(/\n([A-Z]{3}) +([A-Z]{3}) +[^ ].*\n/);
if (legs.length == 1) {
legs[0].reservationFor.departureStation.identifier = 'amtrak:' + codes[1];
legs[0].reservationFor.arrivalStation.identifier = 'amtrak:' + codes[2];
} else if (legs.length == 2 && legs[0].reservationFor.departureStation.name == legs[1].reservationFor.arrivalStation.name && legs[0].reservationFor.arrivalStation.name == legs[1].reservationFor.departureStation.name) {
legs[0].reservationFor.departureStation.identifier = 'amtrak:' + codes[1];
legs[0].reservationFor.arrivalStation.identifier = 'amtrak:' + codes[2];
legs[1].reservationFor.departureStation.identifier = 'amtrak:' + codes[2];
legs[1].reservationFor.arrivalStation.identifier = 'amtrak:' + codes[1];
}
var reservations = new Array();
const pasHdr = text.match(/PASSENGERS \((\d+)\).*\n/);
const pasCount = pasHdr[1];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment