6#include "routeoverlay.h"
8using namespace KOSMIndoorRouting;
10RouteOverlay::RouteOverlay(
QObject *parent)
15RouteOverlay::~RouteOverlay() =
default;
20 if (mapData.isEmpty()) {
24 m_mxRouteKey = m_data.dataSet().
makeTagKey(
"mx:routing");
31 m_gc.push_back(std::move(m_startNode));
36 m_startNode.node()->coordinate = c;
37 m_startNode.setTagValue(m_mxRouteKey,
"start");
38 m_startLevel = floorLevel;
46 m_gc.push_back(std::move(m_endNode));
51 m_endNode.node()->coordinate = c;
52 m_endNode.setTagValue(m_mxRouteKey,
"end");
53 m_endLevel = floorLevel;
58void RouteOverlay::setRoute(
const Route &route)
60 for (
auto &way : m_routeWays) {
61 m_gc.push_back(std::move(way));
64 m_routeWayFloorLevels.clear();
65 m_transientNodesGC.push_back(std::move(m_transientNodes));
68 if (m_route.steps().size() < 2) {
73 m_transientNodes.reserve(m_route.steps().size());
76 int prevLevel = m_route.steps()[0].floorLevel;
79 for (
auto it = m_route.steps().begin(); it != m_route.steps().end();) {
81 bbox = OSM::unite(bbox, {(*it).coordinate, (*it).coordinate});
86 way.setTagValue(m_mxRouteKey,
"route");
91 node.coordinate = (*it).coordinate;
92 way.way()->nodes.push_back(node.id);
93 m_transientNodes.push_back(std::move(node));
95 if (way.way()->nodes.size() >= 2 && (*it).floorLevel != prevLevel) {
96 m_routeWays.push_back(std::move(way));
97 m_routeWayFloorLevels.push_back(prevLevel);
98 prevLevel = (*it).floorLevel;
106 m_routeWays.push_back(std::move(way));
107 m_routeWayFloorLevels.push_back(prevLevel);
110 std::sort(m_transientNodes.begin(), m_transientNodes.end());
111 for (
auto &way :m_routeWays) {
112 way.way()->bbox = bbox;
118void RouteOverlay::forEach(
int floorLevel,
const std::function<
void(
OSM::Element,
int)> &func)
const
120 for (std::size_t i = 0; i < m_routeWays.size(); ++i) {
121 if (floorLevel == m_routeWayFloorLevels[i]) {
122 func(m_routeWays[i], floorLevel);
126 if (m_startNode && m_startLevel == floorLevel) {
127 func(m_startNode, floorLevel);
129 if (m_endNode && m_endLevel == floorLevel) {
130 func(m_endNode, floorLevel);
134void RouteOverlay::endSwap()
137 m_transientNodesGC.clear();
140const std::vector<OSM::Node>* RouteOverlay::transientNodes()
const
142 return &m_transientNodes;
145#include "moc_routeoverlay.cpp"
void reset()
Trigger style re-compilation.
void update()
Trigger map re-rendering when the source changes.
Raw OSM map data, separated by levels.
Coordinate, stored as 1e7 * degree to avoid floating point precision issues, and offset to unsigned v...
Id nextInternalId() const
Create a unique id for internal use (ie.
TagKey makeTagKey(const char *keyName, StringMemory keyMemOpt=StringMemory::Transient)
Create a tag key for the given tag name.
A reference to any of OSM::Node/OSM::Way/OSM::Relation.
A std::unique_ptr-like object for OSM element types.
OSM-based multi-floor indoor maps for buildings.