File indexing completed on 2024-05-12 04:42:18
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 <kosm_export.h> 0011 0012 #include "datatypes.h" 0013 0014 #include <vector> 0015 0016 namespace OSM { 0017 0018 class Element; 0019 0020 /** Appends the nodes referenced by @p nodesBegin and @pnodesEnd into @p nodes. 0021 * This would typically be iterators on OSM::Way::nodes. 0022 */ 0023 template <typename Iter> 0024 static void appendNodesFromWay(const DataSet &dataSet, std::vector<const Node*> &nodes, const Iter& nodeBegin, const Iter &nodeEnd) 0025 { 0026 nodes.reserve(nodes.size() + std::distance(nodeBegin, nodeEnd)); 0027 for (auto it = nodeBegin; it != nodeEnd; ++it) { 0028 if (auto node = dataSet.node((*it))) { 0029 nodes.push_back(node); 0030 } 0031 } 0032 } 0033 0034 /** Assemble a continuous path into @p path from the given @p ways. */ 0035 KOSM_EXPORT void assemblePath(const DataSet &dataSet, std::vector<const Way*> &&ways, std::vector<const Node*> &path); 0036 KOSM_EXPORT void assemblePath(const DataSet &dataSet, const std::vector<OSM::Element> &ways, std::vector<const Node*> &path); 0037 0038 } 0039 0040 #endif // OSM_PATHUTIL_H