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;
61 m_start = OSM::Coordinate{lat, lon};
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;
69 m_end = OSM::Coordinate{lat, lon};
70 m_endLevel = floorLevel;
71 m_routeOverlay->setEnd(m_end, m_endLevel);
74KOSMIndoorMap::AbstractOverlaySource* RoutingController::routeOverlay()
const
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()) {
100 if (!m_navMesh.isValid()) {
106 auto router =
new RoutingJob(
this);
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;
118 if (!m_navMesh.isValid()) {
124 m_routingJob = router;
129void RoutingController::buildNavMesh()
131 auto builder =
new NavMeshBuilder(
this);
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();
142 if (m_navMesh.isValid()) {
145 qWarning() <<
"Failed to generate nav mesh, routing not available!";
154#include "moc_routingcontroller.cpp"
Raw OSM map data, separated by levels.
bool routingInProgress() const
Indicates an ongoing routing or navmesh compilation process.
bool routingAvailable() const
Indicates that routing support is built-in at all.
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)