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

Add CCC Congress ticket extractor

Interesting test case for multi-ticket event tickets.
parent 28a8f5b1
#!/bin/bash
find "$@" -name '*.h' -o -name '*.cpp' -o -name '*.qml' -o -name '*.java'| grep -v /3rdparty/ | while read FILE; do
find "$@" -name '*.h' -o -name '*.cpp' -o -name '*.qml' -o -name '*.java' -o -name "*.js" | grep -v /3rdparty/ | while read FILE; do
if grep -qiE "Licensed under CC0." "$FILE" ; then continue; fi
if grep -qiE "Copyright \(C\) [0-9, -]{4,} " "$FILE" ; then continue; fi
thisfile=`basename $FILE`
......
/*
Copyright (C) 2019 Volker Krause <vkrause@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
function parsePdf(pdf)
{
if (!Context.data) {
return null;
}
var ptTicket = Barcode.decodeUic9183(Context.barcode);
var res = JsonLd.newEventReservation();
res.reservationFor.name = ptTicket.person.name;
res.reservationFor.location.name = "Congress Center Leipzig";
res.reservationFor.location.address.addressLocality = "Leipzig";
res.reservationFor.location.address.addressCountry = "DE";
res.reservationFor.location.geo.latitude = 51.39737;
res.reservationFor.location.geo.longitude = 12.39528;
var start = ptTicket.rct2Ticket.firstDayOfValidity;
start.setHours(11);
res.reservationFor.startDate = start;
var end = ptTicket.rct2Ticket.firstDayOfValidity;
end.setDate(30);
end.setHours(18);
res.reservationFor.endDate = end;
// search for the QR code with the actual event code
var images = pdf.pages[Context.pdfPageNumber].images;
for (var i = 0; i < images.length; ++i) {
var code = Barcode.decodeQR(images[i]);
if (code) {
res.reservedTicket.ticketToken = "qrcode:" + code;
break;
}
}
// generate the second ticket for public transport
var pt = JsonLd.clone(res);
pt.reservedTicket.ticketToken = Context.data[0].reservedTicket.ticketToken;
pt.reservedTicket.name = "Public Transport";
var reservations = new Array();
reservations.push(res);
reservations.push(pt);
return reservations;
}
{
"filter": [
{
"match": "uic:9997",
"property": "reservationFor.provider.identifier",
"type": "JsonLd"
}
],
"function": "parsePdf",
"script": "chaos-communication-congress.js",
"type": "Pdf"
}
......@@ -21,6 +21,8 @@
<file>brusselsairlines.json</file>
<file>brusselsairlines.js</file>
<file>brusselsairlines-receipt.js</file>
<file>chaos-communication-congress.json</file>
<file>chaos-communication-congress.js</file>
<file>czechrailways.json</file>
<file>czechrailways.js</file>
<file>deutschebahn.json</file>
......
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