KOSMIndoorMap

platform.h
1 /*
2  SPDX-FileCopyrightText: 2020 Volker Krause <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #ifndef KOSMINDOORMAP_PLATFORM_H
8 #define KOSMINDOORMAP_PLATFORM_H
9 
10 #include "kosmindoormap_export.h"
11 
12 #include <KOSM/Element>
13 
14 #include <QMetaType>
15 #include <QStringList>
16 
17 #include <limits>
18 #include <vector>
19 
20 namespace KOSMIndoorMap {
21 
22 /** A railway platform section. */
23 class KOSMINDOORMAP_EXPORT PlatformSection
24 {
25 public:
26  /** Platform section has enough data to work with. */
27  bool isValid() const;
28 
29  QString name;
30  OSM::Element position;
31 };
32 
33 /** A railway platform/track. */
34 class KOSMINDOORMAP_EXPORT Platform {
35  Q_GADGET
36 public:
37  explicit Platform();
38  ~Platform();
39 
40  /** Platform has enough data to work with. */
41  bool isValid() const;
42 
43  /** User-visible name of the platform. */
44  QString name() const;
45  void setName(const QString &name);
46 
47  /** Floor level. */
48  int level() const;
49  bool hasLevel() const;
50  void setLevel(int level);
51 
52  /** A singular position for this platform (typically the stop position).
53  * This can be useful for positining views or labels.
54  */
55  OSM::Coordinate position() const;
56  OSM::Element stopPoint() const;
57  void setStopPoint(OSM::Element stop);
58 
59  /** The platform edge path. */
60  OSM::Element edge() const;
61  void setEdge(OSM::Element edge);
62 
63  /** The platform area.
64  * This is often shared between multiple tracks.
65  */
66  OSM::Element area() const;
67  void setArea(OSM::Element area);
68 
69  /** The (railway) track this platform is serving. */
70  const std::vector<OSM::Element>& track() const;
71  void setTrack(std::vector<OSM::Element> &&track);
72  std::vector<OSM::Element>&& takeTrack();
73 
74  /** Platform sections. */
75  const std::vector<PlatformSection>& sections() const;
76  void setSections(std::vector<PlatformSection> &&sections);
77  std::vector<PlatformSection>&& takeSections();
78 
79  /** Transportation mode served by a platform. */
80  enum Mode {
81  Unknown,
82  Rail,
83  LightRail,
84  Subway,
85  Tram,
86  Bus,
87  };
88  Q_ENUM(Mode)
89  Mode mode() const;
90  void setMode(Mode mode);
91 
92  // TODO - clean up once PlatformModel is ported to PlatformFinder
93  QStringList lines;
94 
95  /** Checks if two instances refer to the same platform. */
96  static bool isSame(const Platform &lhs, const Platform &rhs, const OSM::DataSet &dataSet);
97  /** Merge two platform objects. */
98  static Platform merge(const Platform &lhs, const Platform &rhs, const OSM::DataSet &dataSet);
99 
100  /** Checks if @p name is a plausible name for a platform. */
101  static bool isPlausibleName(const QString &name);
102  /** Returns the preferred platform name given two possible alternatives. */
103  static QString preferredName(const QString &lhs, const QString &rhs);
104 
105 private:
106  QString m_name;
107  OSM::Element m_stopPoint;
108  OSM::Element m_edge;
109  OSM::Element m_area;
110  std::vector<OSM::Element> m_track;
111  Mode m_mode = Rail; // TODO should eventually be "Unknown"
112  int m_level = std::numeric_limits<int>::min(); // INT_MIN indicates not set, needed for merging
113  std::vector<PlatformSection> m_sections;
114 
115  static void appendSection(std::vector<PlatformSection> &sections, const Platform &p, PlatformSection &&sec, std::vector<const OSM::Node*> &edgePath, const OSM::DataSet &dataSet);
116  static double maxSectionDistance(const Platform &p, const std::vector<PlatformSection> &sections, const OSM::DataSet &dataSet);
117 };
118 
119 }
120 
121 Q_DECLARE_METATYPE(KOSMIndoorMap::Platform)
122 
123 #endif // KOSMINDOORMAP_PLATFORM_H
OSM-based multi-floor indoor maps for buildings.
Coordinate, stored as 1e7 * degree to avoid floating point precision issues, and offset to unsigned v...
Definition: datatypes.h:37
A reference to any of OSM::Node/OSMWay/OSMRelation.
Definition: element.h:22
A railway platform section.
Definition: platform.h:23
A railway platform/track.
Definition: platform.h:34
Mode
Transportation mode served by a platform.
Definition: platform.h:80
A set of nodes, ways and relations.
Definition: datatypes.h:283
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Oct 25 2021 23:04:00 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.