Commit 86f9a219 authored by dogmaphobic's avatar dogmaphobic

Adding url factory from Open Pilot maps.

As this is no longer google specific, renamed everything google to qgc.
parent 3edd02a3
TARGET = qtgeoservices_google
CONFIG += static
QT += location-private positioning-private network
PLUGIN_TYPE = geoservices
PLUGIN_CLASS_NAME = QGeoServiceProviderFactoryGoogle
load(qt_plugin)
INCLUDEPATH += $$QT.location.includes
HEADERS += \
$$PWD/src/qgeoserviceproviderplugingoogle.h \
$$PWD/src/qgeotiledmappingmanagerenginegoogle.h \
$$PWD/src/qgeotilefetchergoogle.h \
$$PWD/src/qgeomapreplygoogle.h \
$$PWD/src/qgeocodingmanagerenginegoogle.h \
$$PWD/src/qgeocodereplygoogle.h
SOURCES += \
$$PWD/src/qgeoserviceproviderplugingoogle.cpp \
$$PWD/src/qgeotiledmappingmanagerenginegoogle.cpp \
$$PWD/src/qgeotilefetchergoogle.cpp \
$$PWD/src/qgeomapreplygoogle.cpp \
$$PWD/src/qgeocodingmanagerenginegoogle.cpp \
$$PWD/src/qgeocodereplygoogle.cpp
OTHER_FILES += \
$$PWD/google_maps_plugin.json
TARGET = qtgeoservices_qgc
CONFIG += static
QT += location-private positioning-private network
PLUGIN_TYPE = geoservices
PLUGIN_CLASS_NAME = QGeoServiceProviderFactoryQGC
load(qt_plugin)
INCLUDEPATH += $$QT.location.includes
HEADERS += \
$$PWD/src/qgeoserviceproviderpluginqgc.h \
$$PWD/src/qgeotiledmappingmanagerengineqgc.h \
$$PWD/src/qgeotilefetcherqgc.h \
$$PWD/src/qgeomapreplyqgc.h \
$$PWD/src/qgeocodingmanagerengineqgc.h \
$$PWD/src/qgeocodereplyqgc.h \
$$PWD/src/OpenPilotMaps.h
SOURCES += \
$$PWD/src/qgeoserviceproviderpluginqgc.cpp \
$$PWD/src/qgeotiledmappingmanagerengineqgc.cpp \
$$PWD/src/qgeotilefetcherqgc.cpp \
$$PWD/src/qgeomapreplyqgc.cpp \
$$PWD/src/qgeocodingmanagerengineqgc.cpp \
$$PWD/src/qgeocodereplyqgc.cpp \
$$PWD/src/OpenPilotMaps.cc
OTHER_FILES += \
$$PWD/qgc_maps_plugin.json
{
"Keys": ["google-maps"],
"Provider": "google",
"Version": 100,
"Keys": ["qgc-maps"],
"Provider": "QGroundControl",
"Version": 101,
"Experimental": false,
"Features": [
"OnlineMappingFeature",
......
This diff is collapsed.
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief QGC Open Pilot Mapping Tools
* @author Gus Grubba <mavlink@grubba.com>
* Original work: The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
*/
#ifndef OPENPILOTTOOLS_H
#define OPENPILOTTOOLS_H
#include <QString>
#include <Qpoint>
#include <QByteArray>
#include <QNetworkProxy>
namespace OpenPilot {
enum MapType
{
GoogleMap = 1,
GoogleSatellite = 4,
GoogleLabels = 8,
GoogleTerrain = 16,
GoogleHybrid = 20,
GoogleMapChina = 22,
GoogleSatelliteChina = 24,
GoogleLabelsChina = 26,
GoogleTerrainChina = 28,
GoogleHybridChina = 29,
OpenStreetMap = 32,
OpenStreetOsm = 33,
OpenStreetMapSurfer = 34,
OpenStreetMapSurferTerrain=35,
YahooMap = 64,
YahooSatellite = 128,
YahooLabels = 256,
YahooHybrid = 333,
BingMap = 444,
BingSatellite = 555,
BingHybrid = 666,
ArcGIS_Map = 777,
ArcGIS_Satellite = 788,
ArcGIS_ShadedRelief = 799,
ArcGIS_Terrain = 811,
ArcGIS_MapsLT_Map = 1000,
ArcGIS_MapsLT_OrtoFoto = 1001,
ArcGIS_MapsLT_Map_Labels= 1002,
ArcGIS_MapsLT_Map_Hybrid= 1003,
PergoTurkeyMap = 2001,
SigPacSpainMap = 3001,
GoogleMapKorea = 4001,
GoogleSatelliteKorea = 4002,
GoogleLabelsKorea = 4003,
GoogleHybridKorea = 4005,
YandexMapRu = 5000
};
class ProviderStrings {
public:
ProviderStrings();
static const QString levelsForSigPacSpainMap[];
QString GoogleMapsAPIKey;
// Google version strings
QString VersionGoogleMap;
QString VersionGoogleSatellite;
QString VersionGoogleLabels;
QString VersionGoogleTerrain;
QString SecGoogleWord;
// Google (China) version strings
QString VersionGoogleMapChina;
QString VersionGoogleSatelliteChina;
QString VersionGoogleLabelsChina;
QString VersionGoogleTerrainChina;
// Google (Korea) version strings
QString VersionGoogleMapKorea;
QString VersionGoogleSatelliteKorea;
QString VersionGoogleLabelsKorea;
/// <summary>
/// Google Maps API generated using http://greatmaps.codeplex.com/
/// from http://code.google.com/intl/en-us/apis/maps/signup.html
/// </summary>
// Yahoo version strings
QString VersionYahooMap;
QString VersionYahooSatellite;
QString VersionYahooLabels;
// BingMaps
QString VersionBingMaps;
// YandexMap
QString VersionYandexMap;
/// <summary>
/// Bing Maps Customer Identification, more info here
/// http://msdn.microsoft.com/en-us/library/bb924353.aspx
/// </summary>
QString BingMapsClientToken;
};
class UrlFactory : public QObject, public ProviderStrings {
Q_OBJECT
public:
QByteArray UserAgent;
QNetworkProxy Proxy;
UrlFactory();
~UrlFactory();
QString makeImageUrl (const MapType &type, const QPoint &pos, const int &zoom, const QString &language);
private:
void _getSecGoogleWords (const QPoint &pos, QString &sec1, QString &sec2);
int _getServerNum (const QPoint& pos, const int &max) const;
void _tryCorrectGoogleVersions ();
QString _tileXYToQuadKey (const int &tileX, const int &tileY, const int &levelOfDetail) const;
bool _isCorrectedGoogleVersions;
bool _correctGoogleVersions;
int _timeout;
QMutex mutex;
static const double EarthRadiusKm;
};
}
#endif // FOO_H
......@@ -38,7 +38,7 @@
** $QT_END_LICENSE$
**
** 2015.4.4
** Adapted for google maps with the intent of use for QGroundControl
** Adapted for use with QGroundControl
**
** Gus Grubba <mavlink@grubba.com>
**
......@@ -53,7 +53,7 @@
#include <QtPositioning/QGeoRectangle>
#include <unordered_map>
#include "qgeocodereplygoogle.h"
#include "qgeocodereplyqgc.h"
QT_BEGIN_NAMESPACE
......@@ -156,7 +156,7 @@ QSet<int> JasonMonger::json2QGeoCodeTypeGoogle(const QJsonArray &types) {
JasonMonger kMonger;
QGeoCodeReplyGoogle::QGeoCodeReplyGoogle(QNetworkReply *reply, QObject *parent)
QGeoCodeReplyQGC::QGeoCodeReplyQGC(QNetworkReply *reply, QObject *parent)
: QGeoCodeReply(parent), m_reply(reply)
{
connect(m_reply, SIGNAL(finished()), this, SLOT(networkReplyFinished()));
......@@ -167,13 +167,13 @@ QGeoCodeReplyGoogle::QGeoCodeReplyGoogle(QNetworkReply *reply, QObject *parent)
setOffset(0);
}
QGeoCodeReplyGoogle::~QGeoCodeReplyGoogle()
QGeoCodeReplyQGC::~QGeoCodeReplyQGC()
{
if (m_reply)
m_reply->deleteLater();
}
void QGeoCodeReplyGoogle::abort()
void QGeoCodeReplyQGC::abort()
{
if (!m_reply)
return;
......@@ -184,7 +184,7 @@ void QGeoCodeReplyGoogle::abort()
m_reply = 0;
}
void QGeoCodeReplyGoogle::networkReplyFinished()
void QGeoCodeReplyQGC::networkReplyFinished()
{
if (!m_reply)
return;
......@@ -288,7 +288,7 @@ void QGeoCodeReplyGoogle::networkReplyFinished()
m_reply = 0;
}
void QGeoCodeReplyGoogle::networkReplyError(QNetworkReply::NetworkError error)
void QGeoCodeReplyQGC::networkReplyError(QNetworkReply::NetworkError error)
{
Q_UNUSED(error)
if (!m_reply)
......
......@@ -38,7 +38,7 @@
** $QT_END_LICENSE$
**
** 2015.4.4
** Adapted for google maps with the intent of use for QGroundControl
** Adapted for use with QGroundControl
**
** Gus Grubba <mavlink@grubba.com>
**
......@@ -52,13 +52,13 @@
QT_BEGIN_NAMESPACE
class QGeoCodeReplyGoogle : public QGeoCodeReply
class QGeoCodeReplyQGC : public QGeoCodeReply
{
Q_OBJECT
public:
explicit QGeoCodeReplyGoogle(QNetworkReply *reply, QObject *parent = 0);
~QGeoCodeReplyGoogle();
explicit QGeoCodeReplyQGC(QNetworkReply *reply, QObject *parent = 0);
~QGeoCodeReplyQGC();
void abort();
......
......@@ -38,7 +38,7 @@
** $QT_END_LICENSE$
**
** 2015.4.4
** Adapted for google maps with the intent of use for QGroundControl
** Adapted for use with QGroundControl
**
** Gus Grubba <mavlink@grubba.com>
**
......@@ -55,8 +55,8 @@
#include <QtPositioning/QGeoShape>
#include <QtPositioning/QGeoRectangle>
#include "qgeocodingmanagerenginegoogle.h"
#include "qgeocodereplygoogle.h"
#include "qgeocodingmanagerengineqgc.h"
#include "qgeocodereplyqgc.h"
QT_BEGIN_NAMESPACE
......@@ -77,7 +77,7 @@ static QString boundingBoxToLtrb(const QGeoRectangle &rect)
QString::number(rect.bottomRight().latitude());
}
QGeoCodingManagerEngineGoogle::QGeoCodingManagerEngineGoogle(
QGeoCodingManagerEngineQGC::QGeoCodingManagerEngineQGC(
const QVariantMap &parameters,
QGeoServiceProvider::Error *error,
QString *errorString)
......@@ -91,16 +91,16 @@ QGeoCodingManagerEngineGoogle::QGeoCodingManagerEngineGoogle(
errorString->clear();
}
QGeoCodingManagerEngineGoogle::~QGeoCodingManagerEngineGoogle()
QGeoCodingManagerEngineQGC::~QGeoCodingManagerEngineQGC()
{
}
QGeoCodeReply *QGeoCodingManagerEngineGoogle::geocode(const QGeoAddress &address, const QGeoShape &bounds)
QGeoCodeReply *QGeoCodingManagerEngineQGC::geocode(const QGeoAddress &address, const QGeoShape &bounds)
{
return geocode(addressToQuery(address), -1, -1, bounds);
}
QGeoCodeReply *QGeoCodingManagerEngineGoogle::geocode(const QString &address, int limit, int offset, const QGeoShape &bounds)
QGeoCodeReply *QGeoCodingManagerEngineQGC::geocode(const QString &address, int limit, int offset, const QGeoShape &bounds)
{
Q_UNUSED(limit);
Q_UNUSED(offset);
......@@ -124,7 +124,7 @@ QGeoCodeReply *QGeoCodingManagerEngineGoogle::geocode(const QString &address, in
QNetworkReply *reply = m_networkManager->get(request);
reply->setParent(0);
QGeoCodeReplyGoogle *geocodeReply = new QGeoCodeReplyGoogle(reply);
QGeoCodeReplyQGC *geocodeReply = new QGeoCodeReplyQGC(reply);
connect(geocodeReply, SIGNAL(finished()), this, SLOT(replyFinished()));
connect(geocodeReply, SIGNAL(error(QGeoCodeReply::Error,QString)),
......@@ -133,7 +133,7 @@ QGeoCodeReply *QGeoCodingManagerEngineGoogle::geocode(const QString &address, in
return geocodeReply;
}
QGeoCodeReply *QGeoCodingManagerEngineGoogle::reverseGeocode(const QGeoCoordinate &coordinate, const QGeoShape &bounds)
QGeoCodeReply *QGeoCodingManagerEngineQGC::reverseGeocode(const QGeoCoordinate &coordinate, const QGeoShape &bounds)
{
Q_UNUSED(bounds)
......@@ -155,7 +155,7 @@ QGeoCodeReply *QGeoCodingManagerEngineGoogle::reverseGeocode(const QGeoCoordinat
QNetworkReply *reply = m_networkManager->get(request);
reply->setParent(0);
QGeoCodeReplyGoogle *geocodeReply = new QGeoCodeReplyGoogle(reply);
QGeoCodeReplyQGC *geocodeReply = new QGeoCodeReplyQGC(reply);
connect(geocodeReply, SIGNAL(finished()), this, SLOT(replyFinished()));
connect(geocodeReply, SIGNAL(error(QGeoCodeReply::Error,QString)),
......@@ -164,14 +164,14 @@ QGeoCodeReply *QGeoCodingManagerEngineGoogle::reverseGeocode(const QGeoCoordinat
return geocodeReply;
}
void QGeoCodingManagerEngineGoogle::replyFinished()
void QGeoCodingManagerEngineQGC::replyFinished()
{
QGeoCodeReply *reply = qobject_cast<QGeoCodeReply *>(sender());
if (reply)
emit finished(reply);
}
void QGeoCodingManagerEngineGoogle::replyError(QGeoCodeReply::Error errorCode, const QString &errorString)
void QGeoCodingManagerEngineQGC::replyError(QGeoCodeReply::Error errorCode, const QString &errorString)
{
QGeoCodeReply *reply = qobject_cast<QGeoCodeReply *>(sender());
if (reply)
......
......@@ -38,7 +38,7 @@
** $QT_END_LICENSE$
**
** 2015.4.4
** Adapted for google maps with the intent of use for QGroundControl
** Adapted for use with QGroundControl
**
** Gus Grubba <mavlink@grubba.com>
**
......@@ -55,13 +55,13 @@ QT_BEGIN_NAMESPACE
class QNetworkAccessManager;
class QGeoCodingManagerEngineGoogle : public QGeoCodingManagerEngine
class QGeoCodingManagerEngineQGC : public QGeoCodingManagerEngine
{
Q_OBJECT
public:
QGeoCodingManagerEngineGoogle(const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString);
~QGeoCodingManagerEngineGoogle();
QGeoCodingManagerEngineQGC(const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString);
~QGeoCodingManagerEngineQGC();
QGeoCodeReply* geocode (const QGeoAddress &address, const QGeoShape &bounds) Q_DECL_OVERRIDE;
QGeoCodeReply* geocode (const QString &address, int limit, int offset, const QGeoShape &bounds) Q_DECL_OVERRIDE;
......
......@@ -38,7 +38,7 @@
** $QT_END_LICENSE$
**
** 2015.4.4
** Adapted for google maps with the intent of use for QGroundControl
** Adapted for use with QGroundControl
**
** Gus Grubba <mavlink@grubba.com>
**
......@@ -46,9 +46,10 @@
#include <QtLocation/private/qgeotilespec_p.h>
#include "qgeomapreplygoogle.h"
#include "qgeomapreplyqgc.h"
#include "OpenPilotMaps.h"
QGeoMapReplyGoogle::QGeoMapReplyGoogle(QNetworkReply *reply, const QGeoTileSpec &spec, QObject *parent)
QGeoMapReplyQGC::QGeoMapReplyQGC(QNetworkReply *reply, const QGeoTileSpec &spec, QObject *parent)
: QGeoTiledMapReply(spec, parent)
, m_reply(reply)
{
......@@ -57,7 +58,7 @@ QGeoMapReplyGoogle::QGeoMapReplyGoogle(QNetworkReply *reply, const QGeoTileSpec
connect(m_reply, SIGNAL(destroyed()), this, SLOT(replyDestroyed()));
}
QGeoMapReplyGoogle::~QGeoMapReplyGoogle()
QGeoMapReplyQGC::~QGeoMapReplyQGC()
{
if (m_reply) {
m_reply->deleteLater();
......@@ -65,24 +66,24 @@ QGeoMapReplyGoogle::~QGeoMapReplyGoogle()
}
}
void QGeoMapReplyGoogle::abort()
void QGeoMapReplyQGC::abort()
{
if (!m_reply)
return;
m_reply->abort();
}
QNetworkReply *QGeoMapReplyGoogle::networkReply() const
QNetworkReply *QGeoMapReplyQGC::networkReply() const
{
return m_reply;
}
void QGeoMapReplyGoogle::replyDestroyed()
void QGeoMapReplyQGC::replyDestroyed()
{
m_reply = 0;
}
void QGeoMapReplyGoogle::networkReplyFinished()
void QGeoMapReplyQGC::networkReplyFinished()
{
if (!m_reply)
return;
......@@ -90,24 +91,39 @@ void QGeoMapReplyGoogle::networkReplyFinished()
if (m_reply->error() != QNetworkReply::NoError)
return;
// qDebug() << "Map OK: " << m_reply->url().toString();
QByteArray a = m_reply->readAll();
setMapImageData(a);
if(tileSpec().mapId() > 0 && tileSpec().mapId() < 5)
setMapImageFormat("png");
else
qWarning("Unknown map id %d", tileSpec().mapId());
switch ((OpenPilot::MapType)tileSpec().mapId()) {
case OpenPilot::GoogleMap:
case OpenPilot::GoogleSatellite:
case OpenPilot::GoogleLabels:
case OpenPilot::GoogleTerrain:
case OpenPilot::GoogleHybrid:
case OpenPilot::BingMap:
setMapImageFormat("png");
break;
case OpenPilot::BingSatellite:
setMapImageFormat("jpeg");
break;
default:
qWarning("Unknown map id %d", tileSpec().mapId());
break;
}
setFinished(true);
m_reply->deleteLater();
m_reply = 0;
}
void QGeoMapReplyGoogle::networkReplyError(QNetworkReply::NetworkError error)
void QGeoMapReplyQGC::networkReplyError(QNetworkReply::NetworkError error)
{
if (!m_reply)
return;
// qDebug() << "Map error: " << m_reply->url().toString();
if (error != QNetworkReply::OperationCanceledError)
setError(QGeoTiledMapReply::CommunicationError, m_reply->errorString());
......
......@@ -38,7 +38,7 @@
** $QT_END_LICENSE$
**
** 2015.4.4
** Adapted for google maps with the intent of use for QGroundControl
** Adapted for use with QGroundControl
**
** Gus Grubba <mavlink@grubba.com>
**
......@@ -52,13 +52,13 @@
QT_BEGIN_NAMESPACE
class QGeoMapReplyGoogle : public QGeoTiledMapReply
class QGeoMapReplyQGC : public QGeoTiledMapReply
{
Q_OBJECT
public:
explicit QGeoMapReplyGoogle(QNetworkReply *reply, const QGeoTileSpec &spec, QObject *parent = 0);
~QGeoMapReplyGoogle();
explicit QGeoMapReplyQGC(QNetworkReply *reply, const QGeoTileSpec &spec, QObject *parent = 0);
~QGeoMapReplyQGC();
void abort();
......
......@@ -38,7 +38,7 @@
** $QT_END_LICENSE$
**
** 2015.4.4
** Adapted for google maps with the intent of use for QGroundControl
** Adapted for use with QGroundControl
**
** Gus Grubba <mavlink@grubba.com>
**
......@@ -47,32 +47,32 @@
#include <QtLocation/private/qgeotiledmappingmanagerengine_p.h>
#include "qdebug.h"
#include "qgeoserviceproviderplugingoogle.h"
#include "qgeotiledmappingmanagerenginegoogle.h"
#include "qgeocodingmanagerenginegoogle.h"
#include "qgeoserviceproviderpluginqgc.h"
#include "qgeotiledmappingmanagerengineqgc.h"
#include "qgeocodingmanagerengineqgc.h"
QT_BEGIN_NAMESPACE
QGeoCodingManagerEngine *QGeoServiceProviderFactoryGoogle::createGeocodingManagerEngine(
QGeoCodingManagerEngine *QGeoServiceProviderFactoryQGC::createGeocodingManagerEngine(
const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString) const
{
return new QGeoCodingManagerEngineGoogle(parameters, error, errorString);
return new QGeoCodingManagerEngineQGC(parameters, error, errorString);
}
QGeoMappingManagerEngine *QGeoServiceProviderFactoryGoogle::createMappingManagerEngine(
QGeoMappingManagerEngine *QGeoServiceProviderFactoryQGC::createMappingManagerEngine(
const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString) const
{
return new QGeoTiledMappingManagerEngineGoogle(parameters, error, errorString);
return new QGeoTiledMappingManagerEngineQGC(parameters, error, errorString);
}
QGeoRoutingManagerEngine *QGeoServiceProviderFactoryGoogle::createRoutingManagerEngine(
QGeoRoutingManagerEngine *QGeoServiceProviderFactoryQGC::createRoutingManagerEngine(
const QVariantMap &, QGeoServiceProvider::Error *, QString *) const
{
// Not implemented for QGC
return NULL;
}
QPlaceManagerEngine *QGeoServiceProviderFactoryGoogle::createPlaceManagerEngine(
QPlaceManagerEngine *QGeoServiceProviderFactoryQGC::createPlaceManagerEngine(
const QVariantMap &, QGeoServiceProvider::Error *, QString *) const
{
// Not implemented for QGC
......
......@@ -38,7 +38,7 @@
** $QT_END_LICENSE$
**
** 2015.4.4
** Adapted for google maps with the intent of use for QGroundControl
** Adapted for use with QGroundControl
**
** Gus Grubba <mavlink@grubba.com>
**
......@@ -52,11 +52,11 @@
QT_BEGIN_NAMESPACE
class QGeoServiceProviderFactoryGoogle: public QObject, public QGeoServiceProviderFactory
class QGeoServiceProviderFactoryQGC: public QObject, public QGeoServiceProviderFactory
{
Q_OBJECT
Q_INTERFACES(QGeoServiceProviderFactory)
Q_PLUGIN_METADATA(IID "org.qt-project.qt.geoservice.serviceproviderfactory/5.0" FILE "google_maps_plugin.json")
Q_PLUGIN_METADATA(IID "org.qt-project.qt.geoservice.serviceproviderfactory/5.0" FILE "qgc_maps_plugin.json")
public:
QGeoCodingManagerEngine* createGeocodingManagerEngine(const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString) const;
......
......@@ -38,7 +38,7 @@
** $QT_END_LICENSE$
**
** 2015.4.4
** Adapted for google maps with the intent of use for QGroundControl
** Adapted for use with QGroundControl
**
** Gus Grubba <mavlink@grubba.com>
**
......@@ -50,12 +50,13 @@
#include <QDir>
#include <QStandardPaths>
#include "qgeotiledmappingmanagerenginegoogle.h"
#include "qgeotilefetchergoogle.h"
#include "qgeotiledmappingmanagerengineqgc.h"
#include "qgeotilefetcherqgc.h"
#include "OpenPilotMaps.h"
QT_BEGIN_NAMESPACE
QGeoTiledMappingManagerEngineGoogle::QGeoTiledMappingManagerEngineGoogle(const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString)
QGeoTiledMappingManagerEngineQGC::QGeoTiledMappingManagerEngineQGC(const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString)
: QGeoTiledMappingManagerEngine()
{
QGeoCameraCapabilities cameraCaps;
......@@ -66,19 +67,24 @@ QGeoTiledMappingManagerEngineGoogle::QGeoTiledMappingManagerEngineGoogle(const Q
setTileSize(QSize(256, 256));
QList<QGeoMapType> mapTypes;
mapTypes << QGeoMapType(QGeoMapType::StreetMap, tr("Street Map"), tr("Google street map"), false, false, 1);
mapTypes << QGeoMapType(QGeoMapType::SatelliteMapDay, tr("Satellite Map"),tr("Google satellite map"), false, false, 2);
mapTypes << QGeoMapType(QGeoMapType::TerrainMap, tr("Terrain Map"), tr("Google terrain map"), false, false, 3);
// mapTypes << QGeoMapType(QGeoMapType::HybridMap, tr("Hybrid Map"), tr("Google hybrid map"), false, false, 4);
mapTypes << QGeoMapType(QGeoMapType::StreetMap, tr("Google Street Map"), tr("Google street map"), false, false, OpenPilot::GoogleMap);
mapTypes << QGeoMapType(QGeoMapType::SatelliteMapDay, tr("Google Satellite Map"),tr("Google satellite map"), false, false, OpenPilot::GoogleSatellite);
mapTypes << QGeoMapType(QGeoMapType::TerrainMap, tr("Google Terrain Map"), tr("Google terrain map"), false, false, OpenPilot::GoogleTerrain);
// TODO:
// Proper hybrid maps requires collecting two separate bimaps and overlaying them.
//mapTypes << QGeoMapType(QGeoMapType::HybridMap, tr("Google Hybrid Map"), tr("Google hybrid map"), false, false, OpenPilot::GoogleHybrid);
// Bing
mapTypes << QGeoMapType(QGeoMapType::StreetMap, tr("Bing Street Map"), tr("Bing street map"), false, false, OpenPilot::BingMap);
mapTypes << QGeoMapType(QGeoMapType::SatelliteMapDay, tr("Bing Satellite Map"), tr("Bing satellite map"), false, false, OpenPilot::BingSatellite);
setSupportedMapTypes(mapTypes);
QGeoTileFetcherGoogle *tileFetcher = new QGeoTileFetcherGoogle(this);
QGeoTileFetcherQGC *tileFetcher = new QGeoTileFetcherQGC(this);
if (parameters.contains(QStringLiteral("useragent"))) {
const QByteArray ua = parameters.value(QStringLiteral("useragent")).toString().toLatin1();
tileFetcher->setUserAgent(ua);
} else
// QGC Default
tileFetcher->setUserAgent("qgroundcontrol.org");
tileFetcher->setUserAgent("Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7");
setTileFetcher(tileFetcher);
......@@ -146,11 +152,11 @@ QGeoTiledMappingManagerEngineGoogle::QGeoTiledMappingManagerEngineGoogle(const Q
errorString->clear();
}
QGeoTiledMappingManagerEngineGoogle::~QGeoTiledMappingManagerEngineGoogle()
QGeoTiledMappingManagerEngineQGC::~QGeoTiledMappingManagerEngineQGC()
{
}
QGeoMapData *QGeoTiledMappingManagerEngineGoogle::createMapData()
QGeoMapData *QGeoTiledMappingManagerEngineQGC::createMapData()
{
return new QGeoTiledMapData(this, 0);
}
......
......@@ -38,7 +38,7 @@
** $QT_END_LICENSE$
**
** 2015.4.4
** Adapted for google maps with the intent of use for QGroundControl
** Adapted for use with QGroundControl
**
** Gus Grubba <mavlink@grubba.com>
**
......@@ -52,12 +52,12 @@
QT_BEGIN_NAMESPACE
class QGeoTiledMappingManagerEngineGoogle : public QGeoTiledMappingManagerEngine
class QGeoTiledMappingManagerEngineQGC : public QGeoTiledMappingManagerEngine
{
Q_OBJECT
public:
QGeoTiledMappingManagerEngineGoogle(const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString);
~QGeoTiledMappingManagerEngineGoogle();
QGeoTiledMappingManagerEngineQGC(const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString);
~QGeoTiledMappingManagerEngineQGC();
QGeoMapData *createMapData();
};
......
......@@ -38,71 +38,115 @@
** $QT_END_LICENSE$
**
** 2015.4.4
** Adapted for google maps with the intent of use for QGroundControl
** Adapted for use with QGroundControl
**
** Gus Grubba <mavlink@grubba.com>
**
****************************************************************************/
#include "qgeotilefetchergoogle.h"
#include "qgeomapreplygoogle.h"
#include <QtCore/QLocale>
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkRequest>
#include <QtLocation/private/qgeotilespec_p.h>
#include "qgeotilefetcherqgc.h"
#include "qgeomapreplyqgc.h"
QT_BEGIN_NAMESPACE
QGeoTileFetcherGoogle::QGeoTileFetcherGoogle(QGeoTiledMappingManagerEngine *parent)
QGeoTileFetcherQGC::QGeoTileFetcherQGC(QGeoTiledMappingManagerEngine *parent)
: QGeoTileFetcher(parent)
, m_networkManager(new QNetworkAccessManager(this))
, m_userAgent("Qt Application")
{
QStringList langs = QLocale::system().uiLanguages();
if (langs.length() > 0) {
m_Language = langs[0];
}
}
void QGeoTileFetcherGoogle::setUserAgent(const QByteArray &userAgent)
void QGeoTileFetcherQGC::setUserAgent(const QByteArray &userAgent)
{
m_userAgent = userAgent;
}
QGeoTiledMapReply *QGeoTileFetcherGoogle::getTileImage(const QGeoTileSpec &spec)
QGeoTiledMapReply *QGeoTileFetcherQGC::getTileImage(const QGeoTileSpec &spec)
{
QNetworkRequest request;
request.setRawHeader("User-Agent", m_userAgent);
QString url;
if (spec.mapId() == 1) {
url = QStringLiteral("http://mt1.google.com/vt/lyrs=m");
} else if (spec.mapId() == 2) {
url = QStringLiteral("http://mt1.google.com/vt/lyrs=s");
} else if (spec.mapId() == 3) {
url = QStringLiteral("http://mt1.google.com/vt/lyrs=p");
} else if (spec.mapId() == 4) {
url = QStringLiteral(" http://mt1.google.com/vt/lyrs=h");
} else {
qWarning("Unknown map id %d\n", spec.mapId());
url = QStringLiteral("http://mt1.google.com/vt/lyrs=m");
}
QString url = m_UrlFactory.makeImageUrl((OpenPilot::MapType)spec.mapId(), QPoint(spec.x(), spec.y()), spec.zoom(), m_Language);
url += QStringLiteral("&x=%1&y=%2&z=%3")
.arg(spec.x())
.arg(spec.y())
.arg(spec.zoom());
// qDebug() << "Request x" << spec.x() << "y" << spec.y() << "URL:" << url;
QStringList langs = QLocale::system().uiLanguages();
if (langs.length() > 0) {
url += QStringLiteral("&hl=%1").arg(langs[0]);
request.setUrl(QUrl(url));
request.setRawHeader("User-Agent", m_userAgent);
request.setRawHeader("Accept", "*/*");
switch ((OpenPilot::MapType)spec.mapId()) {
case OpenPilot::GoogleMap:
case OpenPilot::GoogleSatellite:
case OpenPilot::GoogleLabels:
case OpenPilot::GoogleTerrain:
case OpenPilot::GoogleHybrid:
{
request.setRawHeader("Referrer", "http://maps.google.com/");
}
break;
case OpenPilot::GoogleMapChina:
case OpenPilot::GoogleSatelliteChina:
case OpenPilot::GoogleLabelsChina:
case OpenPilot::GoogleTerrainChina:
case OpenPilot::GoogleHybridChina:
{
request.setRawHeader("Referrer", "http://ditu.google.cn/");
}
break;
case OpenPilot::BingHybrid:
case OpenPilot::BingMap:
case OpenPilot::BingSatellite:
{
request.setRawHeader("Referrer", "http://www.bing.com/maps/");
}
break;
case OpenPilot::YahooHybrid:
case OpenPilot::YahooLabels:
case OpenPilot::YahooMap:
case OpenPilot::YahooSatellite:
{
request.setRawHeader("Referrer", "http://maps.yahoo.com/");
}
break;
case OpenPilot::ArcGIS_MapsLT_Map_Labels:
case OpenPilot::ArcGIS_MapsLT_Map:
case OpenPilot::ArcGIS_MapsLT_OrtoFoto:
case OpenPilot::ArcGIS_MapsLT_Map_Hybrid:
{
request.setRawHeader("Referrer", "http://www.maps.lt/map_beta/");
}
break;
case OpenPilot::OpenStreetMapSurfer:
case OpenPilot::OpenStreetMapSurferTerrain:
{
request.setRawHeader("Referrer", "http://www.mapsurfer.net/");
}
break;
case OpenPilot::OpenStreetMap:
case OpenPilot::OpenStreetOsm:
{
request.setRawHeader("Referrer", "http://www.openstreetmap.org/");
}
break;
case OpenPilot::YandexMapRu:
{
request.setRawHeader("Referrer", "http://maps.yandex.ru/");
}
break;
default:
break;
}
url += QStringLiteral("&scale=2");
QUrl qurl(url);
request.setUrl(qurl);
QNetworkReply *reply = m_networkManager->get(request);
reply->setParent(0);
return new QGeoMapReplyQGC(reply, spec);
return new QGeoMapReplyGoogle(reply, spec);
}
QT_END_NAMESPACE
......@@ -38,7 +38,7 @@
** $QT_END_LICENSE$
**
** 2015.4.4
** Adapted for google maps with the intent of use for QGroundControl
** Adapted for use with QGroundControl
**
** Gus Grubba <mavlink@grubba.com>
**
......@@ -49,25 +49,28 @@
#include <QtLocation/private/qgeotilefetcher_p.h>
#include <QtLocation/private/qgeotilecache_p.h>
#include "OpenPilotMaps.h"
QT_BEGIN_NAMESPACE
class QGeoTiledMappingManagerEngine;
class QNetworkAccessManager;
class QGeoTileFetcherGoogle : public QGeoTileFetcher
class QGeoTileFetcherQGC : public QGeoTileFetcher
{
Q_OBJECT
public:
explicit QGeoTileFetcherGoogle(QGeoTiledMappingManagerEngine *parent = 0);
explicit QGeoTileFetcherQGC(QGeoTiledMappingManagerEngine *parent = 0);
void setUserAgent(const QByteArray &userAgent);
private:
QGeoTiledMapReply* getTileImage(const QGeoTileSpec &spec);
QNetworkAccessManager *m_networkManager;
QByteArray m_userAgent;
QNetworkAccessManager* m_networkManager;
QByteArray m_userAgent;
OpenPilot::UrlFactory m_UrlFactory;
QString m_Language;
};
QT_END_NAMESPACE
......
......@@ -109,34 +109,34 @@ LANGUAGE = C++
message(BASEDIR $$BASEDIR DESTDIR $$DESTDIR TARGET $$TARGET)
# Google Maps QtLocation
# QGC QtLocation
GOOGLEDIR = $${OUT_PWD}/libs/QtLocationGoogle/plugins/geoservices
QGCMAPDIR = $${OUT_PWD}/libs/QtLocationQGC/plugins/geoservices
LinuxBuild {
LIBS += -L$$GOOGLEDIR -lqtgeoservices_google
PRE_TARGETDEPS += $$GOOGLEDIR/libqtgeoservices_google.a
LIBS += -L$$QGCMAPDIR -lqtgeoservices_qgc
PRE_TARGETDEPS += $$QGCMAPDIR/libqtgeoservices_qgc.a
}
WindowsBuild {
DebugBuild {
LIBS += -L$$GOOGLEDIR -lqtgeoservices_googled
PRE_TARGETDEPS += $$GOOGLEDIR/qtgeoservices_googled.lib
LIBS += -L$$QGCMAPDIR -lqtgeoservices_qgcd
PRE_TARGETDEPS += $$QGCMAPDIR/qtgeoservices_qgcd.lib
}
ReleaseBuild {
LIBS += -L$$GOOGLEDIR -lqtgeoservices_google
PRE_TARGETDEPS += $$GOOGLEDIR/qtgeoservices_google.lib
LIBS += -L$$QGCMAPDIR -lqtgeoservices_qgc
PRE_TARGETDEPS += $$QGCMAPDIR/qtgeoservices_qgc.lib
}
}
MacBuild {
DebugBuild {
LIBS += -L$$GOOGLEDIR -lqtgeoservices_google_debug
PRE_TARGETDEPS += $$GOOGLEDIR/libqtgeoservices_google_debug.a
LIBS += -L$$QGCMAPDIR -lqtgeoservices_qgc_debug
PRE_TARGETDEPS += $$QGCMAPDIR/libqtgeoservices_qgc_debug.a
}
ReleaseBuild {
LIBS += -L$$GOOGLEDIR -lqtgeoservices_google
PRE_TARGETDEPS += $$GOOGLEDIR/libqtgeoservices_google.a
LIBS += -L$$QGCMAPDIR -lqtgeoservices_qgc
PRE_TARGETDEPS += $$QGCMAPDIR/libqtgeoservices_qgc.a
}
}
......
......@@ -19,8 +19,8 @@
TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS = libs/QtLocationGoogle
SUBDIRS = libs/QtLocationQGC
SUBDIRS += ./qgcsystem.pro
qgcsystem.depends = QtLocationGoogle
qgcsystem.depends = QtLocationQGC
......@@ -108,7 +108,7 @@ int main(int argc, char *argv[])
#pragma warning( disable : 4930 4101 )
#endif
Q_IMPORT_PLUGIN(QGeoServiceProviderFactoryGoogle)
Q_IMPORT_PLUGIN(QGeoServiceProviderFactoryQGC)
bool runUnitTests = false; // Run unit tests
......
......@@ -62,7 +62,7 @@ Rectangle {
Plugin {
id: mapPlugin
name: "google"
name: "QGroundControl"
}
Map {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment