Commit 929e666e authored by Volker Krause's avatar Volker Krause
Browse files

Specify the platform mode when known

This makes platform selection also work for trams and subways (if we get
proper platform names for those).
parent 2fc6253a
......@@ -155,9 +155,11 @@ Item {
};
if (!isDeparture) {
args.arrivalPlatformName = stop.hasExpectedPlatform ? stop.expectedPlatform : stop.scheduledPlatform;
args.arrivalPlatformMode = PublicTransport.lineModeToPlatformMode(stop.route.line.mode)
}
if (!isArrival) {
args.departurePlatformName = stop.hasExpectedPlatform ? stop.expectedPlatform : stop.scheduledPlatform;
args.departurePlatformMode = PublicTransport.lineModeToPlatformMode(stop.route.line.mode)
}
applicationWindow().pageStack.push(indoorMapPage, args);
}
......
......@@ -517,4 +517,37 @@ QStringList PublicTransport::suitableBackendsForReservation(KPublicTransport::Ma
return backendIds;
}
KOSMIndoorMap::Platform::Mode PublicTransport::lineModeToPlatformMode(KPublicTransport::Line::Mode lineMode)
{
using namespace KPublicTransport;
switch (lineMode) {
case Line::Unknown:
case Line::Air:
case Line::Boat:
case Line::Ferry:
case Line::Shuttle:
case Line::Taxi:
case Line::RideShare:
return KOSMIndoorMap::Platform::Unknown;
case Line::Bus:
case Line::BusRapidTransit:
case Line::Coach:
return KOSMIndoorMap::Platform::Bus;
case Line::Funicular:
case Line::LocalTrain:
case Line::LongDistanceTrain:
case Line::RailShuttle:
case Line::RapidTransit:
case Line::Train:
return KOSMIndoorMap::Platform::Rail;
case Line::Metro:
return KOSMIndoorMap::Platform::Subway;
case Line::Tramway:
return KOSMIndoorMap::Platform::Tram;
}
return KOSMIndoorMap::Platform::Unknown;
}
#include "moc_publictransport.cpp"
......@@ -13,6 +13,8 @@
#include <KItinerary/MergeUtil>
#include <KItinerary/Place>
#include <KOSMIndoorMap/Platform>
#include <KPublicTransport/Location>
#include <KPublicTransport/Line>
#include <KPublicTransport/Manager>
......@@ -106,10 +108,12 @@ public:
/** Last public transport section of the given section. */
static KPublicTransport::JourneySection lastTransportSection(const KPublicTransport::Journey &journey);
/** Selects suitable backends based on UIC operator codes from the reservation. */
template <typename Request>
static void selectBackends(Request &request, KPublicTransport::Manager *mgr, const QVariant &res);
/** Convert KPublicTransport mode enum to one for KOSMIndoorMap */
Q_INVOKABLE static KOSMIndoorMap::Platform::Mode lineModeToPlatformMode(KPublicTransport::Line::Mode lineMode);
private:
// for use by the template code
static QString idenfitierFromLocation(const KPublicTransport::Location &loc);
......
......@@ -592,6 +592,7 @@ QJSValue TimelineDelegateController::arrivalMapArguments() const
if (transfer.state() == Transfer::Selected) {
const auto dep = PublicTransport::firstTransportSection(transfer.journey());
args.setProperty(QStringLiteral("departurePlatformName"), dep.hasExpectedDeparturePlatform() ? dep.expectedDeparturePlatform() : dep.scheduledDeparturePlatform());
args.setProperty(QStringLiteral("departurePlatformMode"), PublicTransport::lineModeToPlatformMode(dep.route().line().mode()));
args.setProperty(QStringLiteral("endTime"), engine->toScriptValue(dep.hasExpectedDepartureTime() ? dep.expectedDepartureTime() : dep.scheduledDepartureTime()));
return args;
}
......@@ -664,6 +665,7 @@ QJSValue TimelineDelegateController::departureMapArguments() const
if (transfer.state() == Transfer::Selected) {
const auto arr = PublicTransport::lastTransportSection(transfer.journey());
args.setProperty(QStringLiteral("arrivalPlatformName"), arr.hasExpectedArrivalPlatform() ? arr.expectedArrivalPlatform() : arr.scheduledArrivalPlatform());
args.setProperty(QStringLiteral("arrivalPlatformMode"), PublicTransport::lineModeToPlatformMode(arr.route().line().mode()));
args.setProperty(QStringLiteral("beginTime"), engine->toScriptValue(arr.hasExpectedArrivalTime() ? arr.expectedArrivalTime() : arr.scheduledArrivalTime()));
return args;
}
......
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