KOSMIndoorMap

pathutil.h
1/*
2 SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef OSM_PATHUTIL_H
8#define OSM_PATHUTIL_H
9
10#include <kosm_export.h>
11
12#include "datatypes.h"
13
14#include <vector>
15
16namespace OSM {
17
18class Element;
19
20/** Appends the nodes referenced by @p nodesBegin and @pnodesEnd into @p nodes.
21 * This would typically be iterators on OSM::Way::nodes.
22 */
23template <typename Iter>
24static void appendNodesFromWay(const DataSet &dataSet, std::vector<const Node*> &nodes, const Iter& nodeBegin, const Iter &nodeEnd)
25{
26 nodes.reserve(nodes.size() + std::distance(nodeBegin, nodeEnd));
27 for (auto it = nodeBegin; it != nodeEnd; ++it) {
28 if (auto node = dataSet.node((*it))) {
29 nodes.push_back(node);
30 }
31 }
32}
33
34/** Assemble a continuous path into @p path from the given @p ways. */
35KOSM_EXPORT void assemblePath(const DataSet &dataSet, std::vector<const Way*> &&ways, std::vector<const Node*> &path);
36KOSM_EXPORT void assemblePath(const DataSet &dataSet, const std::vector<OSM::Element> &ways, std::vector<const Node*> &path);
37
38}
39
40#endif // OSM_PATHUTIL_H
A set of nodes, ways and relations.
Definition datatypes.h:346
const Node * node(Id id) const
Find a node by its id.
Definition datatypes.cpp:48
Low-level types and functions to work with raw OSM data as efficiently as possible.
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.
Definition pathutil.cpp:42
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.
Definition pathutil.h:24
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 6 2024 12:11:15 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.