File indexing completed on 2024-11-17 04:17:23
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_PLATFORM_H 0008 #define KOSMINDOORMAP_PLATFORM_H 0009 0010 #include "kosmindoormap_export.h" 0011 0012 #include <QExplicitlySharedDataPointer> 0013 #include <QMetaType> 0014 #include <QStringList> 0015 0016 #include <vector> 0017 0018 namespace OSM { 0019 class Coordinate; 0020 class DataSet; 0021 class Element; 0022 } 0023 0024 namespace KOSMIndoorMap { 0025 0026 class PlatformSectionPrivate; 0027 0028 /** A railway platform section. */ 0029 class KOSMINDOORMAP_EXPORT PlatformSection 0030 { 0031 public: 0032 explicit PlatformSection(); 0033 PlatformSection(const PlatformSection&); 0034 PlatformSection(PlatformSection&&); 0035 ~PlatformSection(); 0036 PlatformSection& operator=(const PlatformSection&); 0037 PlatformSection& operator=(PlatformSection&&); 0038 0039 /** Platform section has enough data to work with. */ 0040 bool isValid() const; 0041 0042 /** Platform section name. */ 0043 QString name() const; 0044 void setName(const QString &name); 0045 /** Platform section position. */ 0046 OSM::Element position() const; 0047 void setPosition(const OSM::Element &position); 0048 0049 private: 0050 QExplicitlySharedDataPointer<PlatformSectionPrivate> d; 0051 }; 0052 0053 class PlatformPrivate; 0054 0055 /** A railway platform/track. */ 0056 class KOSMINDOORMAP_EXPORT Platform { 0057 Q_GADGET 0058 Q_PROPERTY(QString name READ name WRITE setName) 0059 Q_PROPERTY(Mode mode READ mode WRITE setMode) 0060 Q_PROPERTY(QString ifopt READ ifopt WRITE setIfopt) 0061 public: 0062 explicit Platform(); 0063 Platform(const Platform&); 0064 Platform(Platform&&); 0065 ~Platform(); 0066 Platform& operator=(const Platform&); 0067 Platform& operator=(Platform&&); 0068 0069 /** Platform has enough data to work with. */ 0070 bool isValid() const; 0071 0072 /** User-visible name of the platform. */ 0073 QString name() const; 0074 void setName(const QString &name); 0075 0076 /** Floor level. */ 0077 int level() const; 0078 bool hasLevel() const; 0079 void setLevel(int level); 0080 0081 /** A singular position for this platform (typically the stop position). 0082 * This can be useful for positining views or labels. 0083 */ 0084 OSM::Coordinate position() const; 0085 OSM::Element stopPoint() const; 0086 void setStopPoint(OSM::Element stop); 0087 0088 /** The platform edge path. */ 0089 OSM::Element edge() const; 0090 void setEdge(OSM::Element edge); 0091 0092 /** The platform area. 0093 * This is often shared between multiple tracks. 0094 */ 0095 OSM::Element area() const; 0096 void setArea(OSM::Element area); 0097 0098 /** The (railway) track this platform is serving. */ 0099 const std::vector<OSM::Element>& track() const; 0100 void setTrack(std::vector<OSM::Element> &&track); 0101 std::vector<OSM::Element>&& takeTrack(); 0102 0103 /** Platform sections. */ 0104 const std::vector<PlatformSection>& sections() const; 0105 void setSections(std::vector<PlatformSection> &§ions); 0106 std::vector<PlatformSection>&& takeSections(); 0107 0108 /** Transportation mode served by a platform. */ 0109 enum Mode { 0110 Unknown, 0111 Rail, 0112 LightRail, 0113 Subway, 0114 Tram, 0115 Monorail, 0116 Bus, 0117 }; 0118 Q_ENUM(Mode) 0119 Mode mode() const; 0120 void setMode(Mode mode); 0121 0122 /** IFOPT identifier */ 0123 QString ifopt() const; 0124 void setIfopt(const QString &ifopt); 0125 0126 /** Names of public transport lines stopping at this platform. */ 0127 QStringList lines() const; 0128 void setLines(QStringList &&lines); 0129 QStringList&& takeLines(); 0130 0131 /** Checks if two instances refer to the same platform. */ 0132 static bool isSame(const Platform &lhs, const Platform &rhs, const OSM::DataSet &dataSet); 0133 /** Merge two platform objects. */ 0134 static Platform merge(const Platform &lhs, const Platform &rhs, const OSM::DataSet &dataSet); 0135 0136 /** Checks if @p name is a plausible name for a platform. */ 0137 static bool isPlausibleName(const QString &name); 0138 /** Returns the preferred platform name given two possible alternatives. */ 0139 static QString preferredName(const QString &lhs, const QString &rhs); 0140 0141 private: 0142 friend class PlatformPrivate; 0143 QExplicitlySharedDataPointer<PlatformPrivate> d; 0144 }; 0145 0146 } 0147 0148 Q_DECLARE_METATYPE(KOSMIndoorMap::Platform) 0149 0150 #endif // KOSMINDOORMAP_PLATFORM_H