Commit 50e64104 authored by Volker Krause's avatar Volker Krause
Browse files

Partially migrate the Trenitalia extractor to use the new ERA SSB code

So far this affects filtering and station codes, for everything after that
the ERA SSB documentation and what we see in Trenitalia barcodes seems to
diverge.

Either way, this already gives us support for international destinations,
something the old code didn't handle.
parent 2539e046
......@@ -53,19 +53,13 @@ function parsePdf(pdf) {
}
// see https://community.kde.org/KDE_PIM/KItinerary/Trenitalia_Barcode
var bitArray = Barcode.toBitArray(barcode);
var depUic = bitArray.readNumberMSB(14*8 + 4, 24);
var arrUic = bitArray.readNumberMSB(18*8 + 3, 24);
if (depUic != arrUic) {
if (bitArray.readNumberMSB(14*8, 4) == 0) {
personalRes.reservationFor.departureStation.identifier = "uic:" + depUic;
}
if (bitArray.readNumberMSB(17*8 + 7, 4) == 0) {
personalRes.reservationFor.arrivalStation.identifier = "uic:" + arrUic;
}
var ssb = Barcode.decodeEraSsbTicket(barcode)
personalRes.reservationFor.departureStation.identifier = "uic:" + (ssb.departureStationNum % 10000000)
if (ssb.departureStationNum != ssb.arrivalStationNum) {
personalRes.reservationFor.arrivalStation.identifier = "uic:" + (ssb.arrivalStationNum % 10000000)
}
var bitArray = Barcode.toBitArray(barcode);
var seatNum = bitArray.readNumberMSB(31*8 + 2, 7);
if (seatNum > 0) {
personalRes.reservedTicket.ticketedSeat.seatNumber = "" + seatNum;
......
......@@ -2,7 +2,7 @@
{
"mimeType": "application/pdf",
"filter": [
{ "mimeType": "application/octet-stream", "match": "^ \\x{14}", "scope": "Descendants" }
{ "mimeType": "internal/era-ssb", "field": "issuerCode", "match": "83", "scope": "Descendants" }
],
"script": "trenitalia.js",
"function": "parsePdf"
......
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