Commit 8685e376 authored by Volker Krause's avatar Volker Krause
Browse files

Extract class code from ERA FCB data

parent fa2e2b40
Pipeline #254133 passed with stage
in 16 minutes and 25 seconds
......@@ -331,10 +331,34 @@ QString Uic9183Parser::outboundArrivalStationId() const
return {};
}
static QString fcbClassCodeToString(Fcb::TravelClassType classCode)
{
switch (classCode) {
case Fcb::notApplicable: return {};
case Fcb::first: return QString::number(1);
case Fcb::second: return QString::number(2);
default:
qCWarning(Log) << "Unhandled FCB class code" << classCode;
}
return {};
}
QString Uic9183Parser::seatingType() const
{
const auto b = findBlock<Vendor0080BLBlock>();;
if (b.isValid()) {
if (const auto fcb = findBlock<Fcb::UicRailTicketData>(); fcb.isValid() && fcb.transportDocument.size() == 1) {
const auto doc = fcb.transportDocument.at(0);
if (doc.ticket.userType() == qMetaTypeId<Fcb::ReservationData>()) {
return fcbClassCodeToString(doc.ticket.value<Fcb::ReservationData>().classCode);
}
if (doc.ticket.userType() == qMetaTypeId<Fcb::OpenTicketData>()) {
return fcbClassCodeToString(doc.ticket.value<Fcb::OpenTicketData>().classCode);
}
if (doc.ticket.userType() == qMetaTypeId<Fcb::PassData>()) {
return fcbClassCodeToString(doc.ticket.value<Fcb::PassData>().classCode);
}
}
if (const auto b = findBlock<Vendor0080BLBlock>(); b.isValid()) {
// S014 contains the class, possibly with a leading 'S' for some reason
const auto sblock = b.findSubBlock("014");
if (!sblock.isNull()) {
......@@ -343,8 +367,7 @@ QString Uic9183Parser::seatingType() const
}
}
const auto rct2 = rct2Ticket();
if (rct2.isValid()) {
if (const auto rct2 = rct2Ticket(); rct2.isValid()) {
return rct2.outboundClass();
}
return {};
......
Supports Markdown
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