File indexing completed on 2024-07-21 09:27:11

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2015 Dennis Nienhüser <nienhueser@kde.org>
0004 //
0005 
0006 #ifndef MARBLE_OSMRELATION
0007 #define MARBLE_OSMRELATION
0008 
0009 #include "OsmNode.h"
0010 #include "OsmWay.h"
0011 #include <osm/OsmPlacemarkData.h>
0012 #include <GeoDataLinearRing.h>
0013 
0014 #include <QString>
0015 #include <QXmlStreamAttributes>
0016 #include <QSet>
0017 
0018 namespace Marble {
0019 
0020 class GeoDataDocument;
0021 
0022 class OsmRelation
0023 {
0024 public:
0025     OsmPlacemarkData & osmData();
0026     void parseMember(const QXmlStreamAttributes &attributes);
0027     void addMember(qint64 reference, const QString &role, const QString &type);
0028     void createMultipolygon(GeoDataDocument* document, OsmWays &ways, const OsmNodes &nodes, QSet<qint64> &usedNodes, QSet<qint64> &usedWays) const;
0029     void createRelation(GeoDataDocument* document, const QHash<qint64, GeoDataPlacemark*>& wayPlacemarks) const;
0030 
0031     const OsmPlacemarkData & osmData() const;
0032 
0033 private:
0034     typedef QPair<GeoDataLinearRing, OsmPlacemarkData> OsmRing;
0035     using OsmRings = QVector<OsmRing>;
0036 
0037     struct OsmMember
0038     {
0039         QString type;
0040         QString role;
0041         qint64 reference;
0042 
0043         OsmMember();
0044     };
0045 
0046     OsmRings rings(const QStringList &roles, const OsmWays &ways, const OsmNodes &nodes, QSet<qint64> &usedNodes, QSet<qint64> &usedWays) const;
0047 
0048     OsmPlacemarkData m_osmData;
0049     QVector<OsmMember> m_members;
0050 };
0051 
0052 typedef QHash<qint64,OsmRelation> OsmRelations;
0053 
0054 }
0055 
0056 #endif