summaryrefslogtreecommitdiff
path: root/src/plugins/geoservices
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/geoservices')
-rw-r--r--src/plugins/geoservices/osm/osm.pro2
-rw-r--r--src/plugins/geoservices/osm/qgeomapreplyosm.cpp11
-rw-r--r--src/plugins/geoservices/osm/qgeotiledmapdataosm.cpp84
-rw-r--r--src/plugins/geoservices/osm/qgeotiledmapdataosm.h59
-rw-r--r--src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp13
-rw-r--r--src/plugins/geoservices/osm/qgeotilefetcherosm.cpp45
6 files changed, 185 insertions, 29 deletions
diff --git a/src/plugins/geoservices/osm/osm.pro b/src/plugins/geoservices/osm/osm.pro
index f8744061..aa24fbc9 100644
--- a/src/plugins/geoservices/osm/osm.pro
+++ b/src/plugins/geoservices/osm/osm.pro
@@ -8,6 +8,7 @@ load(qt_plugin)
HEADERS += \
qgeoserviceproviderpluginosm.h \
qgeotiledmappingmanagerengineosm.h \
+ qgeotiledmapdataosm.h \
qgeotilefetcherosm.h \
qgeomapreplyosm.h \
qgeocodingmanagerengineosm.h \
@@ -19,6 +20,7 @@ HEADERS += \
SOURCES += \
qgeoserviceproviderpluginosm.cpp \
qgeotiledmappingmanagerengineosm.cpp \
+ qgeotiledmapdataosm.cpp \
qgeotilefetcherosm.cpp \
qgeomapreplyosm.cpp \
qgeocodingmanagerengineosm.cpp \
diff --git a/src/plugins/geoservices/osm/qgeomapreplyosm.cpp b/src/plugins/geoservices/osm/qgeomapreplyosm.cpp
index b0c06f22..0d061c0a 100644
--- a/src/plugins/geoservices/osm/qgeomapreplyosm.cpp
+++ b/src/plugins/geoservices/osm/qgeomapreplyosm.cpp
@@ -76,16 +76,7 @@ void QGeoMapReplyOsm::networkReplyFinished()
QByteArray a = m_reply->readAll();
setMapImageData(a);
- switch (tileSpec().mapId()) {
- case 1:
- setMapImageFormat("png");
- break;
- case 2:
- setMapImageFormat("png");
- break;
- default:
- qWarning("Unknown map id %d", tileSpec().mapId());
- }
+ setMapImageFormat("png");
setFinished(true);
diff --git a/src/plugins/geoservices/osm/qgeotiledmapdataosm.cpp b/src/plugins/geoservices/osm/qgeotiledmapdataosm.cpp
new file mode 100644
index 00000000..5b9173cb
--- /dev/null
+++ b/src/plugins/geoservices/osm/qgeotiledmapdataosm.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Aaron McCarthy <mccarthy.aaron@gmail.com>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeotiledmapdataosm.h"
+#include "qgeotiledmappingmanagerengineosm.h"
+
+#include <QtLocation/private/qgeotilespec_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QGeoTiledMapDataOsm::QGeoTiledMapDataOsm(QGeoTiledMappingManagerEngineOsm *engine, QObject *parent)
+: QGeoTiledMapData(engine, parent), m_mapId(-1)
+{
+}
+
+QGeoTiledMapDataOsm::~QGeoTiledMapDataOsm()
+{
+}
+
+void QGeoTiledMapDataOsm::evaluateCopyrights(const QSet<QGeoTileSpec> &visibleTiles)
+{
+ if (visibleTiles.isEmpty())
+ return;
+
+ QGeoTileSpec tile = *visibleTiles.constBegin();
+ if (tile.mapId() == m_mapId)
+ return;
+
+ m_mapId = tile.mapId();
+
+ QString copyrights;
+ switch (m_mapId) {
+ case 1:
+ case 2:
+ // set attribution to Map Quest
+ copyrights = tr("Tiles Courtesy of <a href='http://www.mapquest.com/'>MapQuest</a><br/>Data \u00a9 <a href='http://www.openstreetmap.org/copyright'>OpenStreetMap</a> contributors");
+ break;
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ // set attribution to Thunder Forest
+ copyrights = tr("Maps \u00a9 <a href='http://www.thunderforest.com/'>Thunderforest</a><br/>Data \u00a9 <a href='http://www.openstreetmap.org/copyright'>OpenStreetMap</a> contributors");
+ break;
+ default:
+ // set attribution to OSM
+ copyrights = tr("\u00a9 <a href='http://www.openstreetmap.org/copyright'>OpenStreetMap</a> contributors");
+ }
+
+ emit copyrightsChanged(copyrights);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/osm/qgeotiledmapdataosm.h b/src/plugins/geoservices/osm/qgeotiledmapdataosm.h
new file mode 100644
index 00000000..ffd24dc2
--- /dev/null
+++ b/src/plugins/geoservices/osm/qgeotiledmapdataosm.h
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Aaron McCarthy <mccarthy.aaron@gmail.com>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOTILEDMAPDATAOSM_H
+#define QGEOTILEDMAPDATAOSM_H
+
+#include <QtLocation/private/qgeotiledmapdata_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QGeoTiledMappingManagerEngineOsm;
+class QGeoTiledMapDataOsm: public QGeoTiledMapData
+{
+ Q_OBJECT
+
+public:
+ QGeoTiledMapDataOsm(QGeoTiledMappingManagerEngineOsm *engine, QObject *parent = 0);
+ ~QGeoTiledMapDataOsm();
+
+protected:
+ void evaluateCopyrights(const QSet<QGeoTileSpec> &visibleTiles) Q_DECL_OVERRIDE;
+
+private:
+ int m_mapId;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp b/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp
index e549007f..4e018f51 100644
--- a/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp
+++ b/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp
@@ -33,6 +33,7 @@
#include "qgeotiledmappingmanagerengineosm.h"
#include "qgeotilefetcherosm.h"
+#include "qgeotiledmapdataosm.h"
#include <QtLocation/private/qgeocameracapabilities_p.h>
#include <QtLocation/private/qgeomaptype_p.h>
@@ -51,8 +52,14 @@ QGeoTiledMappingManagerEngineOsm::QGeoTiledMappingManagerEngineOsm(const QVarian
setTileSize(QSize(256, 256));
QList<QGeoMapType> mapTypes;
- mapTypes << QGeoMapType(QGeoMapType::StreetMap, tr("Street Map"), tr("OpenStreetMap street map"), false, false, 1);
- mapTypes << QGeoMapType(QGeoMapType::SatelliteMapDay, tr("Satellite Map"), tr("OpenStreetMap satellite map"), false, false, 2);
+ // See map type implementations in QGeoTiledMapDataOsm and QGeoTileFetcherOsm.
+ mapTypes << QGeoMapType(QGeoMapType::StreetMap, tr("Street Map"), tr("Street map view in daylight mode"), false, false, 1);
+ mapTypes << QGeoMapType(QGeoMapType::SatelliteMapDay, tr("Satellite Map"), tr("Satellite map view in daylight mode"), false, false, 2);
+ mapTypes << QGeoMapType(QGeoMapType::CycleMap, tr("Cycle Map"), tr("Cycle map view in daylight mode"), false, false, 3);
+ mapTypes << QGeoMapType(QGeoMapType::TransitMap, tr("Transit Map"), tr("Public transit map view in daylight mode"), false, false, 4);
+ mapTypes << QGeoMapType(QGeoMapType::TransitMap, tr("Night Transit Map"), tr("Public transit map view in night mode"), false, true, 5);
+ mapTypes << QGeoMapType(QGeoMapType::TerrainMap, tr("Terrain Map"), tr("Terrain map view"), false, false, 6);
+ mapTypes << QGeoMapType(QGeoMapType::PedestrianMap, tr("Hiking Map"), tr("Hiking map view"), false, false, 7);
setSupportedMapTypes(mapTypes);
QGeoTileFetcherOsm *tileFetcher = new QGeoTileFetcherOsm(this);
@@ -73,7 +80,7 @@ QGeoTiledMappingManagerEngineOsm::~QGeoTiledMappingManagerEngineOsm()
QGeoMapData *QGeoTiledMappingManagerEngineOsm::createMapData()
{
- return new QGeoTiledMapData(this, 0);
+ return new QGeoTiledMapDataOsm(this);
}
QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/osm/qgeotilefetcherosm.cpp b/src/plugins/geoservices/osm/qgeotilefetcherosm.cpp
index 32f05030..10fd1709 100644
--- a/src/plugins/geoservices/osm/qgeotilefetcherosm.cpp
+++ b/src/plugins/geoservices/osm/qgeotilefetcherosm.cpp
@@ -56,25 +56,38 @@ QGeoTiledMapReply *QGeoTileFetcherOsm::getTileImage(const QGeoTileSpec &spec)
QNetworkRequest request;
request.setRawHeader("User-Agent", m_userAgent);
+ QString urlPrefix;
+
switch (spec.mapId()) {
- case 1:
- // opensteetmap.org street map
- request.setUrl(QUrl(QStringLiteral("http://otile1.mqcdn.com/tiles/1.0.0/map/") +
- QString::number(spec.zoom()) + QLatin1Char('/') +
- QString::number(spec.x()) + QLatin1Char('/') +
- QString::number(spec.y()) + QStringLiteral(".png")));
- break;
- case 2:
- // opensteetmap.org satellite map
- request.setUrl(QUrl(QStringLiteral("http://otile1.mqcdn.com/tiles/1.0.0/sat/") +
- QString::number(spec.zoom()) + QLatin1Char('/') +
- QString::number(spec.x()) + QLatin1Char('/') +
- QString::number(spec.y()) + QStringLiteral(".png")));
- break;
- default:
- qWarning("Unknown map id %d\n", spec.mapId());
+ case 1:
+ urlPrefix = QStringLiteral("http://otile1.mqcdn.com/tiles/1.0.0/map/");
+ break;
+ case 2:
+ urlPrefix = QStringLiteral("http://otile1.mqcdn.com/tiles/1.0.0/sat/");
+ break;
+ case 3:
+ urlPrefix = QStringLiteral("http://a.tile.thunderforest.com/cycle/");
+ break;
+ case 4:
+ urlPrefix = QStringLiteral("http://a.tile.thunderforest.com/transport/");
+ break;
+ case 5:
+ urlPrefix = QStringLiteral("http://a.tile.thunderforest.com/transport-dark/");
+ break;
+ case 6:
+ urlPrefix = QStringLiteral("http://a.tile.thunderforest.com/landscape/");
+ break;
+ case 7:
+ urlPrefix = QStringLiteral("http://a.tile.thunderforest.com/outdoors/");
+ break;
+ default:
+ qWarning("Unknown map id %d\n", spec.mapId());
}
+ request.setUrl(QUrl(urlPrefix + QString::number(spec.zoom()) + QLatin1Char('/') +
+ QString::number(spec.x()) + QLatin1Char('/') +
+ QString::number(spec.y()) + QStringLiteral(".png")));
+
QNetworkReply *reply = m_networkManager->get(request);
return new QGeoMapReplyOsm(reply, spec);