22 return relation()->id;
35 return node()->coordinate;
37 return way()->bbox.center();
39 return relation()->bbox.center();
52 return BoundingBox(node()->coordinate, node()->coordinate);
56 return relation()->bbox;
63QByteArray Element::tagValue(
TagKey key)
const
80QByteArray Element::tagValue(
const char *keyName)
const
97QByteArray Element::tagValue(
const OSM::Languages &languages,
const char *keyName)
const
116 return std::binary_search(tagsBegin(), tagsEnd(), key);
119std::vector<Tag>::const_iterator OSM::Element::tagsBegin()
const
125 return node()->tags.begin();
127 return way()->tags.begin();
129 return relation()->tags.begin();
134std::vector<Tag>::const_iterator OSM::Element::tagsEnd()
const
140 return node()->tags.end();
142 return way()->tags.end();
144 return relation()->tags.end();
149QString Element::url()
const
155 return node()->url();
159 return relation()->url();
175 std::vector<const Node*> nodes;
181 if (tagValue(
"type") !=
"multipolygon") {
186 std::vector<const Way*> ways;
187 for (
const auto &member : relation()->members) {
188 if (std::strcmp(member.role().name(),
"outer") != 0) {
191 if (
auto way = dataSet.
way(member.id)) {
197 std::vector<const Node*> nodes;
214 way()->bbox = std::accumulate(way()->nodes.begin(), way()->nodes.end(),
OSM::BoundingBox(), [&dataSet](
auto bbox,
auto nodeId) {
215 if (auto node = dataSet.node(nodeId)) {
216 return OSM::unite(bbox, {node->coordinate, node->coordinate});
222 relation()->bbox = {};
223 for_each_member(dataSet, *relation(), [
this, &dataSet](
auto mem) {
224 mem.recomputeBoundingBox(dataSet);
225 relation()->bbox = OSM::unite(relation()->bbox, mem.boundingBox());
232UniqueElement::~UniqueElement()
234 switch (m_element.type()) {
235 case OSM::Type::Null:
237 case OSM::Type::Node:
238 delete m_element.node();
241 delete m_element.way();
243 case OSM::Type::Relation:
244 delete m_element.relation();
249void UniqueElement::setId(
Id id)
251 switch (m_element.type()) {
252 case OSM::Type::Null:
254 case OSM::Type::Node:
255 const_cast<Node*
>(m_element.node())->id = id;
258 const_cast<Way*
>(m_element.way())->id = id;
260 case OSM::Type::Relation:
261 const_cast<Relation*
>(m_element.relation())->id = id;
266void UniqueElement::setTagValue(
TagKey key, QByteArray &&value)
268 switch (m_element.type()) {
269 case OSM::Type::Null:
271 case OSM::Type::Node:
275 OSM::setTagValue(*
const_cast<Way*
>(m_element.way()), key, std::move(value));
277 case OSM::Type::Relation:
278 OSM::setTagValue(*
const_cast<Relation*
>(m_element.relation()), key, std::move(value));
283void UniqueElement::removeTag(
TagKey key)
285 switch (m_element.type()) {
286 case OSM::Type::Null:
288 case OSM::Type::Node:
294 case OSM::Type::Relation:
295 OSM::removeTag(*
const_cast<Relation*
>(m_element.relation()), key);
303 case OSM::Type::Null:
305 case OSM::Type::Node:
309 case OSM::Type::Relation:
Coordinate, stored as 1e7 * degree to avoid floating point precision issues, and offset to unsigned v...
A set of nodes, ways and relations.
const Way * way(Id id) const
Find a way by its id.
A reference to any of OSM::Node/OSMWay/OSMRelation.
void recomputeBoundingBox(const DataSet &dataSet)
Recompute the bounding box of this element.
bool hasTag(TagKey key) const
Returns true if this element has a tag with key key.
std::vector< const Node * > outerPath(const DataSet &dataSet) const
Returns all nodes belonging to the outer path of this element.
A std::unique_ptr-like object for OSM element types.
Low-level types and functions to work with raw OSM data as efficiently as possible.
void setTagValue(Elem &elem, TagKey key, QByteArray &&value)
Inserts a new tag, or updates an existing one.
int64_t Id
OSM element identifier.
KOSM_EXPORT void assemblePath(const DataSet &dataSet, std::vector< const Way * > &&ways, std::vector< const Node * > &path)
Assemble a continuous path into path from the given ways.
KOSM_EXPORT UniqueElement copy_element(Element e)
Creates a copy of element.
static void appendNodesFromWay(const DataSet &dataSet, std::vector< const Node * > &nodes, const Iter &nodeBegin, const Iter &nodeEnd)
Appends the nodes referenced by nodesBegin and @pnodesEnd into nodes.
QByteArray tagValue(const Elem &elem, TagKey key)
Returns the tag value for key of elem.
void removeTag(Elem &elem, TagKey key)
Removes a tag from the given element.