Commit e67baf90 authored by Volker Krause's avatar Volker Krause

Extract English SNCF tickets

parent 06d1c155
......@@ -19,11 +19,11 @@
function parseText(text) {
var reservations = new Array();
var bookingRef = text.match(/DOSSIER VOYAGE : +([A-Z0-9]{6})/);
var bookingRef = text.match(/(?:DOSSIER VOYAGE|BOOKING FILE REFERENCE) : +([A-Z0-9]{6})/);
var pos = 0;
while (true) {
var header = text.substr(pos).match(/ +Départ \/ Arrivée.*\n/);
var header = text.substr(pos).match(/ +(?:Départ \/ Arrivée|Departure \/ Arrival).*\n/);
if (!header)
break;
var index = header.index + header[0].length;
......@@ -31,14 +31,14 @@ function parseText(text) {
var res = JsonLd.newTrainReservation();
res.reservationNumber = bookingRef[1];
var depLine = text.substr(pos + index).match(/\n {2,3}([\w -]+?) +(\d{2}\/\d{2}) à (\d{2}h\d{2})/);
var depLine = text.substr(pos + index).match(/\n {2,3}([\w -]+?) +(\d{2}\/\d{2}) (?:à|at) (\d{2}h\d{2})/);
if (!depLine)
break;
index += depLine.index + depLine[0].length;
res.reservationFor.departureStation.name = depLine[1];
res.reservationFor.departureTime = JsonLd.toDateTime(depLine[2] + " " + depLine[3], "dd/MM hh'h'mm", "fr");
var arrLine = text.substr(pos + index).match(/\n {2,3}([\w -]+?) +(\d{2}\/\d{2}) à (\d{2}h\d{2})/);
var arrLine = text.substr(pos + index).match(/\n {2,3}([\w -]+?) +(\d{2}\/\d{2}) (?:à|at) (\d{2}h\d{2})/);
if (!arrLine)
break;
index += arrLine.index + arrLine[0].length;
......@@ -49,13 +49,13 @@ function parseText(text) {
// since the stations are vertically centered, the stuff we are looking for might be at different
// positions relative to them
var legText = text.substring(pos + header.index + header[0].length, pos + index);
var trainNumber = legText.match(/TRAIN ?(\d{3,4})/);
var trainNumber = legText.match(/TRAIN (?:N°|NUMBER) ?(\d{3,5})/);
if (trainNumber)
res.reservationFor.trainNumber = trainNumber[1];
var seatRes = legText.match(/(VOITURE|COACH) (\d+) - PLACE (\d+)/);
var seatRes = legText.match(/(?:VOITURE|COACH) (\d+) - PLACE (\d+)/);
if (seatRes) {
res.reservedTicket.ticketedSeat.seatSection = seatRes[2];
res.reservedTicket.ticketedSeat.seatNumber = seatRes[3];
res.reservedTicket.ticketedSeat.seatSection = seatRes[1];
res.reservedTicket.ticketedSeat.seatNumber = seatRes[2];
}
reservations.push(res);
......
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