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

Distinguish between dock-based and free floating rental vehicles

parent 4bbe4e2a
Pipeline #45249 passed with stage
in 20 seconds
......@@ -157,6 +157,12 @@ LocationQueryOverlayProxyModel::Info LocationQueryOverlayProxyModel::nodeForRow(
Info info;
info.overlayNode.coordinate = OSM::Coordinate(loc.latitude(), loc.longitude());
switch (loc.type()) {
case Location::Place:
case Location::Stop:
Q_UNREACHABLE();
break;
case Location::RentedVehicleStation:
// try to find a matching node in the base OSM data
for (const auto &n : m_data.dataSet().nodes) {
if (OSM::distance(n.coordinate, info.overlayNode.coordinate) < 10 && OSM::tagValue(n, m_tagKeys.amenity) == "bicycle_rental") {
......@@ -173,16 +179,21 @@ LocationQueryOverlayProxyModel::Info LocationQueryOverlayProxyModel::nodeForRow(
if (loc.rentalVehicleStation().capacity() >= 0) {
OSM::setTagValue(info.overlayNode, m_tagKeys.capacity, QByteArray::number(loc.rentalVehicleStation().capacity()));
}
if (loc.rentalVehicleStation().isValid()) {
OSM::setTagValue(info.overlayNode, m_tagKeys.realtimeAvailable, QByteArray::number(loc.rentalVehicleStation().availableVehicles()));
} else { // free floating
if (OSM::tagValue(info.overlayNode, m_tagKeys.network).isEmpty() && !loc.rentalVehicleStation().network().name().isEmpty()) {
OSM::setTagValue(info.overlayNode, m_tagKeys.network, loc.rentalVehicleStation().network().name().toUtf8());
}
break;
case Location::RentedVehicle:
// free floating vehicles have no matching OSM element, so no point in searching for one
info.overlayNode.id = m_data.dataSet().nextInternalId();
OSM::setTagValue(info.overlayNode, m_tagKeys.amenity, "bicycle_rental");
OSM::setTagValue(info.overlayNode, m_tagKeys.name, loc.name().toUtf8());
OSM::setTagValue(info.overlayNode, m_tagKeys.realtimeAvailable, "1");
if (OSM::tagValue(info.overlayNode, m_tagKeys.network).isEmpty() && !loc.rentalVehicle().network().name().isEmpty()) {
OSM::setTagValue(info.overlayNode, m_tagKeys.network, loc.rentalVehicle().network().name().toUtf8());
}
if (OSM::tagValue(info.overlayNode, m_tagKeys.network).isEmpty() && !loc.rentalVehicleStation().network().name().isEmpty()) {
OSM::setTagValue(info.overlayNode, m_tagKeys.network, loc.rentalVehicleStation().network().name().toUtf8());
break;
}
return info;
}
......@@ -277,7 +277,7 @@ Kirigami.ApplicationWindow {
locationQuery.request.latitude = page.map.mapData.center.y;
locationQuery.request.longitude = page.map.mapData.center.x;
locationQuery.request.maximumDistance = page.map.mapData.radius;
locationQuery.request.types = PublicTransport.Location.RentedVehicleStation;
locationQuery.request.types = PublicTransport.Location.RentedVehicleStation | PublicTransport.Location.RentedVehicle;
}
}
}
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