Commit a900cdde authored by Don Gagne's avatar Don Gagne

Merge pull request #1418 from dogmaphobic/googleMapping

Google mapping
parents 146f52ce c6c75198
......@@ -165,6 +165,7 @@ WindowsBuild {
$$DLL_DIR\\icu*.dll \
$$DLL_DIR\\Qt5Core$${DLL_QT_DEBUGCHAR}.dll \
$$DLL_DIR\\Qt5Gui$${DLL_QT_DEBUGCHAR}.dll \
$$DLL_DIR\\Qt5Location$${DLL_QT_DEBUGCHAR}.dll \
$$DLL_DIR\\Qt5Multimedia$${DLL_QT_DEBUGCHAR}.dll \
$$DLL_DIR\\Qt5MultimediaWidgets$${DLL_QT_DEBUGCHAR}.dll \
$$DLL_DIR\\Qt5Network$${DLL_QT_DEBUGCHAR}.dll \
......@@ -176,7 +177,6 @@ WindowsBuild {
$$DLL_DIR\\Qt5QuickWidgets$${DLL_QT_DEBUGCHAR}.dll \
$$DLL_DIR\\Qt5Sensors$${DLL_QT_DEBUGCHAR}.dll \
$$DLL_DIR\\Qt5SerialPort$${DLL_QT_DEBUGCHAR}.dll \
$$DLL_DIR\\Qt5OpenGL$${DLL_QT_DEBUGCHAR}.dll \
$$DLL_DIR\\Qt5Sql$${DLL_QT_DEBUGCHAR}.dll \
$$DLL_DIR\\Qt5Svg$${DLL_QT_DEBUGCHAR}.dll \
$$DLL_DIR\\Qt5Test$${DLL_QT_DEBUGCHAR}.dll \
......
load(qt_build_config)
MODULE_VERSION = 5.4.1
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": ["qgc-maps"],
"Provider": "QGroundControl",
"Version": 101,
"Experimental": false,
"Features": [
"OnlineMappingFeature",
"OnlineGeocodingFeature",
"ReverseGeocodingFeature"
]
}
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>
#include <QMutex>
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
This diff is collapsed.
/****************************************************************************
**
** Copyright (C) 2013 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:LGPL$
** 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 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
** 2015.4.4
** Adapted for use with QGroundControl
**
** Gus Grubba <mavlink@grubba.com>
**
****************************************************************************/
#ifndef QGEOCODEREPLYGOOGLE_H
#define QGEOCODEREPLYGOOGLE_H
#include <QtNetwork/QNetworkReply>
#include <QtLocation/QGeoCodeReply>
QT_BEGIN_NAMESPACE
class QGeoCodeReplyQGC : public QGeoCodeReply
{
Q_OBJECT
public:
explicit QGeoCodeReplyQGC(QNetworkReply *reply, QObject *parent = 0);
~QGeoCodeReplyQGC();
void abort();
private Q_SLOTS:
void networkReplyFinished();
void networkReplyError(QNetworkReply::NetworkError error);
private:
QNetworkReply *m_reply;
};
QT_END_NAMESPACE
#endif // QGEOCODEREPLYGOOGLE_H
/****************************************************************************
**
** Copyright (C) 2013 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:LGPL$
** 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 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
** 2015.4.4
** Adapted for use with QGroundControl
**
** Gus Grubba <mavlink@grubba.com>
**
****************************************************************************/
#include <QtCore/QVariantMap>
#include <QtCore/QUrl>
#include <QtCore/QUrlQuery>
#include <QtCore/QLocale>
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkRequest>
#include <QtPositioning/QGeoCoordinate>
#include <QtPositioning/QGeoAddress>
#include <QtPositioning/QGeoShape>
#include <QtPositioning/QGeoRectangle>
#include "qgeocodingmanagerengineqgc.h"
#include "qgeocodereplyqgc.h"
QT_BEGIN_NAMESPACE
static QString addressToQuery(const QGeoAddress &address)
{
return address.street() + QStringLiteral(", ") +
address.district() + QStringLiteral(", ") +
address.city() + QStringLiteral(", ") +
address.state() + QStringLiteral(", ") +
address.country();
}
static QString boundingBoxToLtrb(const QGeoRectangle &rect)
{
return QString::number(rect.topLeft().longitude()) + QLatin1Char(',') +
QString::number(rect.topLeft().latitude()) + QLatin1Char(',') +
QString::number(rect.bottomRight().longitude()) + QLatin1Char(',') +
QString::number(rect.bottomRight().latitude());
}
QGeoCodingManagerEngineQGC::QGeoCodingManagerEngineQGC(
const QVariantMap &parameters,
QGeoServiceProvider::Error *error,
QString *errorString)
: QGeoCodingManagerEngine(parameters), m_networkManager(new QNetworkAccessManager(this))
{
if (parameters.contains(QStringLiteral("useragent")))
m_userAgent = parameters.value(QStringLiteral("useragent")).toString().toLatin1();
else
m_userAgent = "Qt Location based application";
*error = QGeoServiceProvider::NoError;
errorString->clear();
}
QGeoCodingManagerEngineQGC::~QGeoCodingManagerEngineQGC()
{
}
QGeoCodeReply *QGeoCodingManagerEngineQGC::geocode(const QGeoAddress &address, const QGeoShape &bounds)
{
return geocode(addressToQuery(address), -1, -1, bounds);
}
QGeoCodeReply *QGeoCodingManagerEngineQGC::geocode(const QString &address, int limit, int offset, const QGeoShape &bounds)
{
Q_UNUSED(limit);
Q_UNUSED(offset);
QNetworkRequest request;
request.setRawHeader("User-Agent", m_userAgent);
QUrl url(QStringLiteral("http://maps.googleapis.com/maps/api/geocode/json"));
QUrlQuery query;
query.addQueryItem(QStringLiteral("sensor"), QStringLiteral("false"));
query.addQueryItem(QStringLiteral("language"), locale().name().left(2));
query.addQueryItem(QStringLiteral("address"), address);
if (bounds.type() == QGeoShape::RectangleType) {
query.addQueryItem(QStringLiteral("bounds"), boundingBoxToLtrb(bounds));
}
url.setQuery(query);
request.setUrl(url);
qDebug() << url;
QNetworkReply *reply = m_networkManager->get(request);
reply->setParent(0);
QGeoCodeReplyQGC *geocodeReply = new QGeoCodeReplyQGC(reply);
connect(geocodeReply, SIGNAL(finished()), this, SLOT(replyFinished()));
connect(geocodeReply, SIGNAL(error(QGeoCodeReply::Error,QString)),
this, SLOT(replyError(QGeoCodeReply::Error,QString)));
return geocodeReply;
}
QGeoCodeReply *QGeoCodingManagerEngineQGC::reverseGeocode(const QGeoCoordinate &coordinate, const QGeoShape &bounds)
{
Q_UNUSED(bounds)
QNetworkRequest request;
request.setRawHeader("User-Agent", m_userAgent);
QUrl url(QStringLiteral("http://maps.googleapis.com/maps/api/geocode/json"));
QUrlQuery query;
query.addQueryItem(QStringLiteral("sensor"), QStringLiteral("false"));
query.addQueryItem(QStringLiteral("language"), locale().name().left(2));
query.addQueryItem(QStringLiteral("latlng"), QStringLiteral("%1,%2")
.arg(coordinate.latitude())
.arg(coordinate.longitude()));
url.setQuery(query);
request.setUrl(url);
qDebug() << url;
QNetworkReply *reply = m_networkManager->get(request);
reply->setParent(0);
QGeoCodeReplyQGC *geocodeReply = new QGeoCodeReplyQGC(reply);
connect(geocodeReply, SIGNAL(finished()), this, SLOT(replyFinished()));
connect(geocodeReply, SIGNAL(error(QGeoCodeReply::Error,QString)),
this, SLOT(replyError(QGeoCodeReply::Error,QString)));
return geocodeReply;
}
void QGeoCodingManagerEngineQGC::replyFinished()
{
QGeoCodeReply *reply = qobject_cast<QGeoCodeReply *>(sender());
if (reply)
emit finished(reply);
}
void QGeoCodingManagerEngineQGC::replyError(QGeoCodeReply::Error errorCode, const QString &errorString)
{
QGeoCodeReply *reply = qobject_cast<QGeoCodeReply *>(sender());
if (reply)
emit error(reply, errorCode, errorString);
}
QT_END_NAMESPACE
/****************************************************************************
**
** Copyright (C) 2013 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:LGPL$
** 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 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
** 2015.4.4
** Adapted for use with QGroundControl
**
** Gus Grubba <mavlink@grubba.com>
**
****************************************************************************/
#ifndef QGEOCODINGMANAGERENGINEGOOGLE_H
#define QGEOCODINGMANAGERENGINEGOOGLE_H
#include <QtLocation/QGeoServiceProvider>
#include <QtLocation/QGeoCodingManagerEngine>
#include <QtLocation/QGeoCodeReply>
QT_BEGIN_NAMESPACE
class QNetworkAccessManager;
class QGeoCodingManagerEngineQGC : public QGeoCodingManagerEngine
{
Q_OBJECT
public:
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;
QGeoCodeReply* reverseGeocode (const QGeoCoordinate &coordinate, const QGeoShape &bounds) Q_DECL_OVERRIDE;
private Q_SLOTS:
void replyFinished ();
void replyError (QGeoCodeReply::Error errorCode, const QString &errorString);
private:
QNetworkAccessManager *m_networkManager;
QByteArray m_userAgent;
};
QT_END_NAMESPACE
#endif // QGEOCODINGMANAGERENGINEGOOGLE_H
/****************************************************************************
**
** Copyright (C) 2013 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:LGPL$
** 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 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
** 2015.4.4
** Adapted for use with QGroundControl
**
** Gus Grubba <mavlink@grubba.com>
**
****************************************************************************/
#include <QtLocation/private/qgeotilespec_p.h>
#include "qgeomapreplyqgc.h"
#include "OpenPilotMaps.h"
QGeoMapReplyQGC::QGeoMapReplyQGC(QNetworkReply *reply, const QGeoTileSpec &spec, QObject *parent)
: QGeoTiledMapReply(spec, parent)
, m_reply(reply)
{
connect(m_reply, SIGNAL(finished()), this, SLOT(networkReplyFinished()));
connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(networkReplyError(QNetworkReply::NetworkError)));
connect(m_reply, SIGNAL(destroyed()), this, SLOT(replyDestroyed()));
}
QGeoMapReplyQGC::~QGeoMapReplyQGC()
{
if (m_reply) {
m_reply->deleteLater();
m_reply = 0;
}
}
void QGeoMapReplyQGC::abort()
{
if (!m_reply)
return;
m_reply->abort();
}
QNetworkReply *QGeoMapReplyQGC::networkReply() const
{
return m_reply;
}
void QGeoMapReplyQGC::replyDestroyed()
{
m_reply = 0;
}
void QGeoMapReplyQGC::networkReplyFinished()
{
if (!m_reply)
return;
if (m_reply->error() != QNetworkReply::NoError)
return;
QByteArray a = m_reply->readAll();
setMapImageData(a);
if(a.size() > 2)
{
if((char)a[0] == (char)0xff && (char)a[1] == (char)0xd8)
setMapImageFormat("jpg");
else if((char)a[0] == (char)0x89 && (char)a[1] == (char)0x50)
setMapImageFormat("png");
else
{
switch ((OpenPilot::MapType)tileSpec().mapId()) {
case OpenPilot::GoogleMap:
case OpenPilot::GoogleLabels:
case OpenPilot::GoogleTerrain:
case OpenPilot::GoogleHybrid:
case OpenPilot::BingMap:
case OpenPilot::OpenStreetMap:
setMapImageFormat("png");
break;
case OpenPilot::GoogleSatellite:
case OpenPilot::BingSatellite:
case OpenPilot::BingHybrid:
setMapImageFormat("jpg");
break;
default:
qWarning("Unknown map id %d", tileSpec().mapId());
break;
}
}
}
setFinished(true);
m_reply->deleteLater();
m_reply = 0;
}
void QGeoMapReplyQGC::networkReplyError(QNetworkReply::NetworkError error)
{
if (!m_reply)
return;
if (error != QNetworkReply::OperationCanceledError)
setError(QGeoTiledMapReply::CommunicationError, m_reply->errorString());
setFinished(true);
m_reply->deleteLater();
m_reply = 0;
}
/****************************************************************************
**
** Copyright (C) 2013 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:LGPL$
** 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 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
** 2015.4.4
** Adapted for use with QGroundControl
**
** Gus Grubba <mavlink@grubba.com>
**
****************************************************************************/
#ifndef QGEOMAPREPLYGOOGLE_H
#define QGEOMAPREPLYGOOGLE_H
#include <QtNetwork/QNetworkReply>
#include <QtLocation/private/qgeotiledmapreply_p.h>
QT_BEGIN_NAMESPACE
class QGeoMapReplyQGC : public QGeoTiledMapReply
{
Q_OBJECT
public:
explicit QGeoMapReplyQGC(QNetworkReply *reply, const QGeoTileSpec &spec, QObject *parent = 0);
~QGeoMapReplyQGC();
void abort();
QNetworkReply *networkReply() const;
private Q_SLOTS:
void replyDestroyed ();
void networkReplyFinished ();
void networkReplyError (QNetworkReply::NetworkError error);
private:
QNetworkReply* m_reply;
};
QT_END_NAMESPACE
#endif // QGEOMAPREPLYGOOGLE_H
/****************************************************************************
**
** Copyright (C) 2013 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:LGPL$
** 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 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
** 2015.4.4
** Adapted for use with QGroundControl
**
** Gus Grubba <mavlink@grubba.com>
**
****************************************************************************/
#include <QtLocation/private/qgeotiledmappingmanagerengine_p.h>
#include "qdebug.h"
#include "qgeoserviceproviderpluginqgc.h"
#include "qgeotiledmappingmanagerengineqgc.h"
#include "qgeocodingmanagerengineqgc.h"
QT_BEGIN_NAMESPACE
QGeoCodingManagerEngine *QGeoServiceProviderFactoryQGC::createGeocodingManagerEngine(
const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString) const
{
return new QGeoCodingManagerEngineQGC(parameters, error, errorString);
}
QGeoMappingManagerEngine *QGeoServiceProviderFactoryQGC::createMappingManagerEngine(
const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString) const
{
return new QGeoTiledMappingManagerEngineQGC(parameters, error, errorString);
}
QGeoRoutingManagerEngine *QGeoServiceProviderFactoryQGC::createRoutingManagerEngine(
const QVariantMap &, QGeoServiceProvider::Error *, QString *) const
{
// Not implemented for QGC
return NULL;
}
QPlaceManagerEngine *QGeoServiceProviderFactoryQGC::createPlaceManagerEngine(
const QVariantMap &, QGeoServiceProvider::Error *, QString *) const
{
// Not implemented for QGC
return NULL;
}
QT_END_NAMESPACE
/****************************************************************************
**
** Copyright (C) 2013 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:LGPL$
** 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 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
** 2015.4.4
** Adapted for use with QGroundControl
**
** Gus Grubba <mavlink@grubba.com>
**
****************************************************************************/
#ifndef QGEOSERVICEPROVIDER_GOOGLE_H
#define QGEOSERVICEPROVIDER_GOOGLE_H
#include <QtCore/QObject>
#include <QtLocation/QGeoServiceProviderFactory>
QT_BEGIN_NAMESPACE
class QGeoServiceProviderFactoryQGC: public QObject, public QGeoServiceProviderFactory
{
Q_OBJECT
Q_INTERFACES(QGeoServiceProviderFactory)
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;
QGeoMappingManagerEngine* createMappingManagerEngine(const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString) const;
QGeoRoutingManagerEngine* createRoutingManagerEngine(const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString) const;
QPlaceManagerEngine* createPlaceManagerEngine(const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString) const;
};
QT_END_NAMESPACE
#endif // QGEOSERVICEPROVIDER_GOOGLE_H
/****************************************************************************
**
** Copyright (C) 2013 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:LGPL$
** 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 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
** 2015.4.4
** Adapted for use with QGroundControl
**
** Gus Grubba <mavlink@grubba.com>
**
****************************************************************************/
#include <QtLocation/private/qgeocameracapabilities_p.h>
#include <QtLocation/private/qgeomaptype_p.h>
#include <QtLocation/private/qgeotiledmapdata_p.h>
#include <QDir>
#include <QStandardPaths>
#include "qgeotiledmappingmanagerengineqgc.h"
#include "qgeotilefetcherqgc.h"
#include "OpenPilotMaps.h"
QT_BEGIN_NAMESPACE
QGeoTiledMappingManagerEngineQGC::QGeoTiledMappingManagerEngineQGC(const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString)
: QGeoTiledMappingManagerEngine()
{
QGeoCameraCapabilities cameraCaps;
cameraCaps.setMinimumZoomLevel(0.0);
cameraCaps.setMaximumZoomLevel(22.0);
setCameraCapabilities(cameraCaps);
setTileSize(QSize(256, 256));
QList<QGeoMapType> mapTypes;
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);
mapTypes << QGeoMapType(QGeoMapType::HybridMap, tr("Bing Hybrid Map"), tr("Bing hybrid map"), false, false, OpenPilot::BingHybrid);
mapTypes << QGeoMapType(QGeoMapType::StreetMap, tr("Open Street Map"), tr("Open Street map"), false, false, OpenPilot::OpenStreetMap);
setSupportedMapTypes(mapTypes);
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("Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7");
setTileFetcher(tileFetcher);
QString cacheDir;
if (parameters.contains(QStringLiteral("mapping.cache.directory")))
cacheDir = parameters.value(QStringLiteral("mapping.cache.directory")).toString();
else {
cacheDir = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + QLatin1String("/QGCMapCache");
if(!QDir::root().mkpath(cacheDir)) {
qWarning() << "Could not create mapping disk cache directory: " << cacheDir;
cacheDir = QDir::homePath() + QLatin1String("/.qgcmapscache/");
}
}
if(!QDir::root().mkpath(cacheDir))
{
qWarning() << "Could not create mapping disk cache directory: " << cacheDir;
cacheDir.clear();
}
//else {
// qDebug() << "Mapping cache directory:" << cacheDir;
//}
QGeoTileCache *tileCache = createTileCacheWithDir(cacheDir);
int cacheLimit = 0;
if (parameters.contains(QStringLiteral("mapping.cache.disk.size"))) {
bool ok = false;
cacheLimit = parameters.value(QStringLiteral("mapping.cache.disk.size")).toString().toInt(&ok);
if (!ok)
cacheLimit = 0;
}
if(!cacheLimit)
// QGC Default
cacheLimit = 1024 * 1024 * 1024;
tileCache->setMaxDiskUsage(cacheLimit);
//qDebug() << "Disk caching limit:" << cacheLimit;
cacheLimit = 0;
if (parameters.contains(QStringLiteral("mapping.cache.memory.size"))) {
bool ok = false;
cacheLimit = parameters.value(QStringLiteral("mapping.cache.memory.size")).toString().toInt(&ok);
if (!ok)
cacheLimit = 0;
}
if(!cacheLimit)
// QGC Default
cacheLimit = 10 * 1024 * 1024;
tileCache->setMaxMemoryUsage(cacheLimit);
//qDebug() << "Memory caching limit:" << cacheLimit;
cacheLimit = 0;
if (parameters.contains(QStringLiteral("mapping.cache.texture.size"))) {
bool ok = false;
cacheLimit = parameters.value(QStringLiteral("mapping.cache.texture.size")).toString().toInt(&ok);
if (!ok)
cacheLimit = 0;
}
if(!cacheLimit)
// QGC Default
cacheLimit = 10 * 1024 * 1024;
tileCache->setExtraTextureUsage(cacheLimit);
*error = QGeoServiceProvider::NoError;
errorString->clear();
}
QGeoTiledMappingManagerEngineQGC::~QGeoTiledMappingManagerEngineQGC()
{
}
QGeoMapData *QGeoTiledMappingManagerEngineQGC::createMapData()
{
return new QGeoTiledMapData(this, 0);
}
QT_END_NAMESPACE
/****************************************************************************
**
** Copyright (C) 2013 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:LGPL$
** 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 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
** 2015.4.4
** Adapted for use with QGroundControl
**
** Gus Grubba <mavlink@grubba.com>
**
****************************************************************************/
#ifndef QGEOTILEDMAPPINGMANAGERENGINEGOOGLE_H
#define QGEOTILEDMAPPINGMANAGERENGINEGOOGLE_H
#include <QtLocation/QGeoServiceProvider>
#include <QtLocation/private/qgeotiledmappingmanagerengine_p.h>
QT_BEGIN_NAMESPACE
class QGeoTiledMappingManagerEngineQGC : public QGeoTiledMappingManagerEngine
{
Q_OBJECT
public:
QGeoTiledMappingManagerEngineQGC(const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString);
~QGeoTiledMappingManagerEngineQGC();
QGeoMapData *createMapData();
};
QT_END_NAMESPACE
#endif // QGEOTILEDMAPPINGMANAGERENGINEGOOGLE_H
/****************************************************************************
**
** Copyright (C) 2013 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:LGPL$
** 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 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
** 2015.4.4
** Adapted for use with QGroundControl
**
** Gus Grubba <mavlink@grubba.com>
**
****************************************************************************/
#include <QtCore/QLocale>
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkRequest>
#include <QtLocation/private/qgeotilespec_p.h>
#include "qgeotilefetcherqgc.h"
#include "qgeomapreplyqgc.h"
QT_BEGIN_NAMESPACE
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 QGeoTileFetcherQGC::setUserAgent(const QByteArray &userAgent)
{
m_userAgent = userAgent;
}
QGeoTiledMapReply *QGeoTileFetcherQGC::getTileImage(const QGeoTileSpec &spec)
{
QNetworkRequest request;
QString url = m_UrlFactory.makeImageUrl((OpenPilot::MapType)spec.mapId(), QPoint(spec.x(), spec.y()), spec.zoom(), m_Language);
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;
}
QNetworkReply *reply = m_networkManager->get(request);
reply->setParent(0);
return new QGeoMapReplyQGC(reply, spec);
}
QT_END_NAMESPACE
/****************************************************************************
**
** Copyright (C) 2013 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:LGPL$
** 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 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
** 2015.4.4
** Adapted for use with QGroundControl
**
** Gus Grubba <mavlink@grubba.com>
**
****************************************************************************/
#ifndef QGEOTILEFETCHERGOOGLE_H
#define QGEOTILEFETCHERGOOGLE_H
#include <QtLocation/private/qgeotilefetcher_p.h>
#include <QtLocation/private/qgeotilecache_p.h>
#include "OpenPilotMaps.h"
QT_BEGIN_NAMESPACE
class QGeoTiledMappingManagerEngine;
class QNetworkAccessManager;
class QGeoTileFetcherQGC : public QGeoTileFetcher
{
Q_OBJECT
public:
explicit QGeoTileFetcherQGC(QGeoTiledMappingManagerEngine *parent = 0);
void setUserAgent(const QByteArray &userAgent);
private:
QGeoTiledMapReply* getTileImage(const QGeoTileSpec &spec);
QNetworkAccessManager* m_networkManager;
QByteArray m_userAgent;
OpenPilot::UrlFactory m_UrlFactory;
QString m_Language;
};
QT_END_NAMESPACE
#endif // QGEOTILEFETCHERGOOGLE_H
This diff is collapsed.
This diff is collapsed.
......@@ -101,6 +101,14 @@ int main(int argc, char *argv[])
// anyway to silence the debug output.
qRegisterMetaType<QSerialPort::SerialPortError>();
qRegisterMetaType<QAbstractSocket::SocketError>();
// We statically link to the google QtLocation plugin
#ifdef Q_OS_WIN
// In Windows, the compiler doesn't see the use of the class created by Q_IMPORT_PLUGIN
#pragma warning( disable : 4930 4101 )
#endif
Q_IMPORT_PLUGIN(QGeoServiceProviderFactoryQGC)
bool runUnitTests = false; // Run unit tests
......
This diff is collapsed.
......@@ -86,7 +86,7 @@ QGCFlightDisplay::~QGCFlightDisplay()
_refreshTimer->stop();
}
void QGCFlightDisplay::saveSetting(const QString& name, bool value)
void QGCFlightDisplay::saveSetting(const QString &name, const QString& value)
{
QSettings settings;
QString key(kMainFlightDisplayGroup);
......@@ -94,12 +94,12 @@ void QGCFlightDisplay::saveSetting(const QString& name, bool value)
settings.setValue(key, value);
}
bool QGCFlightDisplay::loadSetting(const QString& name, bool defaultValue)
QString QGCFlightDisplay::loadSetting(const QString &name, const QString& defaultValue)
{
QSettings settings;
QString key(kMainFlightDisplayGroup);
key += "/" + name;
return settings.value(key, defaultValue).toBool();
return settings.value(key, defaultValue).toString();
}
void QGCFlightDisplay::_forgetUAS(UASInterface* uas)
......
......@@ -54,8 +54,8 @@ public:
Q_PROPERTY(float latitude READ latitude NOTIFY latitudeChanged)
Q_PROPERTY(float longitude READ longitude NOTIFY longitudeChanged)
Q_INVOKABLE void saveSetting (const QString &key, bool value);
Q_INVOKABLE bool loadSetting (const QString &key, bool defaultValue);
Q_INVOKABLE void saveSetting (const QString &key, const QString& value);
Q_INVOKABLE QString loadSetting (const QString &key, const QString& defaultValue);
float roll () { return _roll; }
float pitch () { return _pitch; }
......
......@@ -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