6#include "routingcontroller.h"
8#include "navmeshbuilder.h"
10#include "routeoverlay.h"
14using namespace KOSMIndoorRouting;
16RoutingController::RoutingController(
QObject *parent)
18 , m_routeOverlay(new RouteOverlay(this))
22RoutingController::~RoutingController() =
default;
35 return m_builder || m_routingJob;
40 if (m_mapData == mapData) {
45 m_routeOverlay->setMapData(mapData);
51 m_routingJob =
nullptr;
58void RoutingController::setStartPosition(
double lat,
double lon,
int floorLevel)
60 qDebug() << lat << lon <<floorLevel;
62 m_startLevel = floorLevel;
63 m_routeOverlay->setStart(m_start, m_startLevel);
66void RoutingController::setEndPosition(
double lat,
double lon,
int floorLevel)
68 qDebug() << lat << lon <<floorLevel;
70 m_endLevel = floorLevel;
71 m_routeOverlay->setEnd(m_end, m_endLevel);
76 return m_routeOverlay;
81 qDebug() << profile.flags();
82 if (profile == m_routingProfile) {
85 m_routingProfile = profile;
89void RoutingController::searchRoute()
96 if (!m_start.isValid() && !m_end.isValid()) {
107 router->setNavMesh(m_navMesh);
108 router->setStart(m_navMesh.transform().mapGeoHeightToNav(m_start, m_startLevel));
109 router->setEnd(m_navMesh.transform().mapGeoHeightToNav(m_end, m_endLevel));
110 router->setRoutingProfile(m_routingProfile);
111 connect(router, &RoutingJob::finished,
this, [
this, router]() {
112 router->deleteLater();
113 if (m_routingJob == router) {
114 m_routeOverlay->setRoute(router->route());
115 m_routingJob =
nullptr;
124 m_routingJob = router;
129void RoutingController::buildNavMesh()
132 builder->setMapData(m_mapData);
133 builder->setEquipmentModel(m_elevatorModel);
134 connect(builder, &NavMeshBuilder::finished,
this, [
this, builder]() {
135 builder->deleteLater();
136 if (m_builder == builder) {
137 m_navMesh = builder->navMesh();
145 qWarning() <<
"Failed to generate nav mesh, routing not available!";
154#include "moc_routingcontroller.cpp"
A source for overlay elements, drawn on top of the static map data.
Raw OSM map data, separated by levels.
Job for building a navigation mesh for the given building.
bool isValid() const
Returns true if the nav mesh is neither null (ie.
bool routingInProgress() const
Indicates an ongoing routing or navmesh compilation process.
bool routingAvailable() const
Indicates that routing support is built-in at all.
Job for running a routing query on a compiled NavMesh instance.
Coordinate, stored as 1e7 * degree to avoid floating point precision issues, and offset to unsigned v...
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)