summaryrefslogtreecommitdiffstats
path: root/src/plugins/geoservices/osm/qgeotilefetcherosm.h
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@theqtcompany.com>2016-07-11 14:27:34 +0200
committerAlex Blasche <alexander.blasche@theqtcompany.com>2016-07-27 05:36:25 +0000
commit04762a9eecafc80ebeb90c06258de551d451497f (patch)
tree1ac1ff2d6ea9f9fb448fee41aca0f2a30a50eea1 /src/plugins/geoservices/osm/qgeotilefetcherosm.h
parent5adda3e6651f3d45838ece962a4ae656eac5af04 (diff)
Add indirection for osm providers
To prevent furter breakage of qtlocation osm provider in existing qt versions, this patch introduces one level of indirection in resolving OSM providers, fetching the tile server address from files hosted at http://maps-redirect.qt.io/osm/5.6/ The content of the files requested for the server address resolution must be in JSON format, containing (currently) the following fields: { "Enabled" : bool, (optional) "UrlTemplate" : "<url template>", (mandatory) "ImageFormat" : "<image format>", (mandatory) "MapCopyRight" : "<copyright>", (mandatory) "DataCopyRight" : "<copyright>", (mandatory) "MinimumZoomLevel" : <minimumZoomLevel>, (optional) "MaximumZoomLevel" : <maximumZoomLevel>, (optional) } Enabled is optional, and allows us to temporarily disable tile providers if they go offline without firing requests to them. Default is true. MinimumZoomLevel and MaximumZoomLevel are also optional, and allow us to prevent tile requests to the providers, if they do not support the specific ZL. Default is 0 and 19, respectively. <server address template> is required, and is the tile url template, with %x, %y and %z as placeholders for the actual parameters. Example: http://localhost:8080/maps/%z/%x/%y.png <image format> is required, and is the format of the tile. Example: "png" or "jpg" <MapCopyRight> is required and is the string that will be displayed in the "Map (c)" part of the on-screen copyright notice. example: "<a href='http://www.mapquest.com/'>MapQuest</a>" <DataCopyRight> is required and is the string that will be displayed in the "Data (c)" part of the on-screen copyright notice. example: "a href= 'http://www.openstreetmap.org/copyright'>OpenStreetMap</a> contributors" The patch also adds four additional OSM plugin parameters, modifies an existing ones, and removes another existing one. Removed: - osm.mapping.copyright, now removed and replaced by two other parameters (see below). New: - osm.mapping.providersrepository.address, allowing to change the hardcoded http://maps-redirect.qt.io/osm/5.6/ The implication of this parameter is that it becomes possible to use file:// urls or even qrc:, allowing to ship custom providers with the applicarions - osm.mapping.providersrepository.disabled, allowing to disable the indirection and go with hardcoded URLs by default. - osm.mapping.custom.mapcopyright replaces the old osm.mapping.copyright, and contains the copyright notice to be displayed next to the "Map (c)" part of the copyright, to be consistent with the way the copyright notice coming from the provider data is handled - osm.mapping.custom.datacopyright replaces the old osm.mapping.copyright, and contains the copyright notice to be displayed next to the "Data (c)" part of the copyright, to be consistent with the way the copyright notice coming from the provider data is handled Modified: - osm.mapping.host now became osm.mapping.custom.host, improving the naming consistency. Task-number: QTBUG-54599 Change-Id: Iee88883572a198c00bcf54cf2bc33fbcc0498a68 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/plugins/geoservices/osm/qgeotilefetcherosm.h')
-rw-r--r--src/plugins/geoservices/osm/qgeotilefetcherosm.h27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/plugins/geoservices/osm/qgeotilefetcherosm.h b/src/plugins/geoservices/osm/qgeotilefetcherosm.h
index 2f61f8f7..bee5b8e3 100644
--- a/src/plugins/geoservices/osm/qgeotilefetcherosm.h
+++ b/src/plugins/geoservices/osm/qgeotilefetcherosm.h
@@ -34,31 +34,48 @@
#ifndef QGEOTILEFETCHEROSM_H
#define QGEOTILEFETCHEROSM_H
+#include "qgeotileproviderosm.h"
#include <QtLocation/private/qgeotilefetcher_p.h>
+#include <QVector>
QT_BEGIN_NAMESPACE
-class QGeoTiledMappingManagerEngine;
class QNetworkAccessManager;
class QGeoTileFetcherOsm : public QGeoTileFetcher
{
Q_OBJECT
+ friend class QGeoMapReplyOsm;
+ friend class QGeoTiledMappingManagerEngineOsm;
public:
- QGeoTileFetcherOsm(QObject *parent = 0);
+ QGeoTileFetcherOsm(const QVector<QGeoTileProviderOsm *> &providers,
+ QNetworkAccessManager *nm,
+ QObject *parent = 0);
void setUserAgent(const QByteArray &userAgent);
- void setUrlPrefix(const QString &urlPrefix);
+
+Q_SIGNALS:
+ void providerDataUpdated(const QGeoTileProviderOsm *provider);
+
+protected:
+ bool initialized() const Q_DECL_OVERRIDE;
+
+protected Q_SLOTS:
+ void onProviderResolutionFinished(const QGeoTileProviderOsm *provider);
+ void onProviderResolutionError(const QGeoTileProviderOsm *provider, QNetworkReply::NetworkError error);
private:
QGeoTiledMapReply *getTileImage(const QGeoTileSpec &spec);
+ void readyUpdated();
- QNetworkAccessManager *m_networkManager;
QByteArray m_userAgent;
- QString m_urlPrefix;
+ QVector<QGeoTileProviderOsm *> m_providers;
+ QNetworkAccessManager *m_nm;
+ bool m_ready;
};
QT_END_NAMESPACE
#endif // QGEOTILEFETCHEROSM_H
+