KOSMIndoorMap

overpassquery.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 OSM_OVERPASSQUERY_H
8#define OSM_OVERPASSQUERY_H
9
10#include "kosm_export.h"
11
12#include "datatypes.h"
13
14#include <QObject>
15#include <QRectF>
16
17class QNetworkReply;
18
19namespace OSM {
20
21/** An Overpass QL query job, to be executed by OverpassQueryManager.
22 * @note Use this wrongly can cause excessive load on Overpass servers,
23 * so only use this when you know what you are doing!
24 */
25class KOSM_EXPORT OverpassQuery : public QObject
26{
27 Q_OBJECT
28public:
29 explicit OverpassQuery(QObject *parent = nullptr);
31
32 /** Returns the raw (without bbox replacement) query string. */
33 [[nodiscard]] QString query() const;
34 /** Returns the query with @p bbox applied. */
35 [[nodiscard]] QString query(const QRectF &bbox) const;
36 /** Overpass QL query string.
37 * Can contain the '{{bbox}}' bounding box placeholder also supported by Overpass Turbo.
38 */
39 void setQuery(const QString &query);
40
41 /** Bounding box for this query, values in degree. */
42 [[nodiscard]] QRectF boundingBox() const;
43 /** Set the bounding box for this query, values in degree. */
44 void setBoundingBox(const QRectF &bbox);
45
46 /** Tile size in which the bounding box is broken down for querying.
47 * Values in degree.
48 */
49 [[nodiscard]] QSizeF tileSize() const;
50 /** Sets the tile size in which the bounding box is broken down for querying.
51 * Values in degree.
52 */
53 void setTileSize(const QSizeF &tileSize);
54 /** Minimum tile size to which tiles can be broken down in case of query timeouts. */
55 [[nodiscard]] QSizeF minimumTileSize() const;
56 /** Sets the minimum tile size.
57 * Should be smaller than tile size by a power of 2.
58 */
59 void setMinimumTileSize(const QSizeF &minTileSize);
60
61 /** Error codes. */
62 enum Error {
63 NoError,
64 QueryError, ///< generic query error
65 QueryTimeout, ///< query exceeded its execution time budget
66 NetworkError,
67 };
68 /** Error code of this query job. */
69 [[nodiscard]] Error error() const;
70
71 /** Query result data set. */
72 [[nodiscard]] const DataSet& result() const;
73 [[nodiscard]] DataSet&& takeResult();
74
75Q_SIGNALS:
76 void finished();
77
78private:
79 friend class OverpassQueryManager;
80 friend class OverpassQueryManagerPrivate;
81
82 [[nodiscard]] Error processReply(QNetworkReply *reply);
83
84 QString m_query;
85 QRectF m_bbox = { -180.0, -90.0, 360.0, 180.0 };
86 QSizeF m_tileSize = { 360.0, 180.0 };
87 QSizeF m_minimumTileSize = { 1.0, 1.0 };
88 Error m_error = NoError;
89 OSM::DataSet m_result;
90};
91
92}
93
94#endif // OSM_OVERPASSQUERY_H
A set of nodes, ways and relations.
Definition datatypes.h:340
Executes OverpassQuery jobs.
An Overpass QL query job, to be executed by OverpassQueryManager.
@ QueryTimeout
query exceeded its execution time budget
@ QueryError
generic query error
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 Tue Mar 26 2024 11:20:03 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.