KOSMIndoorMap

navmesh-dump.cpp
1/*
2 SPDX-FileCopyrightText: 2024 Volker Krause <vkrause@kde.org>
3 SPDX-License-Identifier: LGPL-2.0-or-later
4*/
5
6#include <KOSMIndoorRouting/NavMesh>
7#include <KOSMIndoorRouting/NavMeshBuilder>
8
9#include <KOSMIndoorMap/EquipmentModel>
10#include <KOSMIndoorMap/MapData>
11#include <KOSMIndoorMap/MapLoader>
12
13#include <osm/datatypes.h>
14#include <osm/io.h>
15
16#include <QCommandLineParser>
17#include <QCoreApplication>
18#include <QDebug>
19#include <QFile>
20
21using namespace KOSMIndoorMap;
22using namespace KOSMIndoorRouting;
23
24int main(int argc, char **argv)
25{
26 QCoreApplication app(argc, argv);
27 QCommandLineParser parser;
28 QCommandLineOption pointOpt({QStringLiteral("p"), QStringLiteral("point")}, QStringLiteral("download area around point"), QStringLiteral("lat,lon"));
29 parser.addOption(pointOpt);
30 QCommandLineOption outputOpt({QStringLiteral("o"), QStringLiteral("output")}, QStringLiteral("output path"), QStringLiteral("directory"));
31 parser.addOption(outputOpt);
32 QCommandLineOption nameOpt({QStringLiteral("n"), QStringLiteral("name")}, QStringLiteral("output name"), QStringLiteral("name"));
33 parser.addOption(nameOpt);
34 parser.addHelpOption();
35 parser.process(app);
36
37 const auto coords = QStringView(parser.value(pointOpt)).split(QLatin1Char(','));
38 if (coords.size() != 2) {
39 qCritical() << "Invalid coordinate!";
40 return 1;
41 }
42 OSM::Coordinate coord{coords[0].toDouble(), coords[1].toDouble()};
43
44 MapLoader loader;
45 loader.loadForCoordinate(coord.latF(), coord.lonF());
46
49 auto data = loader.takeData();
50
51 // TODO use RealtimeEquipmentModel
52 KOSMIndoorMap::EquipmentModel equipmentModel;
53 equipmentModel.setMapData(data);
54
56 navMeshBuilder.setMapData(data);
57 navMeshBuilder.setEquipmentModel(&equipmentModel);
58 navMeshBuilder.writeDebugNavMesh(parser.value(outputOpt) + QLatin1Char('/') + parser.value(nameOpt) + QLatin1String(".gset"), parser.value(outputOpt) + QLatin1Char('/') + parser.value(nameOpt) + QLatin1String(".obj"));
59 navMeshBuilder.start();
60 QObject::connect(&navMeshBuilder, &NavMeshBuilder::finished, &app, [&] {
61 navMeshBuilder.navMesh().writeToFile(parser.value(outputOpt) + QLatin1Char('/') + parser.value(nameOpt) + QLatin1String(".bin"));
63 });
65}
Overlay source for elevators and escalators.
Loader for OSM data for a single station or airport.
Definition maploader.h:29
void done()
Emitted when the requested data has been loaded.
Q_INVOKABLE void loadForCoordinate(double lat, double lon)
Load map for the given coordinates.
MapData && takeData()
Take out the completely loaded result.
Job for building a navigation mesh for the given building.
void writeToFile(const QString &fileName) const
Write nav mesh data to the given file.
Definition navmesh.cpp:58
Coordinate, stored as 1e7 * degree to avoid floating point precision issues, and offset to unsigned v...
Definition datatypes.h:37
OSM-based multi-floor indoor maps for buildings.
QCommandLineOption addHelpOption()
bool addOption(const QCommandLineOption &option)
void process(const QCoreApplication &app)
QString value(const QCommandLineOption &option) const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QList< QStringView > split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:55:43 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.