3 #include <QNetworkAccessManager>
4 #include <QNetworkRequest>
5 #include <QNetworkReply>
13 return "http://overpass-api.de/api/interpreter";
25 : mServiceUrl( defaultServiceUrl() ), mReply( 0 )
46 mError =
tr(
"No query has been specified." );
52 mError =
tr(
"There is already a pending request for data." );
56 if ( !mFile.
open( QIODevice::WriteOnly | QIODevice::Truncate ) )
58 mError =
tr(
"Cannot open output file: %1" ).
arg( mFile.
fileName() );
64 QUrl url( mServiceUrl );
70 mReply = nwam->
get( request );
72 connect( mReply, SIGNAL( readyRead() ),
this, SLOT( onReadyRead() ) );
73 connect( mReply, SIGNAL( error( QNetworkReply::NetworkError ) ),
this, SLOT( onError( QNetworkReply::NetworkError ) ) );
91 void QgsOSMDownload::onReadyRead()
100 void QgsOSMDownload::onFinished()
102 qDebug(
"finished" );
114 void QgsOSMDownload::onError( QNetworkReply::NetworkError err )
116 qDebug(
"error: %d", err );
A rectangle specified with double values.
void downloadProgress(qint64, qint64)
normally the total length is not known (until we reach end)
QString errorString() const
double yMaximum() const
Get the y maximum value (top side of rectangle)
QString tr(const char *sourceText, const char *disambiguation, int n)
bool abort()
Aborts current pending request.
bool isFinished() const
Returns true if the request has already finished.
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
double xMaximum() const
Get the x maximum value (right side of rectangle)
void finished()
emitted when the network reply has finished (with success or with an error)
qint64 read(char *data, qint64 maxSize)
bool start()
Starts network request for data.
static QString queryFromRect(const QgsRectangle &rect)
Create query (in Overpass Query Language) that fetches everything in given rectangle.
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
static QgsNetworkAccessManager * instance()
returns a pointer to the single instance
static QString defaultServiceUrl()
Return URL of the service that is used by default.
qint64 write(const char *data, qint64 maxSize)
void addQueryItem(const QString &key, const QString &value)
QNetworkReply * get(const QNetworkRequest &request)
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
double xMinimum() const
Get the x minimum value (left side of rectangle)