KOSMIndoorMap
10 #include "kosm_export.h"
12 #include "datatypes.h"
25 inline constexpr
Element() : m_elem(
nullptr,
static_cast<uint8_t
>(Type::Null)) {}
26 inline Element(
const Node *node) : m_elem(node,
static_cast<uint8_t
>(Type::Node)) {}
27 inline Element(
const Way *way) : m_elem(way,
static_cast<uint8_t
>(Type::Way)) {}
28 inline Element(
const Relation *relation) : m_elem(relation,
static_cast<uint8_t
>(Type::Relation)) {}
30 inline bool operator==(
Element other)
const {
return m_elem == other.m_elem; }
31 inline bool operator!=(
Element other)
const {
return m_elem != other.m_elem; }
32 inline bool operator<(
Element other)
const {
return m_elem < other.m_elem; }
33 explicit inline operator bool()
const {
return type() != OSM::Type::Null; }
35 inline Type type()
const {
return static_cast<Type>(m_elem.tag()); }
36 inline const Node* node()
const {
return static_cast<const Node*
>(m_elem.get()); }
37 inline const Way* way()
const {
return static_cast<const Way*
>(m_elem.get()); }
38 inline const Relation* relation()
const {
return static_cast<const Relation*
>(m_elem.get()); }
49 template <
typename K,
typename ...Args>
QByteArray tagValue(K key, Args... args)
const;
52 inline bool hasTags()
const {
return std::distance(tagsBegin(), tagsEnd()) > 0; }
54 bool hasTag(
TagKey key)
const;
56 std::vector<Tag>::const_iterator tagsBegin()
const;
57 std::vector<Tag>::const_iterator tagsEnd()
const;
64 std::vector<const Node*> outerPath(
const DataSet &dataSet)
const;
70 void recomputeBoundingBox(
const DataSet &dataSet);
76 template <
typename K,
typename ...Args>
79 const auto v = tagValue(k);
83 return tagValue(args...);
86 template <
typename K,
typename ...Args>
89 const auto v = tagValue(locale, key);
93 return tagValue(locale, args...);
108 m_element = other.m_element;
109 other.m_element = {};
116 m_element = other.m_element;
117 other.m_element = {};
121 explicit inline operator bool()
const {
return m_element.type() != OSM::Type::Null; }
123 constexpr
inline Element element()
const {
return m_element; }
124 constexpr
inline operator Element()
const {
return m_element; }
139 template <
typename ...Args>
140 constexpr Element
coalesce(Element e, Args... args) {
return e ? e :
coalesce(args...); }
142 enum ForeachFlag : uint8_t {
143 IncludeRelations = 1,
146 IterateAll = IncludeRelations | IncludeWays | IncludeNodes,
149 template <
typename Func>
150 inline void for_each(
const DataSet &dataSet, Func func, uint8_t flags = IterateAll)
152 if (flags & IncludeRelations) {
153 for (
const auto &rel : dataSet.relations) {
157 if (flags & IncludeWays) {
158 for (
const auto &way : dataSet.ways) {
162 if (flags & IncludeNodes) {
163 for (
const auto &node : dataSet.nodes) {
164 func(Element(&node));
169 template <
typename Func>
170 inline void for_each_node(
const DataSet &dataSet,
const Way &way, Func func)
172 for (
auto nodeId : way.nodes) {
173 if (
auto node = dataSet.node(nodeId)) {
179 template <
typename Func>
180 inline void for_each_member(
const DataSet &dataSet,
const Relation &rel, Func func)
182 for (
const auto &mem : rel.members) {
183 switch (mem.type()) {
187 if (
auto node = dataSet.node(mem.id)) {
192 if (
auto way = dataSet.way(mem.id)) {
197 if (
auto rel = dataSet.relation(mem.id)) {
209 #endif // OSM_ELEMENT_H
int64_t Id
OSM element identifier.
A set of nodes, ways and relations.
Coordinate, stored as 1e7 * degree to avoid floating point precision issues, and offset to unsigned v...
KOSM_EXPORT UniqueElement copy_element(Element e)
Creates a copy of element.
void removeTag(Elem &elem, TagKey key)
Removes a tag from the given element.
A std::unique_ptr-like object for OSM element types.
void setTagValue(Elem &elem, TagKey key, const QByteArray &value)
Inserts a new tag, or updates an existing one.
bool hasTags() const
Returns whether or not this element has any tags set.
QByteArray tagValue(const Elem &elem, TagKey key)
Returns the tag value for key of elem.
Low-level types and functions to work with raw OSM data as efficiently as possible.
constexpr Element coalesce(Element e)
Utility function similar to SQL COALESCE for OSM::Element, ie.
A reference to any of OSM::Node/OSM::Way/OSM::Relation.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sat Sep 30 2023 04:03:49 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.