KOSMIndoorMap

overpassquery.h
1 /*
2  SPDX-FileCopyrightText: 2020 Volker Krause <[email protected]>
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 
17 class QNetworkReply;
18 
19 namespace 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  */
25 class KOSM_EXPORT OverpassQuery : public QObject
26 {
27  Q_OBJECT
28 public:
29  explicit OverpassQuery(QObject *parent = nullptr);
30  ~OverpassQuery();
31 
32  /** Returns the raw (without bbox replacement) query string. */
33  QString query() const;
34  /** Returns the query with @p bbox applied. */
35  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  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  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  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  Error error() const;
70 
71  /** Query result data set. */
72  const DataSet& result() const;
73  DataSet&& takeResult();
74 
75 Q_SIGNALS:
76  void finished();
77 
78 private:
79  friend class OverpassQueryManager;
80  friend class OverpassQueryManagerPrivate;
81 
82  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
Error
Error codes.
Definition: overpassquery.h:62
Executes OverpassQuery jobs.
generic query error
Definition: overpassquery.h:64
query exceeded its execution time budget
Definition: overpassquery.h:65
An Overpass QL query job, to be executed by OverpassQueryManager.
Definition: overpassquery.h:25
A set of nodes, ways and relations.
Definition: datatypes.h:283
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-2021 The KDE developers.
Generated on Mon Oct 25 2021 23:04:00 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.