17 #include <QNetworkAccessManager> 18 #include <QNetworkRequest> 19 #include <QNetworkReply> 27 return "http://overpass-api.de/api/interpreter";
61 mError =
tr(
"No query has been specified." );
67 mError =
tr(
"There is already a pending request for data." );
71 if ( !mFile.
open( QIODevice::WriteOnly | QIODevice::Truncate ) )
73 mError =
tr(
"Cannot open output file: %1" ).
arg( mFile.
fileName() );
79 QUrl url( mServiceUrl );
85 mReply = nwam->
get( request );
87 connect( mReply, SIGNAL( readyRead() ),
this, SLOT( onReadyRead() ) );
88 connect( mReply, SIGNAL( error( QNetworkReply::NetworkError ) ),
this, SLOT( onError( QNetworkReply::NetworkError ) ) );
106 void QgsOSMDownload::onReadyRead()
115 void QgsOSMDownload::onFinished()
117 qDebug(
"finished" );
129 void QgsOSMDownload::onError( QNetworkReply::NetworkError err )
131 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)
bool isFinished() const
Returns true if the request has already finished.
QString errorString() const
QString tr(const char *sourceText, const char *disambiguation, int n)
bool abort()
Aborts current pending request.
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)
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
double xMaximum() const
Get the x maximum value (right side of rectangle)
static QgsNetworkAccessManager * instance()
returns a pointer to the single instance
static QString defaultServiceUrl()
Return URL of the service that is used by default.
double xMinimum() const
Get the x minimum value (left side of rectangle)
qint64 write(const char *data, qint64 maxSize)
void addQueryItem(const QString &key, const QString &value)
double yMaximum() const
Get the y maximum value (top side of rectangle)
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
network access manager for QGIS