QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Signals | Public Member Functions | Static Public Member Functions | List of all members
QgsOSMDownload Class Reference

OSMDownload is a utility class for downloading OpenStreetMap via Overpass API. More...

#include <qgsosmdownload.h>

Signals

void downloadProgress (qint64, qint64)
 normally the total length is not known (until we reach end)
void finished ()
 emitted when the network reply has finished (with success or with an error)

Public Member Functions

 QgsOSMDownload ()
 ~QgsOSMDownload ()
bool abort ()
 Aborts current pending request.
QString errorString () const
bool hasError () const
bool isFinished () const
 Returns true if the request has already finished.
QString outputFileName () const
QString query () const
QString serviceUrl () const
void setOutputFileName (const QString &outputFileName)
void setQuery (const QString &query)
void setServiceUrl (const QString &serviceUrl)
bool start ()
 Starts network request for data.

Static Public Member Functions

static QString defaultServiceUrl ()
 Return URL of the service that is used by default.
static QString queryFromRect (const QgsRectangle &rect)
 Create query (in Overpass Query Language) that fetches everything in given rectangle.

Detailed Description

OSMDownload is a utility class for downloading OpenStreetMap via Overpass API.

To use this class, it is necessary to set query, output file name and start the request. The interface is asynchronous, the caller has to wait for finished() signal that is emitted whe the request has finished (successfully or with an error).

To check whether the the request has been successful, check hasError() and use errorString() to retreive error message. An error may happen either directly in start() method or during the network communication.

By default OSMDownload uses remote service at location returned by defaultServiceUrl() method.

Definition at line 39 of file qgsosmdownload.h.

Constructor & Destructor Documentation

QgsOSMDownload::QgsOSMDownload ( )

Definition at line 24 of file qgsosmdownload.cpp.

QgsOSMDownload::~QgsOSMDownload ( )

Definition at line 29 of file qgsosmdownload.cpp.

Member Function Documentation

bool QgsOSMDownload::abort ( )

Aborts current pending request.

Returns
true if there is a pending request and has been aborted, false otherwise

Definition at line 81 of file qgsosmdownload.cpp.

QString QgsOSMDownload::defaultServiceUrl ( )
static

Return URL of the service that is used by default.

Definition at line 11 of file qgsosmdownload.cpp.

void QgsOSMDownload::downloadProgress ( qint64  ,
qint64   
)
signal

normally the total length is not known (until we reach end)

QString QgsOSMDownload::errorString ( ) const
inline

Definition at line 63 of file qgsosmdownload.h.

void QgsOSMDownload::finished ( )
signal

emitted when the network reply has finished (with success or with an error)

bool QgsOSMDownload::hasError ( ) const
inline

Definition at line 62 of file qgsosmdownload.h.

bool QgsOSMDownload::isFinished ( ) const

Returns true if the request has already finished.

Definition at line 123 of file qgsosmdownload.cpp.

QString QgsOSMDownload::outputFileName ( ) const
inline

Definition at line 60 of file qgsosmdownload.h.

QString QgsOSMDownload::query ( ) const
inline

Definition at line 57 of file qgsosmdownload.h.

QString QgsOSMDownload::queryFromRect ( const QgsRectangle rect)
static

Create query (in Overpass Query Language) that fetches everything in given rectangle.

Definition at line 17 of file qgsosmdownload.cpp.

QString QgsOSMDownload::serviceUrl ( ) const
inline

Definition at line 54 of file qgsosmdownload.h.

void QgsOSMDownload::setOutputFileName ( const QString &  outputFileName)
inline

Definition at line 59 of file qgsosmdownload.h.

void QgsOSMDownload::setQuery ( const QString &  query)
inline

Definition at line 56 of file qgsosmdownload.h.

void QgsOSMDownload::setServiceUrl ( const QString &  serviceUrl)
inline

Definition at line 53 of file qgsosmdownload.h.

bool QgsOSMDownload::start ( )

Starts network request for data.

The prerequisite is that the query string and output file name have been set.

Only one request may be pending at one point - if you need more requests at once, use several instances.

Returns
true if the network request has been issued, false otherwise (and sets error string)

Definition at line 40 of file qgsosmdownload.cpp.


The documentation for this class was generated from the following files: