diff --git a/src/lib/marble/geodata/data/GeoDataRelation.cpp b/src/lib/marble/geodata/data/GeoDataRelation.cpp index 1997712e1..c5b36de09 100644 --- a/src/lib/marble/geodata/data/GeoDataRelation.cpp +++ b/src/lib/marble/geodata/data/GeoDataRelation.cpp @@ -1,131 +1,143 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2017 Dennis Nienhüser #include "GeoDataRelation.h" #include "GeoDataTypes.h" #include "OsmPlacemarkData.h" #include namespace Marble { class GeoDataRelationPrivate { public: QSet m_features; OsmPlacemarkData m_osmData; QSet m_memberIds; static QHash s_relationTypes; }; QHash GeoDataRelationPrivate::s_relationTypes; GeoDataRelation::GeoDataRelation() : GeoDataFeature(), d_ptr(new GeoDataRelationPrivate) { // nothing to do } GeoDataRelation::~GeoDataRelation() { delete d_ptr; } GeoDataRelation::GeoDataRelation(const GeoDataRelation &other) : GeoDataFeature(other), d_ptr(new GeoDataRelationPrivate) { Q_D(GeoDataRelation); d->m_features = other.d_func()->m_features; d->m_osmData = other.d_func()->m_osmData; } GeoDataRelation &GeoDataRelation::operator=(GeoDataRelation other) // passed by value { GeoDataFeature::operator=(other); std::swap(*this->d_ptr, *other.d_ptr); return *this; } const char *GeoDataRelation::nodeType() const { return GeoDataTypes::GeoDataRelationType; } GeoDataFeature *GeoDataRelation::clone() const { return new GeoDataRelation(*this); } void GeoDataRelation::addMember(const GeoDataFeature *feature, qint64 id, const QString &role) { Q_D(GeoDataRelation); d->m_features << feature; d->m_osmData.addRelation(id, role); d->m_memberIds << id; } QSet GeoDataRelation::members() const { Q_D(const GeoDataRelation); return d->m_features; } OsmPlacemarkData &GeoDataRelation::osmData() { Q_D(GeoDataRelation); return d->m_osmData; } const OsmPlacemarkData &GeoDataRelation::osmData() const { Q_D(const GeoDataRelation); return d->m_osmData; } GeoDataRelation::RelationType GeoDataRelation::relationType() const { if (GeoDataRelationPrivate::s_relationTypes.isEmpty()) { auto &map = GeoDataRelationPrivate::s_relationTypes; map["road"] = RouteRoad; map["detour"] = RouteDetour; map["ferry"] = RouteFerry; map["train"] = RouteTrain; + map["subway"] = RouteSubway; map["tram"] = RouteTram; map["bus"] = RouteBus; map["trolleybus"] = RouteTrolleyBus; map["bicycle"] = RouteBicycle; map["mtb"] = RouteMountainbike; map["foot"] = RouteFoot; map["hiking"] = GeoDataRelation::RouteHiking; map["horse"] = RouteHorse; map["inline_skates"] = RouteInlineSkates; - map["ski"] = RouteSki; } Q_D(const GeoDataRelation); if (d->m_osmData.containsTag(QStringLiteral("type"), QStringLiteral("route"))) { auto const route = d->m_osmData.tagValue(QStringLiteral("route")); + if (route == QStringLiteral("piste")) { + auto const piste = d->m_osmData.tagValue(QStringLiteral("piste:type")); + if (piste == QStringLiteral("downhill")) { + return RouteSkiDownhill; + } else if (piste == QStringLiteral("nordic")) { + return RouteSkiNordic; + } else if (piste == QStringLiteral("skitour")) { + return RouteSkitour; + } else if (piste == QStringLiteral("sled")) { + return RouteSled; + } + } return GeoDataRelationPrivate::s_relationTypes.value(route, UnknownType); } return UnknownType; } QSet GeoDataRelation::memberIds() const { Q_D(const GeoDataRelation); return d->m_memberIds; } } diff --git a/src/lib/marble/geodata/data/GeoDataRelation.h b/src/lib/marble/geodata/data/GeoDataRelation.h index 161760571..6205bda0a 100644 --- a/src/lib/marble/geodata/data/GeoDataRelation.h +++ b/src/lib/marble/geodata/data/GeoDataRelation.h @@ -1,67 +1,71 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2017 Dennis Nienhüser #ifndef MARBLE_GEODATARELATION_H #define MARBLE_GEODATARELATION_H #include "GeoDataCoordinates.h" #include "GeoDataPlacemark.h" #include "geodata_export.h" namespace Marble { class GeoDataRelationPrivate; class GEODATA_EXPORT GeoDataRelation: public GeoDataFeature { public: enum RelationType { UnknownType, RouteRoad, RouteDetour, RouteFerry, RouteTrain, + RouteSubway, RouteTram, RouteBus, RouteTrolleyBus, RouteBicycle, RouteMountainbike, RouteFoot, RouteHiking, RouteHorse, RouteInlineSkates, - RouteSki + RouteSkiDownhill, + RouteSkiNordic, + RouteSkitour, + RouteSled, }; GeoDataRelation(); ~GeoDataRelation(); GeoDataRelation(const GeoDataRelation &other); GeoDataRelation & operator=(GeoDataRelation other); const char* nodeType() const override; GeoDataFeature * clone() const override; void addMember(const GeoDataFeature* feature, qint64 id, const QString &role); QSet members() const; OsmPlacemarkData &osmData(); const OsmPlacemarkData &osmData() const; RelationType relationType() const; QSet memberIds() const; private: GeoDataRelationPrivate* d_ptr; Q_DECLARE_PRIVATE(GeoDataRelation) }; } #endif