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,32 +157,43 @@ LocationQueryOverlayProxyModel::Info LocationQueryOverlayProxyModel::nodeForRow( ...@@ -157,32 +157,43 @@ LocationQueryOverlayProxyModel::Info LocationQueryOverlayProxyModel::nodeForRow(
Info info; Info info;
info.overlayNode.coordinate = OSM::Coordinate(loc.latitude(), loc.longitude()); info.overlayNode.coordinate = OSM::Coordinate(loc.latitude(), loc.longitude());
// try to find a matching node in the base OSM data switch (loc.type()) {
for (const auto &n : m_data.dataSet().nodes) { case Location::Place:
if (OSM::distance(n.coordinate, info.overlayNode.coordinate) < 10 && OSM::tagValue(n, m_tagKeys.amenity) == "bicycle_rental") { case Location::Stop:
qDebug() << "found matching node, cloning that!" << n.url(); Q_UNREACHABLE();
info.sourceElement = OSM::Element(&n); break;
info.overlayNode = n; case Location::RentedVehicleStation:
OSM::setTagValue(info.overlayNode, m_tagKeys.mxoid, QByteArray::number(qlonglong(n.id))); // 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") {
qDebug() << "found matching node, cloning that!" << n.url();
info.sourceElement = OSM::Element(&n);
info.overlayNode = n;
OSM::setTagValue(info.overlayNode, m_tagKeys.mxoid, QByteArray::number(qlonglong(n.id)));
break;
}
}
info.overlayNode.id = m_data.dataSet().nextInternalId();
OSM::setTagValue(info.overlayNode, m_tagKeys.amenity, "bicycle_rental");
if (loc.rentalVehicleStation().capacity() >= 0) {
OSM::setTagValue(info.overlayNode, m_tagKeys.capacity, QByteArray::number(loc.rentalVehicleStation().capacity()));
}
OSM::setTagValue(info.overlayNode, m_tagKeys.realtimeAvailable, QByteArray::number(loc.rentalVehicleStation().availableVehicles()));
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());
}
break; break;
}
}
info.overlayNode.id = m_data.dataSet().nextInternalId();
OSM::setTagValue(info.overlayNode, m_tagKeys.amenity, "bicycle_rental");
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
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.rentalVehicleStation().network().name().isEmpty()) {
OSM::setTagValue(info.overlayNode, m_tagKeys.network, loc.rentalVehicleStation().network().name().toUtf8());
} }
return info; return info;
} }
...@@ -277,7 +277,7 @@ Kirigami.ApplicationWindow { ...@@ -277,7 +277,7 @@ Kirigami.ApplicationWindow {
locationQuery.request.latitude = page.map.mapData.center.y; locationQuery.request.latitude = page.map.mapData.center.y;
locationQuery.request.longitude = page.map.mapData.center.x; locationQuery.request.longitude = page.map.mapData.center.x;
locationQuery.request.maximumDistance = page.map.mapData.radius; 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