File indexing completed on 2024-11-24 04:15:37
0001 /* 0002 SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KOSMINDOORMAP_MAPDATA_H 0008 #define KOSMINDOORMAP_MAPDATA_H 0009 0010 #include "kosmindoormap_export.h" 0011 0012 #include <KOSM/Datatypes> 0013 #include <KOSM/Element> 0014 0015 #include <QMetaType> 0016 0017 #include <map> 0018 #include <memory> 0019 #include <vector> 0020 0021 class QPointF; 0022 class QTimeZone; 0023 0024 namespace KOSMIndoorMap { 0025 0026 /** A floor level. */ 0027 class KOSMINDOORMAP_EXPORT MapLevel 0028 { 0029 public: 0030 explicit MapLevel(int level = 0); 0031 ~MapLevel(); 0032 0033 bool operator<(const MapLevel &other) const; 0034 bool operator==(const MapLevel &other) const; 0035 0036 bool hasName() const; 0037 QString name() const; 0038 void setName(const QString &name); 0039 0040 bool isFullLevel() const; 0041 /** In case this is not a full level, this returns the numeric values of the full levels above/below. */ 0042 int fullLevelBelow() const; 0043 int fullLevelAbove() const; 0044 0045 int numericLevel() const; 0046 0047 private: 0048 int m_level = 0; 0049 QString m_levelName; 0050 }; 0051 } 0052 0053 Q_DECLARE_METATYPE(KOSMIndoorMap::MapLevel) 0054 0055 namespace KOSMIndoorMap { 0056 class MapDataPrivate; 0057 0058 /** Raw OSM map data, separated by levels. */ 0059 class KOSMINDOORMAP_EXPORT MapData 0060 { 0061 Q_GADGET 0062 /** Center position of the bounding box for QML usage (longitude/latitude, in degree). */ 0063 Q_PROPERTY(QPointF center READ center) 0064 /** Radius from the bounding box center encompassing the entire bounding box, in meters. 0065 * Useful for circular search queries. 0066 */ 0067 Q_PROPERTY(float radius READ radius) 0068 0069 Q_PROPERTY(QString regionCode READ regionCode) 0070 Q_PROPERTY(QString timeZone READ timeZoneId) 0071 public: 0072 explicit MapData(); 0073 MapData(const MapData&); 0074 MapData(MapData&&); 0075 ~MapData(); 0076 0077 MapData& operator=(const MapData&); 0078 MapData& operator=(MapData&&); 0079 0080 bool isEmpty() const; 0081 bool operator==(const MapData &other) const; 0082 0083 const OSM::DataSet& dataSet() const; 0084 OSM::DataSet& dataSet(); 0085 void setDataSet(OSM::DataSet &&dataSet); 0086 0087 OSM::BoundingBox boundingBox() const; 0088 void setBoundingBox(OSM::BoundingBox bbox); 0089 0090 const std::map<MapLevel, std::vector<OSM::Element>>& levelMap() const; 0091 0092 QPointF center() const; 0093 float radius() const; 0094 0095 /** ISO 3166-1/2 region or country code of the area covered by this map data. */ 0096 QString regionCode() const; 0097 void setRegionCode(const QString ®ionCode); 0098 0099 /** Timezone the are covered by this map data is in. */ 0100 QTimeZone timeZone() const; 0101 void setTimeZone(const QTimeZone &tz); 0102 0103 private: 0104 void processElements(); 0105 void addElement(int level, OSM::Element e, bool isDependentElement); 0106 QString levelName(OSM::Element e); 0107 void filterLevels(); 0108 0109 QString timeZoneId() const; 0110 0111 std::shared_ptr<MapDataPrivate> d; 0112 }; 0113 0114 } 0115 0116 Q_DECLARE_METATYPE(KOSMIndoorMap::MapData) 0117 0118 #endif // KOSMINDOORMAP_MAPDATA_H