File indexing completed on 2024-12-01 10:29:54

0001 /*
0002     SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef OSM_PATHUTIL_H
0008 #define OSM_PATHUTIL_H
0009 
0010 #include "datatypes.h"
0011 
0012 #include <vector>
0013 
0014 namespace OSM {
0015 
0016 class Element;
0017 
0018 /** Appends the nodes referenced by @p nodesBegin and @pnodesEnd into @p nodes.
0019  *  This would typically be iterators on OSM::Way::nodes.
0020  */
0021 template <typename Iter>
0022 static void appendNodesFromWay(const DataSet &dataSet, std::vector<const Node*> &nodes, const Iter& nodeBegin, const Iter &nodeEnd)
0023 {
0024     nodes.reserve(nodes.size() + std::distance(nodeBegin, nodeEnd));
0025     for (auto it = nodeBegin; it != nodeEnd; ++it) {
0026         if (auto node = dataSet.node((*it))) {
0027             nodes.push_back(node);
0028         }
0029     }
0030 }
0031 
0032 /** Assemble a continuous path into @p path from the given @p ways. */
0033 void assemblePath(const DataSet &dataSet, std::vector<const Way*> &&ways, std::vector<const Node*> &path);
0034 void assemblePath(const DataSet &dataSet, const std::vector<OSM::Element> &ways, std::vector<const Node*> &path);
0035 
0036 }
0037 
0038 #endif // OSM_PATHUTIL_H