QGIS API Documentation  2.18.3-Las Palmas (77b8c3d)
qgsosmdownload.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsosmdownload.h
3  --------------------------------------
4  Date : January 2013
5  Copyright : (C) 2013 by Martin Dobias
6  Email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef OSMDOWNLOAD_H
17 #define OSMDOWNLOAD_H
18 
19 
20 #include <QObject>
21 #include <QFile>
22 #include <QNetworkReply>
23 
24 class QgsRectangle;
25 
39 class ANALYSIS_EXPORT QgsOSMDownload : public QObject
40 {
41  Q_OBJECT
42  public:
43 
45  static QString defaultServiceUrl();
46 
48  static QString queryFromRect( const QgsRectangle& rect );
49 
51  ~QgsOSMDownload();
52 
53  void setServiceUrl( const QString& serviceUrl ) { mServiceUrl = serviceUrl; }
54  QString serviceUrl() const { return mServiceUrl; }
55 
56  void setQuery( const QString& query ) { mQuery = query; }
57  QString query() const { return mQuery; }
58 
59  void setOutputFileName( const QString& outputFileName ) { mFile.setFileName( outputFileName ); }
60  QString outputFileName() const { return mFile.fileName(); }
61 
62  bool hasError() const { return !mError.isNull(); }
63  QString errorString() const { return mError; }
64 
73  bool start();
74 
79  bool abort();
80 
82  bool isFinished() const;
83 
84  signals:
85  void finished();
86  void downloadProgress( qint64, qint64 );
87 
88  private slots:
89  void onReadyRead();
90  void onFinished();
91  void onError( QNetworkReply::NetworkError err );
92 
93  private:
94  QString mServiceUrl;
95  QString mQuery;
96  QString mError;
97 
98  QNetworkReply* mReply;
99  QFile mFile;
100 };
101 
102 #endif // OSMDOWNLOAD_H
QString query() const
void setOutputFileName(const QString &outputFileName)
void setQuery(const QString &query)
A rectangle specified with double values.
Definition: qgsrectangle.h:35
OSMDownload is a utility class for downloading OpenStreetMap via Overpass API.
QString outputFileName() const
bool hasError() const
QString errorString() const
QString serviceUrl() const
void setServiceUrl(const QString &serviceUrl)