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

Parse OTP2 individual transport modes

parent 7a3cb1ea
Pipeline #85917 passed with stage
in 1 minute and 22 seconds
{"plan":{"itineraries":[{"legs":[{"startTime":1633535130000,"endTime":1633535886000,"departureDelay":0,"arrivalDelay":0,"realTime":false,"distance":2889.4559999999997,"mode":"BICYCLE","transitLeg":false,"rentedBike":false,"from":{"name":"Origin","lat":48.58000183105469,"lon":8.859999656677246,"stop":null,"bikeRentalStation":null,"bikePark":null,"carPark":null,"vehicleParkingWithEntrance":null},"to":{"name":"Fahrradabstellplatz","lat":48.5936244,"lon":8.8633925,"stop":null,"bikeRentalStation":null,"bikePark":{"id":"QmlrZVBhcms6T1NNOk9TTU5vZGUvNzcyNTMyNDUxNg","bikeParkId":"OSM:OSMNode/7725324516","spacesAvailable":null,"realtime":false},"carPark":{"id":"Q2FyUGFyazpPU006T1NNTm9kZS83NzI1MzI0NTE2","carParkId":"OSM:OSMNode/7725324516","maxCapacity":null,"spacesAvailable":null,"realtime":false},"vehicleParkingWithEntrance":{"vehicleParking":{"id":"VmVoaWNsZVBhcmtpbmc6T1NNOk9TTU5vZGUvNzcyNTMyNDUxNg","vehicleParkingId":"OSM:OSMNode/7725324516","realtime":false,"detailsUrl":null,"imageUrl":null,"tags":["osm:amenity=bicycle_parking"],"note":null,"feeHours":null,"openingHours":null,"state":"OPERATIONAL","bicyclePlaces":true,"anyCarPlaces":false,"carPlaces":false,"wheelchairAccessibleCarPlaces":false,"capacity":{"bicycleSpaces":6,"carSpaces":null,"wheelchairAccessibleCarSpaces":null},"availability":null},"closesSoon":false,"realtime":false}},"trip":null},{"startTime":1633535886000,"endTime":1633536060000,"departureDelay":0,"arrivalDelay":0,"realTime":false,"distance":115.036,"mode":"WALK","transitLeg":false,"rentedBike":false,"from":{"name":"Fahrradabstellplatz","lat":48.5936244,"lon":8.8633925,"stop":null,"bikeRentalStation":null,"bikePark":{"id":"QmlrZVBhcms6T1NNOk9TTU5vZGUvNzcyNTMyNDUxNg","bikeParkId":"OSM:OSMNode/7725324516","spacesAvailable":null,"realtime":false},"carPark":{"id":"Q2FyUGFyazpPU006T1NNTm9kZS83NzI1MzI0NTE2","carParkId":"OSM:OSMNode/7725324516","maxCapacity":null,"spacesAvailable":null,"realtime":false},"vehicleParkingWithEntrance":{"vehicleParking":{"id":"VmVoaWNsZVBhcmtpbmc6T1NNOk9TTU5vZGUvNzcyNTMyNDUxNg","vehicleParkingId":"OSM:OSMNode/7725324516","realtime":false,"detailsUrl":null,"imageUrl":null,"tags":["osm:amenity=bicycle_parking"],"note":null,"feeHours":null,"openingHours":null,"state":"OPERATIONAL","bicyclePlaces":true,"anyCarPlaces":false,"carPlaces":false,"wheelchairAccessibleCarPlaces":false,"capacity":{"bicycleSpaces":6,"carSpaces":null,"wheelchairAccessibleCarSpaces":null},"availability":null},"closesSoon":false,"realtime":false}},"to":{"name":"Herrenberg","lat":48.593994,"lon":8.862829,"stop":{"id":"hbg:de:08115:4512:1:2","platformCode":null},"bikeRentalStation":null,"bikePark":null,"carPark":null,"vehicleParkingWithEntrance":null},"trip":null},{"startTime":1633536060000,"endTime":1633538400000,"departureDelay":0,"arrivalDelay":0,"realTime":false,"distance":35950.59826542039,"mode":"RAIL","transitLeg":true,"rentedBike":null,"from":{"name":"Herrenberg","lat":48.593994,"lon":8.862829,"stop":{"id":"hbg:de:08115:4512:1:2","platformCode":null},"bikeRentalStation":null,"bikePark":null,"carPark":null,"vehicleParkingWithEntrance":null},"to":{"name":"Stuttgart Hauptbahnhof (tief)","lat":48.783367,"lon":9.180338,"stop":{"id":"hbg:de:08111:6118:1:102","platformCode":null},"bikeRentalStation":null,"bikePark":null,"carPark":null,"vehicleParkingWithEntrance":null},"trip":{"route":{"type":2,"desc":null,"shortName":"S1","longName":"Kirchheim (T) - Plochingen - Stuttgart - Herrenberg","color":"83B23B","textColor":"FFFFFF","alerts":[]},"tripHeadsign":"Plochingen","tripShortName":null}},{"startTime":1633538400000,"endTime":1633538621000,"departureDelay":0,"arrivalDelay":0,"realTime":false,"distance":102.656,"mode":"WALK","transitLeg":false,"rentedBike":false,"from":{"name":"Stuttgart Hauptbahnhof (tief)","lat":48.783367,"lon":9.180338,"stop":{"id":"hbg:de:08111:6118:1:102","platformCode":null},"bikeRentalStation":null,"bikePark":null,"carPark":null,"vehicleParkingWithEntrance":null},"to":{"name":"Destination","lat":48.7835693359375,"lon":9.1814603805542,"stop":null,"bikeRentalStation":null,"bikePark":null,"
carPark":null,"vehicleParkingWithEntrance":null},"trip":null}]}],"prevDateTime":1633530696000,"nextDateTime":1633536000000,"searchWindowUsed":4200}}
[
{
"sections": [
{
"disruptionEffect": "NormalService",
"distance": 2889,
"from": {
"latitude": 48.58000183105469,
"longitude": 8.859999656677246,
"name": "Origin"
},
"individualTransport": {
"mode": "Bike",
"qualifier": "None"
},
"mode": "IndividualTransport",
"scheduledArrivalTime": "2021-10-06T15:58:06Z",
"scheduledDepartureTime": "2021-10-06T15:45:30Z",
"to": {
"latitude": 48.593624114990234,
"longitude": 8.86339282989502,
"name": "Fahrradabstellplatz"
}
},
{
"disruptionEffect": "NormalService",
"distance": 115,
"from": {
"latitude": 48.593624114990234,
"longitude": 8.86339282989502,
"name": "Fahrradabstellplatz"
},
"mode": "Walking",
"scheduledArrivalTime": "2021-10-06T16:01:00Z",
"scheduledDepartureTime": "2021-10-06T15:58:06Z",
"to": {
"identifier": {
"gtfs": "hbg:de:08115:4512:1:2"
},
"latitude": 48.593994140625,
"longitude": 8.862829208374023,
"name": "Herrenberg",
"type": "Stop"
}
},
{
"disruptionEffect": "NormalService",
"distance": 35950,
"from": {
"identifier": {
"gtfs": "hbg:de:08115:4512:1:2"
},
"latitude": 48.593994140625,
"longitude": 8.862829208374023,
"name": "Herrenberg",
"type": "Stop"
},
"mode": "PublicTransport",
"route": {
"direction": "Plochingen",
"line": {
"color": "#83b23b",
"mode": "Train",
"name": "S1",
"textColor": "#ffffff"
}
},
"scheduledArrivalTime": "2021-10-06T16:40:00Z",
"scheduledDepartureTime": "2021-10-06T16:01:00Z",
"to": {
"identifier": {
"gtfs": "hbg:de:08111:6118:1:102"
},
"latitude": 48.78336715698242,
"longitude": 9.180337905883789,
"name": "Stuttgart Hauptbahnhof (tief)",
"type": "Stop"
}
},
{
"disruptionEffect": "NormalService",
"distance": 102,
"from": {
"identifier": {
"gtfs": "hbg:de:08111:6118:1:102"
},
"latitude": 48.78336715698242,
"longitude": 9.180337905883789,
"name": "Stuttgart Hauptbahnhof (tief)",
"type": "Stop"
},
"mode": "Walking",
"scheduledArrivalTime": "2021-10-06T16:43:41Z",
"scheduledDepartureTime": "2021-10-06T16:40:00Z",
"to": {
"latitude": 48.7835693359375,
"longitude": 9.1814603805542,
"name": "Destination"
}
}
]
}
]
......@@ -104,6 +104,7 @@
"distance": 895.204,
"mode": "BICYCLE",
"transitLeg": false,
"rentedBike": true,
"from": {
"name": "path",
"lat": 48.4004982,
......
......@@ -190,6 +190,10 @@ private Q_SLOTS:
<< s(SOURCE_DIR "/data/otp/de-stadtnavi-carpool-journey.in.json")
<< s(SOURCE_DIR "/data/otp/de-stadtnavi-carpool-journey.out.json")
<< s(SOURCE_DIR "/../src/lib/networks/de_bw_stadtnavi.json");
QTest::newRow("de-stadtnavi-bike-parking-journey")
<< s(SOURCE_DIR "/data/otp/de-stadtnavi-bike-parking-journey.in.json")
<< s(SOURCE_DIR "/data/otp/de-stadtnavi-bike-parking-journey.out.json")
<< s(SOURCE_DIR "/../src/lib/networks/de_bw_stadtnavi.json");
}
void testParseJourney()
......
......@@ -425,8 +425,12 @@ JourneySection OpenTripPlannerParser::parseJourneySection(const QJsonObject &obj
section.setMode(JourneySection::PublicTransport);
section.setRoute(detectAndParseRoute(obj));
} else {
if (obj.value(QLatin1String("mode")).toString() == QLatin1String("BICYCLE")) {
section.setMode(JourneySection::RentedVehicle);
const auto mode = obj.value(QLatin1String("mode")).toString();
const auto isRented = obj.value(QLatin1String("rentedBike")).toBool();
if (mode.compare(QLatin1String("WALK"), Qt::CaseInsensitive) == 0 || mode.compare(QLatin1String("FOOT"), Qt::CaseInsensitive) == 0) {
section.setMode(JourneySection::Walking);
} else if (mode == QLatin1String("BICYCLE")) {
RentalVehicle v;
if (from.rentalVehicleStation().network().isValid()) {
v.setNetwork(from.rentalVehicleStation().network());
......@@ -436,9 +440,18 @@ JourneySection OpenTripPlannerParser::parseJourneySection(const QJsonObject &obj
v.setNetwork(to.rentalVehicleStation().network());
}
v.setType(vehicleTypeFromTypes(v.network().vehicleTypes(), RentalVehicle::Bicycle));
section.setRentalVehicle(v);
if (v.network().isValid() || isRented) {
section.setMode(JourneySection::RentedVehicle);
section.setRentalVehicle(v);
} else {
section.setMode(JourneySection::IndividualTransport);
section.setIndividualTransport({ IndividualTransport::Bike });
}
} else if (mode == QLatin1String("CAR")) {
section.setMode(JourneySection::IndividualTransport);
section.setIndividualTransport({ IndividualTransport::Car });
} else {
section.setMode(JourneySection::Walking);
qWarning() << "Unhandled OTP mode:" << mode;
}
}
......
......@@ -35,6 +35,7 @@ query journeys(
distance
mode
transitLeg
rentedBike
from { ...locationFragment }
to { ...locationFragment }
trip {
......
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