Commit 0ffac825 authored by Volker Krause's avatar Volker Krause
Browse files

Display remaining range of rental vehicles when available

Also color those with only a few kilometers left in yellow rather than
green.
parent e1c1c247
......@@ -44,6 +44,7 @@ void LocationQueryOverlayProxyModel::setMapData(const MapData &data)
m_tagKeys.realtimeAvailable = m_data.dataSet().makeTagKey("mx:realtime_available");
m_tagKeys.network = m_data.dataSet().makeTagKey("network");
m_tagKeys.mxoid = m_data.dataSet().makeTagKey("mx:oid");
m_tagKeys.remainingRange = m_data.dataSet().makeTagKey("mx:remaining_range");
}
initialize();
......@@ -211,6 +212,9 @@ LocationQueryOverlayProxyModel::Info LocationQueryOverlayProxyModel::nodeForRow(
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 (vehicle.remainingRange() >= 0) {
OSM::setTagValue(info.overlayNode, m_tagKeys.remainingRange, QByteArray::number(vehicle.remainingRange()));
}
break;
}
case Location::Equipment:
......
......@@ -67,6 +67,7 @@ private:
OSM::TagKey realtimeAvailable;
OSM::TagKey network;
OSM::TagKey mxoid;
OSM::TagKey remainingRange;
} m_tagKeys;
std::vector<Info> m_nodes;
......
......@@ -15,6 +15,17 @@
using namespace KOSMIndoorMap;
static QString formatDistance(int meter)
{
if (meter < 1000) {
return i18n("%1m", meter);
}
if (meter < 10000) {
return i18n("%1km", ((int)meter/100)/10.0);
}
return i18n("%1km", (int)qRound(meter/1000.0));
}
bool OSMElementInformationModel::Info::operator<(OSMElementInformationModel::Info other) const
{
if (category == other.category) {
......@@ -183,6 +194,7 @@ struct {
M("email", Email, Contact),
M("fee", Fee, UnresolvedCategory),
M("maxstay", MaxStay, Parking),
M("mx:remaining_range", RemainingRange, Main),
M("network", Network, Operator),
M("office", Category, Header),
M("old_name", OldName, UnresolvedCategory),
......@@ -436,6 +448,7 @@ QString OSMElementInformationModel::keyName(OSMElementInformationModel::Key key)
case OperatorName: return {};
case Network: return i18nc("transport network", "Network");
case OperatorWikipedia: return {};
case RemainingRange: return i18nc("remaining travel range of a battery powered vehicle", "Remaining range");
case DebugLink: return QStringLiteral("OSM");
case DebugKey: return {};
}
......@@ -637,6 +650,11 @@ QVariant OSMElementInformationModel::valueForKey(Info info) const
case OperatorName: return QString::fromUtf8(m_element.tagValue("operator"));
case Network: return QString::fromUtf8(m_element.tagValue("network"));
case OperatorWikipedia: return wikipediaUrl(m_element.tagValue("operator:wikipedia", QLocale()));
case RemainingRange:
{
const auto range = m_element.tagValue("mx:remaining_range").toInt();
return formatDistance(range);
}
case DebugLink: return m_element.url();
case DebugKey: return {};
}
......
......@@ -89,6 +89,7 @@ public:
OperatorName,
Network,
OperatorWikipedia,
RemainingRange,
DebugLink,
DebugKey,
};
......
......@@ -485,6 +485,10 @@ node|z20-[vending=public_transport_tickets] {
icon-color: #27ae60;
text: "";
}
*|z18-[amenity=scooter_rental][mx:realtime_available>0][mx:remaining_range<5000]
{
icon-color: #fdbc4b;
}
// charging stations
node|z19-[amenity=charging_station] {
......
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