KOSMIndoorMap

maploader.h
1/*
2 SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef KOSMINDOORMAP_MAPLOADER_H
8#define KOSMINDOORMAP_MAPLOADER_H
9
10#include "kosmindoormap_export.h"
11
12#include <QObject>
13
14#include <memory>
15
16namespace OSM {
17class BoundingBox;
18}
19
20/** OSM-based multi-floor indoor maps for buildings. */
21namespace KOSMIndoorMap {
22
23class MapData;
24class MapLoaderPrivate;
25class Tile;
26
27/** Loader for OSM data for a single station or airport. */
28class KOSMINDOORMAP_EXPORT MapLoader : public QObject
29{
30 Q_OBJECT
31 /** Indicates we are downloading content. Use for progress display. */
32 Q_PROPERTY(bool isLoading READ isLoading NOTIFY isLoadingChanged)
33public:
34 explicit MapLoader(QObject *parent = nullptr);
35 ~MapLoader();
36
37 /** Load a single O5M or OSM PBF file. */
38 Q_INVOKABLE void loadFromFile(const QString &fileName);
39 /** Load map for the given coordinates.
40 * This can involve online access.
41 */
42 Q_INVOKABLE void loadForCoordinate(double lat, double lon);
43 /** Same as the above, but ensureing the requested data is cached until @p ttl. */
44 void loadForCoordinate(double lat, double lon, const QDateTime &ttl);
45
46 /** Load map data for the given bounding box, without applying the boundary search. */
47 void loadForBoundingBox(OSM::BoundingBox box);
48 /** QML-compatible overload of the above. */
49 Q_INVOKABLE void loadForBoundingBox(double minLat, double minLon, double maxLat, double maxLon);
50
51 /** Load map data for the given tile. */
52 void loadForTile(Tile tile);
53
54 /** Add a changeset to be applied on top of the data loaded by any of the load() methods.
55 * Needs to be called after any of the load methods and before returning to the event loop.
56 * @param url can be a local file or a HTTP URL which is downloaded if needed.
57 */
58 Q_INVOKABLE void addChangeSet(const QUrl &url);
59
60 /** Take out the completely loaded result.
61 * Do this before loading the next map with the same loader.
62 */
63 MapData&& takeData();
64
65 [[nodiscard]] bool isLoading() const;
66
67 [[nodiscard]] bool hasError() const;
68 [[nodiscard]] QString errorMessage() const;
69
70Q_SIGNALS:
71 /** Emitted when the requested data has been loaded. */
72 void done();
73 void isLoadingChanged();
74
75private:
76 void downloadTiles();
77 void downloadFinished();
78 void downloadFailed(Tile tile, const QString &errorMessage);
79 void loadTiles();
80 [[nodiscard]] Tile makeTile(uint32_t x, uint32_t y) const;
81 void applyNextChangeSet();
82 void applyChangeSet(const QUrl &url, QIODevice *io);
83
84 std::unique_ptr<MapLoaderPrivate> d;
85};
86
87}
88
89#endif // KOSMINDOORMAP_MAPLOADER_H
Raw OSM map data, separated by levels.
Definition mapdata.h:60
Loader for OSM data for a single station or airport.
Definition maploader.h:29
void done()
Emitted when the requested data has been loaded.
Bounding box, ie.
Definition datatypes.h:95
OSM-based multi-floor indoor maps for buildings.
Low-level types and functions to work with raw OSM data as efficiently as possible.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:55:21 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.