Commit 213a334a authored by Volker Krause's avatar Volker Krause
Browse files

Basic support for GBFS v2.1 docked vehicle data

This at least produces correct vehicle data now, still to be decided
whether those should be merged with the corresponding dock data in some
parent ef7db0cb
......@@ -184,16 +184,26 @@ static void appendResults(const GBFSService &service, const LocationRequest &req
const auto lat = GBFSReader::readLatitude(bike);
const auto lon = GBFSReader::readLongitude(bike);
if (std::isnan(lat) || std::isnan(lon) || Location::distance(lat, lon, req.latitude(), req.longitude()) > req.maximumDistance()) {
const bool selectedByCoord = !std::isnan(lat) && !std::isnan(lon) && Location::distance(lat, lon, req.latitude(), req.longitude()) > req.maximumDistance();
// GBFS v2.1: docked vehicle status - TODO do we want to drop the corresponding station in that case?
const auto id = stationIdToString(bike.value(QLatin1String("station_id")));
const auto it = std::find(selectedStationIds.begin(), selectedStationIds.end(), id);
if (it == selectedStationIds.end() && !selectedByCoord) {
Location loc;
loc.setCoordinate(lat, lon);
const auto stationId = bike.value(QLatin1String("bike_id")).toString();
loc.setIdentifier(service.systemId, stationId);
if (selectedByCoord) {
loc.setCoordinate(lat, lon);
} else {
const auto &station = context->result[context->result.size() - selectedStationIds.size() + std::distance(selectedStationIds.begin(), it)];
loc.setCoordinate(station.latitude(), station.longitude());
const auto bikeId = bike.value(QLatin1String("bike_id")).toString();
loc.setIdentifier(service.systemId, bikeId);
// TODO deep rental links
RentalVehicle vehicle;
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