Commit 672efb99 authored by Volker Krause's avatar Volker Krause
Browse files

Forward vehicle sharing dock address data and names

Makes those show up in the info box when available (and newer GBFS versions
actually provide those).
parent cb63fd24
Pipeline #197432 passed with stage
in 5 minutes and 57 seconds
......@@ -59,6 +59,9 @@ void LocationQueryOverlayProxyModel::setMapData(const MapData &data)
m_tagKeys.mxoid = m_data.dataSet().makeTagKey("mx:oid");
m_tagKeys.remainingRange = m_data.dataSet().makeTagKey("mx:remaining_range");
m_tagKeys.vehicle = m_data.dataSet().makeTagKey("mx:vehicle");
m_tagKeys.addr_street = m_data.dataSet().makeTagKey("addr:street");
m_tagKeys.addr_city = m_data.dataSet().makeTagKey("addr:city");
m_tagKeys.addr_postcode = m_data.dataSet().makeTagKey("addr:postcode");
}
int i = 0;
......@@ -169,6 +172,13 @@ void LocationQueryOverlayProxyModel::initialize()
}
}
static void setTagIfMissing(OSM::Node &node, OSM::TagKey tag, const QString &value)
{
if (OSM::tagValue(node, tag).isEmpty() && !value.isEmpty()) {
OSM::setTagValue(node, tag, value.toUtf8());
}
}
LocationQueryOverlayProxyModel::Info LocationQueryOverlayProxyModel::nodeForRow(int row) const
{
const auto idx = m_sourceModel->index(row, 0);
......@@ -203,9 +213,11 @@ LocationQueryOverlayProxyModel::Info LocationQueryOverlayProxyModel::nodeForRow(
OSM::setTagValue(info.overlayNode, m_tagKeys.capacity, QByteArray::number(station.capacity()));
}
OSM::setTagValue(info.overlayNode, m_tagKeys.realtimeAvailable, QByteArray::number(station.availableVehicles()));
if (OSM::tagValue(info.overlayNode, m_tagKeys.network).isEmpty() && !station.network().name().isEmpty()) {
OSM::setTagValue(info.overlayNode, m_tagKeys.network, station.network().name().toUtf8());
}
setTagIfMissing(info.overlayNode, m_tagKeys.network, station.network().name());
setTagIfMissing(info.overlayNode, m_tagKeys.name, loc.name());
setTagIfMissing(info.overlayNode, m_tagKeys.addr_street, loc.streetAddress());
setTagIfMissing(info.overlayNode, m_tagKeys.addr_city, loc.locality());
setTagIfMissing(info.overlayNode, m_tagKeys.addr_postcode, loc.postalCode());
int i = 0;
for (const auto &v : vehicle_type_map) {
......@@ -240,9 +252,7 @@ LocationQueryOverlayProxyModel::Info LocationQueryOverlayProxyModel::nodeForRow(
break;
}
OSM::setTagValue(info.overlayNode, m_tagKeys.name, loc.name().toUtf8());
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());
}
setTagIfMissing(info.overlayNode, m_tagKeys.network, vehicle.network().name());
if (vehicle.remainingRange() >= 0) {
OSM::setTagValue(info.overlayNode, m_tagKeys.remainingRange, QByteArray::number(vehicle.remainingRange()));
}
......
......@@ -69,6 +69,9 @@ private:
OSM::TagKey mxoid;
OSM::TagKey remainingRange;
OSM::TagKey vehicle;
OSM::TagKey addr_street;
OSM::TagKey addr_city;
OSM::TagKey addr_postcode;
} m_tagKeys;
OSM::TagKey m_realtimeAvailableTagKeys[5];
......
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