Commit 8624fb71 authored by dogmaphobic's avatar dogmaphobic

Fixed Google Satellite

Download Speed Tweaks (+2 squashed commits)
Squashed commits:
[ff0ef7e] Cleanup (remove OpenStreetMap)
[370fa1d] Done (+25 squashed commits)
Squashed commits:
[9f3368f] Need to check how many instances of MapEngine are active.
[d557eac] Download Optimization
[392f50a] Almost there.
Trying to optimize download.
[a49d1d2] Settings
[a94be97] Mostly there. Needs to finish options and map thumbnail.
[38d5a0b] Downloading tiles and deleting sets
[81101b9] More UI Work
[c597d4b] Downloading tiles
[a815e35] Get rid of OpenMaps
[7e177ea] More reorg
[fa6b671] Start handling create tile set
Fix signal order when creating fetch tile task
[2a31f4d] Refactoring
[268b906] Renaming things
[947d66e] Fix resource load error.
[19e2de8] Adding MapBox
[c73e627] Preparing download
[87bbf22] UI Tweaks
[3c32a86] A lot of UI code done.
[ece8ce2] Starting to deal with tiles
[7f387bc] Save tile set
[f66f343] Adding more code
[4de3418] Working
[f0cc25d] Done for the night.
[2d1d86e] Added SQL database for holding out own tile cache.
[d405a87] Convert to camel case as this has been driving me nuts.
parent 7891f53c
......@@ -139,6 +139,7 @@
<file alias="buttonRight.svg">resources/buttonRight.svg</file>
<file alias="JoystickBezel.png">resources/JoystickBezel.png</file>
<file alias="JoystickBezelLight.png">resources/JoystickBezelLight.png</file>
<file alias="notile.png">resources/notile.png</file>
<file alias="Pause">resources/Pause.svg</file>
<file alias="Play">resources/Play.svg</file>
<file alias="PowerButton">resources/PowerButton.svg</file>
......
......@@ -203,6 +203,8 @@ INCLUDEPATH += \
src/ui/uas \
src/VehicleSetup \
src/ViewWidgets \
src/QtLocationPlugin \
src/QtLocationPlugin/QMLControl \
FORMS += \
src/ui/MainWindow.ui \
......@@ -284,7 +286,8 @@ HEADERS += \
src/AutoPilotPlugins/PX4/PX4AirframeLoader.h \
src/AutoPilotPlugins/APM/APMAirframeLoader.h \
src/QmlControls/QGCImageProvider.h \
src/AutoPilotPlugins/APM/APMRemoteParamsDownloader.h
src/AutoPilotPlugins/APM/APMRemoteParamsDownloader.h \
src/QtLocationPlugin/QMLControl/QGCMapEngineManager.h \
DebugBuild {
HEADERS += \
......@@ -405,7 +408,8 @@ SOURCES += \
src/AutoPilotPlugins/PX4/PX4AirframeLoader.cc \
src/AutoPilotPlugins/APM/APMAirframeLoader.cc \
src/QmlControls/QGCImageProvider.cc \
src/AutoPilotPlugins/APM/APMRemoteParamsDownloader.cc
src/AutoPilotPlugins/APM/APMRemoteParamsDownloader.cc \
src/QtLocationPlugin/QMLControl/QGCMapEngineManager.cc \
DebugBuild {
SOURCES += \
......
......@@ -27,6 +27,7 @@
<file alias="MavlinkSettings.qml">src/ui/preferences/MavlinkSettings.qml</file>
<file alias="MockLink.qml">src/ui/preferences/MockLink.qml</file>
<file alias="MockLinkSettings.qml">src/ui/preferences/MockLinkSettings.qml</file>
<file alias="OfflineMap.qml">src/QtLocationPlugin/QMLControl/OfflineMap.qml</file>
<file alias="SerialSettings.qml">src/ui/preferences/SerialSettings.qml</file>
<file alias="TcpSettings.qml">src/ui/preferences/TcpSettings.qml</file>
<file alias="UdpSettings.qml">src/ui/preferences/UdpSettings.qml</file>
......@@ -139,6 +140,7 @@
<file alias="SetupView.qml">src/VehicleSetup/SetupView.qml</file>
<file alias="test.qml">src/test.qml</file>
<file alias="VehicleSummary.qml">src/VehicleSetup/VehicleSummary.qml</file>
<file alias="QGroundControl/Controls/OfflineMapButton.qml">src/QmlControls/OfflineMapButton.qml</file>
</qresource>
<qresource prefix="/json">
<file alias="MavCmdInfoCommon.json">src/MissionManager/MavCmdInfoCommon.json</file>
......
......@@ -43,7 +43,7 @@ void FlightMapSettings::setToolbox(QGCToolbox *toolbox)
qmlRegisterUncreatableType<FlightMapSettings> ("QGroundControl", 1, 0, "FlightMapSetting", "Reference only");
_supportedMapProviders << "Bing" << "Google" << "OpenStreetMap";
_supportedMapProviders << "Bing" << "Google"; // << "OpenStreetMap";
_loadSettings();
}
......@@ -93,8 +93,10 @@ void FlightMapSettings::_setMapTypesForCurrentProvider(void)
_mapTypes << "Street Map" << "Satellite Map" << "Hybrid Map";
} else if (_mapProvider == "Google") {
_mapTypes << "Street Map" << "Satellite Map" << "Terrain Map";
/*
} else if (_mapProvider == "OpenStreetMap") {
_mapTypes << "Street Map";
*/
}
emit mapTypesChanged(_mapTypes);
......
......@@ -34,6 +34,7 @@
#include "MultiVehicleManager.h"
#include "QGCImageProvider.h"
#include "UASMessageHandler.h"
#include "QGCMapEngineManager.h"
QGCToolbox::QGCToolbox(QGCApplication* app)
: _audioOutput(NULL)
......@@ -48,6 +49,7 @@ QGCToolbox::QGCToolbox(QGCApplication* app)
, _mavlinkProtocol(NULL)
, _missionCommands(NULL)
, _multiVehicleManager(NULL)
, _mapEngineManager(NULL)
, _uasMessageHandler(NULL)
{
_audioOutput = new GAudioOutput(app);
......@@ -62,6 +64,7 @@ QGCToolbox::QGCToolbox(QGCApplication* app)
_mavlinkProtocol = new MAVLinkProtocol(app);
_missionCommands = new MissionCommands(app);
_multiVehicleManager = new MultiVehicleManager(app);
_mapEngineManager = new QGCMapEngineManager(app);
_uasMessageHandler = new UASMessageHandler(app);
_audioOutput->setToolbox(this);
......@@ -76,6 +79,7 @@ QGCToolbox::QGCToolbox(QGCApplication* app)
_mavlinkProtocol->setToolbox(this);
_missionCommands->setToolbox(this);
_multiVehicleManager->setToolbox(this);
_mapEngineManager->setToolbox(this);
_uasMessageHandler->setToolbox(this);
}
......@@ -91,6 +95,7 @@ QGCToolbox::~QGCToolbox()
delete _linkManager;
delete _mavlinkProtocol;
delete _missionCommands;
delete _mapEngineManager;
delete _multiVehicleManager;
delete _uasMessageHandler;
}
......
......@@ -37,6 +37,7 @@ class LinkManager;
class MAVLinkProtocol;
class MissionCommands;
class MultiVehicleManager;
class QGCMapEngineManager;
class QGCApplication;
class QGCImageProvider;
class UASMessageHandler;
......@@ -58,6 +59,7 @@ public:
MAVLinkProtocol* mavlinkProtocol(void) { return _mavlinkProtocol; }
MissionCommands* missionCommands(void) { return _missionCommands; }
MultiVehicleManager* multiVehicleManager(void) { return _multiVehicleManager; }
QGCMapEngineManager* mapEngineManager(void) { return _mapEngineManager; }
QGCImageProvider* imageProvider() { return _imageProvider; }
UASMessageHandler* uasMessageHandler(void) { return _uasMessageHandler; }
......@@ -74,6 +76,7 @@ private:
MAVLinkProtocol* _mavlinkProtocol;
MissionCommands* _missionCommands;
MultiVehicleManager* _multiVehicleManager;
QGCMapEngineManager* _mapEngineManager;
UASMessageHandler* _uasMessageHandler;
};
......
import QtQuick 2.5
import QtQuick.Controls 1.2
import QGroundControl.Palette 1.0
import QGroundControl.ScreenTools 1.0
Rectangle
{
id: __mapButton
property var __qgcPal: QGCPalette { colorGroupEnabled: enabled }
property bool __showHighlight: (__pressed | __hovered | checked) && !__forceHoverOff
property bool __forceHoverOff: false
property int __lastGlobalMouseX: 0
property int __lastGlobalMouseY: 0
property bool __pressed: false
property bool __hovered: false
property bool checked: false
property bool complete: false
property alias text: nameLabel.text
property alias size: sizeLabel.text
signal clicked()
color: __showHighlight ? __qgcPal.buttonHighlight : __qgcPal.button
anchors.margins: ScreenTools.defaultFontPixelWidth
Row {
anchors.centerIn: parent
QGCLabel {
id: nameLabel
width: __mapButton.width * 0.4
color: __showHighlight ? __qgcPal.buttonHighlightText : __qgcPal.buttonText
anchors.verticalCenter: parent.verticalCenter
}
QGCLabel {
id: sizeLabel
width: __mapButton.width * 0.4
horizontalAlignment: Text.AlignRight
anchors.verticalCenter: parent.verticalCenter
color: __showHighlight ? __qgcPal.buttonHighlightText : __qgcPal.buttonText
}
Item {
width: ScreenTools.defaultFontPixelWidth * 2
height: 1
}
Rectangle {
width: sizeLabel.height * 0.5
height: sizeLabel.height * 0.5
radius: width / 2
color: complete ? "#31f55b" : "#fc5656"
opacity: sizeLabel.text.length > 0 ? 1 : 0
anchors.verticalCenter: parent.verticalCenter
}
Item {
width: ScreenTools.defaultFontPixelWidth * 2
height: 1
}
QGCColoredImage {
width: sizeLabel.height * 0.8
height: sizeLabel.height * 0.8
source: "/res/buttonRight.svg"
mipmap: true
fillMode: Image.PreserveAspectFit
color: __showHighlight ? __qgcPal.buttonHighlightText : __qgcPal.buttonText
anchors.verticalCenter: parent.verticalCenter
}
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onMouseXChanged: {
__lastGlobalMouseX = ScreenTools.mouseX()
__lastGlobalMouseY = ScreenTools.mouseY()
}
onMouseYChanged: {
__lastGlobalMouseX = ScreenTools.mouseX()
__lastGlobalMouseY = ScreenTools.mouseY()
}
onEntered: { __hovered = true; __forceHoverOff = false; hoverTimer.start() }
onExited: { __hovered = false; __forceHoverOff = false; hoverTimer.stop() }
onPressed: { __pressed = true; }
onReleased: { __pressed = false; }
onClicked: {
__mapButton.clicked()
}
}
Timer {
id: hoverTimer
interval: 250
repeat: true
onTriggered: {
if (__lastGlobalMouseX !== ScreenTools.mouseX() || __lastGlobalMouseY !== ScreenTools.mouseY()) {
__forceHoverOff = true
} else {
__forceHoverOff = false
}
}
}
}
......@@ -35,3 +35,4 @@ SubMenuButton 1.0 SubMenuButton.qml
VehicleRotationCal 1.0 VehicleRotationCal.qml
VehicleSummaryRow 1.0 VehicleSummaryRow.qml
ViewWidget 1.0 ViewWidget.qml
OfflineMapButton 1.0 OfflineMapButton.qml
......@@ -39,6 +39,7 @@ QGroundControlQmlGlobal::QGroundControlQmlGlobal(QGCApplication* app)
, _linkManager(NULL)
, _missionCommands(NULL)
, _multiVehicleManager(NULL)
, _mapEngineManager(NULL)
, _virtualTabletJoystick(false)
, _offlineEditingFirmwareTypeFact(QString(), "OfflineEditingFirmwareType", FactMetaData::valueTypeUint32, (uint32_t)MAV_AUTOPILOT_ARDUPILOTMEGA)
, _offlineEditingFirmwareTypeMetaData(FactMetaData::valueTypeUint32)
......@@ -65,12 +66,12 @@ QGroundControlQmlGlobal::~QGroundControlQmlGlobal()
void QGroundControlQmlGlobal::setToolbox(QGCToolbox* toolbox)
{
QGCTool::setToolbox(toolbox);
_flightMapSettings = toolbox->flightMapSettings();
_homePositionManager = toolbox->homePositionManager();
_linkManager = toolbox->linkManager();
_missionCommands = toolbox->missionCommands();
_multiVehicleManager = toolbox->multiVehicleManager();
_flightMapSettings = toolbox->flightMapSettings();
_homePositionManager = toolbox->homePositionManager();
_linkManager = toolbox->linkManager();
_missionCommands = toolbox->missionCommands();
_multiVehicleManager = toolbox->multiVehicleManager();
_mapEngineManager = toolbox->mapEngineManager();
}
......
......@@ -55,6 +55,7 @@ public:
Q_PROPERTY(LinkManager* linkManager READ linkManager CONSTANT)
Q_PROPERTY(MissionCommands* missionCommands READ missionCommands CONSTANT)
Q_PROPERTY(MultiVehicleManager* multiVehicleManager READ multiVehicleManager CONSTANT)
Q_PROPERTY(QGCMapEngineManager* mapEngineManager READ mapEngineManager CONSTANT)
Q_PROPERTY(qreal zOrderTopMost READ zOrderTopMost CONSTANT) ///< z order for top most items, toolbar, main window sub view
Q_PROPERTY(qreal zOrderWidgets READ zOrderWidgets CONSTANT) ///< z order value to widgets, for example: zoom controls, hud widgetss
......@@ -95,9 +96,10 @@ public:
FlightMapSettings* flightMapSettings () { return _flightMapSettings; }
HomePositionManager* homePositionManager () { return _homePositionManager; }
LinkManager* linkManager () { return _linkManager; }
MissionCommands* missionCommands () { return _missionCommands; }
LinkManager* linkManager () { return _linkManager; }
MissionCommands* missionCommands () { return _missionCommands; }
MultiVehicleManager* multiVehicleManager () { return _multiVehicleManager; }
QGCMapEngineManager* mapEngineManager () { return _mapEngineManager; }
qreal zOrderTopMost () { return 1000; }
qreal zOrderWidgets () { return 100; }
......@@ -149,6 +151,7 @@ private:
LinkManager* _linkManager;
MissionCommands* _missionCommands;
MultiVehicleManager* _multiVehicleManager;
QGCMapEngineManager* _mapEngineManager;
bool _virtualTabletJoystick;
......
This diff is collapsed.
......@@ -17,22 +17,29 @@ contains(QT_VERSION, 5.5.1) {
}
HEADERS += \
$$PWD/qgeoserviceproviderpluginqgc.h \
$$PWD/qgeotiledmappingmanagerengineqgc.h \
$$PWD/qgeotilefetcherqgc.h \
$$PWD/qgeomapreplyqgc.h \
$$PWD/qgeocodingmanagerengineqgc.h \
$$PWD/qgeocodereplyqgc.h \
$$PWD/OpenPilotMaps.h
$$PWD/QGCMapEngine.h \
$$PWD/QGCMapEngineData.h \
$$PWD/QGCMapTileSet.h \
$$PWD/QGCMapUrlEngine.h \
$$PWD/QGCTileCacheWorker.h \
$$PWD/QGeoCodeReplyQGC.h \
$$PWD/QGeoCodingManagerEngineQGC.h \
$$PWD/QGeoMapReplyQGC.h \
$$PWD/QGeoServiceProviderPluginQGC.h \
$$PWD/QGeoTileFetcherQGC.h \
$$PWD/QGeoTiledMappingManagerEngineQGC.h \
SOURCES += \
$$PWD/qgeoserviceproviderpluginqgc.cpp \
$$PWD/qgeotiledmappingmanagerengineqgc.cpp \
$$PWD/qgeotilefetcherqgc.cpp \
$$PWD/qgeomapreplyqgc.cpp \
$$PWD/qgeocodingmanagerengineqgc.cpp \
$$PWD/qgeocodereplyqgc.cpp \
$$PWD/OpenPilotMaps.cc
$$PWD/QGCMapEngine.cpp \
$$PWD/QGCMapTileSet.cpp \
$$PWD/QGCMapUrlEngine.cpp \
$$PWD/QGCTileCacheWorker.cpp \
$$PWD/QGeoCodeReplyQGC.cpp \
$$PWD/QGeoCodingManagerEngineQGC.cpp \
$$PWD/QGeoMapReplyQGC.cpp \
$$PWD/QGeoServiceProviderPluginQGC.cpp \
$$PWD/QGeoTileFetcherQGC.cpp \
$$PWD/QGeoTiledMappingManagerEngineQGC.cpp \
OTHER_FILES += \
$$PWD/qgc_maps_plugin.json
This diff is collapsed.
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2016 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 Map Tile Cache
*
* @author Gus Grubba <mavlink@grubba.com>
*
*/
#ifndef QGC_MAP_ENGINE_H
#define QGC_MAP_ENGINE_H
#include <QString>
#include "QGCMapUrlEngine.h"
#include "QGCMapEngineData.h"
#include "QGCTileCacheWorker.h"
//-----------------------------------------------------------------------------
class QGCTileSet
{
public:
QGCTileSet()
{
clear();
}
QGCTileSet& operator += (QGCTileSet& other)
{
tileX0 += other.tileX0;
tileX1 += other.tileX1;
tileY0 += other.tileY0;
tileY1 += other.tileY1;
tileCount += other.tileCount;
tileSize += other.tileSize;
return *this;
}
void clear()
{
tileX0 = 0;
tileX1 = 0;
tileY0 = 0;
tileY1 = 0;
tileCount = 0;
tileSize = 0;
}
int tileX0;
int tileX1;
int tileY0;
int tileY1;
quint64 tileCount;
quint64 tileSize;
};
//-----------------------------------------------------------------------------
class QGCMapEngine : public QObject
{
Q_OBJECT
public:
QGCMapEngine ();
~QGCMapEngine ();
void init ();
void addTask (QGCMapTask *task);
void cacheTile (UrlFactory::MapType type, int x, int y, int z, const QByteArray& image, const QString& format, qulonglong set = UINT64_MAX);
void cacheTile (UrlFactory::MapType type, const QString& hash, const QByteArray& image, const QString& format, qulonglong set = UINT64_MAX);
QGCFetchTileTask* createFetchTileTask (UrlFactory::MapType type, int x, int y, int z);
QStringList getMapNameList ();
const QString userAgent () { return _userAgent; }
void setUserAgent (const QString& ua) { _userAgent = ua; }
UrlFactory::MapType hashToType (const QString& hash);
QString getMapBoxToken ();
void setMapBoxToken (const QString& token);
quint32 getMaxDiskCache ();
void setMaxDiskCache (quint32 size);
quint32 getMaxMemCache ();
void setMaxMemCache (quint32 size);
const QString getCachePath () { return _cachePath; }
const QString getCacheFilename () { return _cacheFile; }
UrlFactory* urlFactory () { return _urlFactory; }
//-- Tile Math
static QGCTileSet getTileCount (int zoom, double topleftLon, double topleftLat, double bottomRightLon, double bottomRightLat, UrlFactory::MapType mapType);
static int long2tileX (double lon, int z);
static int lat2tileY (double lat, int z);
static QString getTileHash (UrlFactory::MapType type, int x, int y, int z);
static UrlFactory::MapType getTypeFromName (const QString &name);
static QString bigSizeToString (quint64 size);
static QString numberToString (quint32 number);
static int concurrentDownloads (UrlFactory::MapType type);
private slots:
void _updateTotals (quint32 totaltiles, quint64 totalsize, quint32 defaulttiles, quint64 defaultsize);
void _pruned ();
signals:
void updateTotals (quint32 totaltiles, quint64 totalsize, quint32 defaulttiles, quint64 defaultsize);
private:
QGCCacheWorker _worker;
QString _cachePath;
QString _cacheFile;
QString _mapBoxToken;
UrlFactory* _urlFactory;
QString _userAgent;
quint32 _maxDiskCache;
quint32 _maxMemCache;
bool _prunning;
};
extern QGCMapEngine* getQGCMapEngine();
extern void destroyMapEngine();
#endif // QGC_MAP_ENGINE_H
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2016 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 Map Tile Cache Data
*
* @author Gus Grubba <mavlink@grubba.com>
*
*/
#ifndef QGC_MAP_ENGINE_DATA_H
#define QGC_MAP_ENGINE_DATA_H
#include <QObject>
#include <QString>
#include <QHash>
#include <QDateTime>
#include "QGCMapUrlEngine.h"
class QGCCachedTileSet;
//-----------------------------------------------------------------------------
class QGCTile : public QObject
{
Q_OBJECT
public:
QGCTile()
: _x(0)
, _y(0)
, _z(0)
, _set(UINT64_MAX)
, _type(UrlFactory::Invalid)
{
}
QGCTile(const QGCTile& other)
: _x(other.x())
, _y(other.y())
, _z(other.z())
, _set(other.set())
, _hash(other.hash())
, _type(other.type())
{
}
enum TyleState {
StatePending = 0,
StateDownloading,
StateError,
StateComplete
};
int x () const { return _x; }
int y () const { return _y; }
int z () const { return _z; }
qulonglong set () const { return _set; }
const QString hash () const { return _hash; }
UrlFactory::MapType type () const { return _type; }
void setX (int x) { _x = x; }
void setY (int y) { _y = y; }
void setZ (int z) { _z = z; }
void setTileSet (qulonglong set) { _set = set; }
void setHash (const QString& hash) { _hash = hash; }
void setType (UrlFactory::MapType type) { _type = type; }
private:
int _x;
int _y;
int _z;
qulonglong _set;
QString _hash;
UrlFactory::MapType _type;
};
//-----------------------------------------------------------------------------
class QGCCacheTile : public QObject
{
Q_OBJECT
public:
QGCCacheTile (const QString hash, const QByteArray img, const QString format, UrlFactory::MapType type, qulonglong set = UINT64_MAX)
: _set(set)
, _hash(hash)
, _img(img)
, _format(format)
, _type(type)
{
}
QGCCacheTile (const QString hash, qulonglong set)
: _set(set)
, _hash(hash)
{
}
qulonglong set () { return _set; }
QString hash () { return _hash; }
QByteArray img () { return _img; }
QString format () { return _format;}
UrlFactory::MapType type () { return _type; }
private:
qulonglong _set;
QString _hash;
QByteArray _img;
QString _format;
UrlFactory::MapType _type;
};
//-----------------------------------------------------------------------------
class QGCMapTask : public QObject
{
Q_OBJECT
public:
enum TaskType {
taskInit,
taskCacheTile,
taskFetchTile,
taskFetchTileSets,
taskCreateTileSet,
taskGetTileDownloadList,
taskUpdateTileDownloadState,
taskDeleteTileSet,
taskPruneCache,
taskReset
};
QGCMapTask(TaskType type)
: _type(type)
{}
virtual ~QGCMapTask()
{}
virtual TaskType type () { return _type; }
void setError(QString errorString)
{
emit error(_type, errorString);
}
signals:
void error (QGCMapTask::TaskType type, QString errorString);
private:
TaskType _type;
};
//-----------------------------------------------------------------------------
class QGCFetchTileSetTask : public QGCMapTask
{
Q_OBJECT
public:
QGCFetchTileSetTask()
: QGCMapTask(QGCMapTask::taskFetchTileSets)
{}
void setTileSetFetched(QGCCachedTileSet* tileSet)
{
emit tileSetFetched(tileSet);
}
signals:
void tileSetFetched (QGCCachedTileSet* tileSet);
};
//-----------------------------------------------------------------------------
class QGCCreateTileSetTask : public QGCMapTask
{
Q_OBJECT
public:
QGCCreateTileSetTask(QGCCachedTileSet* tileSet)
: QGCMapTask(QGCMapTask::taskCreateTileSet)
, _tileSet(tileSet)
, _saved(false)
{}
~QGCCreateTileSetTask();
QGCCachedTileSet* tileSet () { return _tileSet; }
void setTileSetSaved()
{
//-- Flag as saved. Signalee wll maintain it.
_saved = true;
emit tileSetSaved(_tileSet);
}
signals:
void tileSetSaved (QGCCachedTileSet* tileSet);
private:
QGCCachedTileSet* _tileSet;
bool _saved;
};
//-----------------------------------------------------------------------------
class QGCFetchTileTask : public QGCMapTask
{
Q_OBJECT
public:
QGCFetchTileTask(const QString hash)
: QGCMapTask(QGCMapTask::taskFetchTile)
, _hash(hash)
{}
~QGCFetchTileTask()
{
}
void setTileFetched(QGCCacheTile* tile)
{
emit tileFetched(tile);
}
QString hash() { return _hash; }
signals:
void tileFetched (QGCCacheTile* tile);
private:
QString _hash;
};
//-----------------------------------------------------------------------------
class QGCSaveTileTask : public QGCMapTask
{
Q_OBJECT
public:
QGCSaveTileTask(QGCCacheTile* tile)
: QGCMapTask(QGCMapTask::taskCacheTile)
, _tile(tile)
{}
~QGCSaveTileTask()
{
if(_tile)
delete _tile;
}
QGCCacheTile* tile() { return _tile; }
private:
QGCCacheTile* _tile;
};
//-----------------------------------------------------------------------------
class QGCGetTileDownloadListTask : public QGCMapTask
{
Q_OBJECT
public:
QGCGetTileDownloadListTask(qulonglong setID, int count)
: QGCMapTask(QGCMapTask::taskGetTileDownloadList)
, _setID(setID)
, _count(count)
{}
qulonglong setID() { return _setID; }
int count() { return _count; }
void setTileListFetched(QList<QGCTile*> tiles)
{
emit tileListFetched(tiles);
}
signals:
void tileListFetched (QList<QGCTile*> tiles);
private:
qulonglong _setID;
int _count;
};
//-----------------------------------------------------------------------------
class QGCUpdateTileDownloadStateTask : public QGCMapTask
{
Q_OBJECT
public:
QGCUpdateTileDownloadStateTask(qulonglong setID, QGCTile::TyleState state, const QString& hash)
: QGCMapTask(QGCMapTask::taskUpdateTileDownloadState)
, _setID(setID)
, _state(state)
, _hash(hash)
{}
QString hash () { return _hash; }
qulonglong setID () { return _setID; }
QGCTile::TyleState state () { return _state; }
private:
qulonglong _setID;
QGCTile::TyleState _state;
QString _hash;
};
//-----------------------------------------------------------------------------
class QGCDeleteTileSetTask : public QGCMapTask
{
Q_OBJECT
public:
QGCDeleteTileSetTask(qulonglong setID)
: QGCMapTask(QGCMapTask::taskDeleteTileSet)
, _setID(setID)
{}
qulonglong setID() { return _setID; }
void setTileSetDeleted()
{
emit tileSetDeleted(_setID);
}
signals:
void tileSetDeleted(qulonglong setID);
private:
qulonglong _setID;
};
//-----------------------------------------------------------------------------
class QGCPruneCacheTask : public QGCMapTask
{
Q_OBJECT
public:
QGCPruneCacheTask(quint64 amount)
: QGCMapTask(QGCMapTask::taskPruneCache)
, _amount(amount)
{}
quint64 amount() { return _amount; }
void setPruned()
{
emit pruned();
}
signals:
void pruned();
private:
quint64 _amount;
};
//-----------------------------------------------------------------------------
class QGCResetTask : public QGCMapTask
{
Q_OBJECT
public:
QGCResetTask()
: QGCMapTask(QGCMapTask::taskReset)
{}
void setResetCompleted()
{
emit resetCompleted();
}
signals:
void resetCompleted();
};
#endif // QGC_MAP_ENGINE_DATA_H
This diff is collapsed.
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2016 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 Map Tile Set
*
* @author Gus Grubba <mavlink@grubba.com>
*
*/
#ifndef QGC_MAP_TILE_SET_H
#define QGC_MAP_TILE_SET_H
#include <QObject>
#include <QString>
#include <QHash>
#include <QDateTime>
#include <QImage>
#include "QGCLoggingCategory.h"
#include "QGCMapEngineData.h"
#include "QGCMapUrlEngine.h"
Q_DECLARE_LOGGING_CATEGORY(QGCCachedTileSetLog)
class QGCTile;
class QGCMapEngineManager;
//-----------------------------------------------------------------------------
class QGCCachedTileSet : public QObject
{
Q_OBJECT
public:
QGCCachedTileSet (const QString& name, const QString& description);
~QGCCachedTileSet ();
Q_PROPERTY(QString name READ name CONSTANT)
Q_PROPERTY(QString description READ description CONSTANT)
Q_PROPERTY(QString mapTypeStr READ mapTypeStr CONSTANT)
Q_PROPERTY(double topleftLon READ topleftLon CONSTANT)
Q_PROPERTY(double topleftLat READ topleftLat CONSTANT)
Q_PROPERTY(double bottomRightLon READ bottomRightLon CONSTANT)
Q_PROPERTY(double bottomRightLat READ bottomRightLat CONSTANT)
Q_PROPERTY(int minZoom READ minZoom CONSTANT)
Q_PROPERTY(int maxZoom READ maxZoom CONSTANT)
Q_PROPERTY(quint32 numTiles READ numTiles NOTIFY numTilesChanged)
Q_PROPERTY(QString numTilesStr READ numTilesStr NOTIFY numTilesChanged)
Q_PROPERTY(quint64 tilesSize READ tilesSize NOTIFY tilesSizeChanged)
Q_PROPERTY(QString tilesSizeStr READ tilesSizeStr NOTIFY tilesSizeChanged)
Q_PROPERTY(quint32 savedTiles READ savedTiles NOTIFY savedTilesChanged)
Q_PROPERTY(QString savedTilesStr READ savedTilesStr NOTIFY savedTilesChanged)
Q_PROPERTY(quint64 savedSize READ savedSize NOTIFY savedSizeChanged)
Q_PROPERTY(QString savedSizeStr READ savedSizeStr NOTIFY savedSizeChanged)
Q_PROPERTY(QString downloadStatus READ downloadStatus NOTIFY savedSizeChanged)
Q_PROPERTY(QDateTime creationDate READ creationDate CONSTANT)
Q_PROPERTY(bool complete READ complete NOTIFY completeChanged)
Q_PROPERTY(bool defaultSet READ defaultSet CONSTANT)
Q_PROPERTY(quint64 setID READ setID CONSTANT)
Q_PROPERTY(bool deleting READ deleting NOTIFY deletingChanged)
Q_PROPERTY(bool downloading READ downloading NOTIFY downloadingChanged)
Q_PROPERTY(quint32 errorCount READ errorCount NOTIFY errorCountChanged)
Q_PROPERTY(QString errorCountStr READ errorCountStr NOTIFY errorCountChanged)
Q_PROPERTY(QImage thumbNail READ thumbNail CONSTANT)
Q_INVOKABLE void createDownloadTask ();
Q_INVOKABLE void resumeDownloadTask ();
Q_INVOKABLE void cancelDownloadTask ();
void setManager (QGCMapEngineManager* mgr);
QString name () { return _name; }
QString description () { return _description; }
QString mapTypeStr () { return _mapTypeStr; }
double topleftLat () { return _topleftLat; }
double topleftLon () { return _topleftLon; }
double bottomRightLat () { return _bottomRightLat; }
double bottomRightLon () { return _bottomRightLon; }
quint32 numTiles () { return (quint32)_numTiles; }
QString numTilesStr ();
quint64 tilesSize () { return (quint64)_tilesSize; }
QString tilesSizeStr ();
quint32 savedTiles () { return (quint32)_savedTiles; }
QString savedTilesStr ();
quint64 savedSize () { return (quint64)_savedSize; }
QString savedSizeStr ();
QString downloadStatus ();
int minZoom () { return _minZoom; }
int maxZoom () { return _maxZoom; }
QDateTime creationDate () { return _creationDate; }
quint64 id () { return _id; }
UrlFactory::MapType type () { return _type; }
bool complete () { return _defaultSet || (_numTiles == _savedTiles); }
bool defaultSet () { return _defaultSet; }
quint64 setID () { return _id; }
bool deleting () { return _deleting; }
bool downloading () { return _downloading; }
quint32 errorCount () { return _errorCount; }
QString errorCountStr ();
QImage thumbNail () { return _thumbNail; }
void setName (QString name) { _name = name; }
void setDescription (QString desc) { _description = desc; }
void setMapTypeStr (QString typeStr) { _mapTypeStr = typeStr; }
void setTopleftLat (double lat) { _topleftLat = lat; }
void setTopleftLon (double lon) { _topleftLon = lon; }
void setBottomRightLat (double lat) { _bottomRightLat = lat; }
void setBottomRightLon (double lon) { _bottomRightLon = lon; }
void setNumTiles (quint32 num) { _numTiles = num; }
void setTilesSize (quint64 size) { _tilesSize = size; }
void setSavedTiles (quint32 num) { _savedTiles = num; emit savedTilesChanged(); }
void setSavedSize (quint64 size) { _savedSize = size; emit savedSizeChanged(); }
void setMinZoom (int zoom) { _minZoom = zoom; }
void setMaxZoom (int zoom) { _maxZoom = zoom; }
void setCreationDate (QDateTime date) { _creationDate = date; }
void setId (quint64 id) { _id = id; }
void setType (UrlFactory::MapType type) { _type = type; }
void setDefaultSet (bool def) { _defaultSet = def; }
void setDeleting (bool del) { _deleting = del; emit deletingChanged(); }
void setDownloading (bool down) { _downloading = down; }
void setThumbNail (const QImage& thumb) { _thumbNail = thumb; }
signals:
void deletingChanged ();
void downloadingChanged ();
void numTilesChanged ();
void tilesSizeChanged ();
void savedTilesChanged ();
void savedSizeChanged ();
void completeChanged ();
void errorCountChanged ();
private slots:
void _tileListFetched (QList<QGCTile*> tiles);
void _networkReplyFinished ();
void _networkReplyError (QNetworkReply::NetworkError error);
private:
void _prepareDownload ();
private:
QString _name;
QString _description;
QString _mapTypeStr;
double _topleftLat;
double _topleftLon;
double _bottomRightLat;
double _bottomRightLon;
quint32 _numTiles;
quint64 _tilesSize;
quint32 _savedTiles;
quint64 _savedSize;
int _minZoom;
int _maxZoom;
bool _defaultSet;
bool _deleting;
bool _downloading;
QDateTime _creationDate;
quint64 _id;
UrlFactory::MapType _type;
QNetworkAccessManager* _networkManager;
QHash<QString, QNetworkReply*> _replies;
quint32 _errorCount;
//-- Tile download
QList<QGCTile *> _tilesToDownload;
bool _noMoreTiles;
bool _batchRequested;
QGCMapEngineManager* _manager;
QImage _thumbNail;
};
#endif // QGC_MAP_TILE_SET_H
This diff is collapsed.
......@@ -2,7 +2,7 @@
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
(c) 2009, 2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
......@@ -23,13 +23,11 @@ This file is part of the QGROUNDCONTROL project
/**
* @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
#ifndef QGC_MAP_URL_ENGINE_H
#define QGC_MAP_URL_ENGINE_H
#include <QString>
#include <QPoint>
......@@ -38,107 +36,57 @@ This file is part of the QGROUNDCONTROL project
#include <QNetworkReply>
#include <QMutex>
#define MAX_MAP_ZOOM (20.0)
#define MAX_MAP_ZOOM (18.0)
namespace OpenPilot {
class UrlFactory : public QObject {
Q_OBJECT
public:
enum MapType
{
Invalid = -1,
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 QObject {
Q_OBJECT
public:
ProviderStrings();
static const QString kLevelsForSigPacSpainMap[];
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 ProviderStrings {
Q_OBJECT
public:
UrlFactory(QNetworkAccessManager* network);
~UrlFactory();
QString makeImageUrl (const MapType &type, const QPoint &pos, const int &zoom, const QString &language);
MapQuestMap = 700,
MapQuestSat = 701,
MapBoxStreets = 6000,
MapBoxLight = 6001,
MapBoxDark = 6002,
MapBoxSatellite = 6003,
MapBoxHybrid = 6004,
MapBoxWheatPaste = 6005,
MapBoxStreetsBasic = 6006,
MapBoxComic = 6007,
MapBoxOutdoors = 6008,
MapBoxRunBikeHike = 6009,
MapBoxPencil = 6010,
MapBoxPirates = 6011,
MapBoxEmerald = 6012,
MapBoxHighContrast = 6013
};
UrlFactory ();
~UrlFactory ();
QNetworkRequest getTileURL (MapType type, int x, int y, int zoom, QNetworkAccessManager* networkManager);
QString getImageFormat (MapType type, const QByteArray& image);
static quint32 averageSizeForType (MapType type);
private slots:
void _networkReplyError (QNetworkReply::NetworkError error);
......@@ -146,19 +94,28 @@ private slots:
void _replyDestroyed ();
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;
int _timeout;
bool _googleVersionRetrieved;
QNetworkAccessManager* _network;
QNetworkReply* _googleReply;
QMutex _googleVersionMutex;
QByteArray _userAgent;
};
QString _getURL (MapType type, int x, int y, int zoom, QNetworkAccessManager* networkManager);
void _getSecGoogleWords (int x, int y, QString& sec1, QString& sec2);
int _getServerNum (int x, int y, int max);
void _tryCorrectGoogleVersions (QNetworkAccessManager* networkManager);
QString _tileXYToQuadKey (int tileX, int tileY, int levelOfDetail);
int _timeout;
bool _googleVersionRetrieved;
QNetworkReply* _googleReply;
QMutex _googleVersionMutex;
QByteArray _userAgent;
QString _language;
// Google version strings
QString _versionGoogleMap;
QString _versionGoogleSatellite;
QString _versionGoogleLabels;
QString _versionGoogleTerrain;
QString _secGoogleWord;
// BingMaps
QString _versionBingMaps;
}
};
#endif // FOO_H
#endif
This diff is collapsed.
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2016 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 Map Tile Cache Worker Thread
*
* @author Gus Grubba <mavlink@grubba.com>
*
*/
#ifndef QGC_TILE_CACHE_WORKER_H
#define QGC_TILE_CACHE_WORKER_H
#include <QString>
#include <QThread>
#include <QQueue>
#include <QMutex>
#include <QWaitCondition>
#include <QMutexLocker>
#include <QtSql/QSqlDatabase>
#include "QGCLoggingCategory.h"
Q_DECLARE_LOGGING_CATEGORY(QGCTileCacheLog)
class QGCMapTask;
class QGCCachedTileSet;
//-----------------------------------------------------------------------------
class QGCCacheWorker : public QThread
{
Q_OBJECT
public:
QGCCacheWorker ();
~QGCCacheWorker ();
void quit ();
bool enqueueTask (QGCMapTask* task);
void setDatabaseFile (const QString& path);
protected:
void run ();
private:
void _saveTile (QGCMapTask* mtask);
void _getTile (QGCMapTask* mtask);
void _getTileSets (QGCMapTask* mtask);
void _createTileSet (QGCMapTask* mtask);
void _getTileDownloadList (QGCMapTask* mtask);
void _updateTileDownloadState(QGCMapTask* mtask);
void _deleteTileSet (QGCMapTask* mtask);
void _resetCacheDatabase (QGCMapTask* mtask);
void _pruneCache (QGCMapTask* mtask);
bool _findTile (const QString hash);
bool _findTileSetID (const QString name, quint64& setID);
void _updateSetTotals (QGCCachedTileSet* set);
bool _init ();
void _createDB ();
quint64 _getDefaultTileSet ();
void _updateTotals ();
signals:
void updateTotals (quint32 totaltiles, quint64 totalsize, quint32 defaulttiles, quint64 defaultsize);
private:
QQueue<QGCMapTask*> _taskQueue;
QMutex _mutex;
QMutex _waitmutex;
QWaitCondition _waitc;
QString _databasePath;
QSqlDatabase* _db;
bool _valid;
bool _failed;
quint64 _defaultSet;
quint64 _totalSize;
quint32 _totalCount;
quint64 _defaultSize;
quint32 _defaultCount;
time_t _lastUpdate;
int _updateTimeout;
};
#endif // QGC_TILE_CACHE_WORKER_H
......@@ -54,7 +54,7 @@
#include <QSet>
#include <QDebug>
#include "qgeocodereplyqgc.h"
#include "QGeoCodeReplyQGC.h"
enum QGeoCodeTypeGoogle {
GeoCodeTypeUnknown,
......
......@@ -44,8 +44,8 @@
**
****************************************************************************/
#ifndef QGEOCODEREPLYGOOGLE_H
#define QGEOCODEREPLYGOOGLE_H
#ifndef QGEOCODEREPLYQGC_H
#define QGEOCODEREPLYQGC_H
#include <QtNetwork/QNetworkReply>
#include <QtLocation/QGeoCodeReply>
......@@ -68,4 +68,4 @@ private:
QNetworkReply *m_reply;
};
#endif // QGEOCODEREPLYGOOGLE_H
#endif // QGEOCODEREPLYQGC_H
......@@ -57,8 +57,8 @@
#include <QtPositioning/QGeoRectangle>
#include <QDebug>
#include "qgeocodingmanagerengineqgc.h"
#include "qgeocodereplyqgc.h"
#include "QGeoCodingManagerEngineQGC.h"
#include "QGeoCodeReplyQGC.h"
static QString addressToQuery(const QGeoAddress &address)
{
......
......@@ -44,8 +44,8 @@
**
****************************************************************************/
#ifndef QGEOCODINGMANAGERENGINEGOOGLE_H
#define QGEOCODINGMANAGERENGINEGOOGLE_H
#ifndef QGEOCODINGMANAGERENGINEQGC_H
#define QGEOCODINGMANAGERENGINEQGC_H
#include <QtLocation/QGeoServiceProvider>
#include <QtLocation/QGeoCodingManagerEngine>
......@@ -78,4 +78,4 @@ private:
QT_END_NAMESPACE
#endif // QGEOCODINGMANAGERENGINEGOOGLE_H
#endif // QGEOCODINGMANAGERENGINEQGC_H
......@@ -45,114 +45,127 @@
****************************************************************************/
#include <QtLocation/private/qgeotilespec_p.h>
#include <QtNetwork/QNetworkAccessManager>
#include <QFile>
#include "qgeomapreplyqgc.h"
#include "OpenPilotMaps.h"
#include "QGCMapEngine.h"
#include "QGeoMapReplyQGC.h"
QGeoMapReplyQGC::QGeoMapReplyQGC(QNetworkReply *reply, const QGeoTileSpec &spec, QObject *parent)
//-----------------------------------------------------------------------------
QGeoTiledMapReplyQGC::QGeoTiledMapReplyQGC(QNetworkAccessManager *networkManager, const QNetworkRequest &request, const QGeoTileSpec &spec, QObject *parent)
: QGeoTiledMapReply(spec, parent)
, m_reply(reply)
, _reply(NULL)
, _request(request)
, _networkManager(networkManager)
{
if(!reply)
{
setError(QGeoTiledMapReply::UnknownError, "Invalid tile request");
if(_request.url().isEmpty()) {
if(!_badMapBox.size()) {
QFile b(":/res/notile.png");
if(b.open(QFile::ReadOnly))
_badMapBox = b.readAll();
}
setMapImageData(_badMapBox);
setMapImageFormat("png");
setFinished(true);
}
else
{
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()));
setCached(false);
} else {
QGCFetchTileTask* task = getQGCMapEngine()->createFetchTileTask((UrlFactory::MapType)spec.mapId(), spec.x(), spec.y(), spec.zoom());
connect(task, &QGCFetchTileTask::tileFetched, this, &QGeoTiledMapReplyQGC::cacheReply);
connect(task, &QGCMapTask::error, this, &QGeoTiledMapReplyQGC::cacheError);
getQGCMapEngine()->addTask(task);
}
}
QGeoMapReplyQGC::~QGeoMapReplyQGC()
//-----------------------------------------------------------------------------
QGeoTiledMapReplyQGC::~QGeoTiledMapReplyQGC()
{
if (m_reply) {
m_reply->deleteLater();
m_reply = 0;
if (_reply) {
_reply->deleteLater();
_reply = 0;
}
}
void QGeoMapReplyQGC::abort()
{
if (!m_reply)
return;
m_reply->abort();
}
QNetworkReply *QGeoMapReplyQGC::networkReply() const
//-----------------------------------------------------------------------------
void
QGeoTiledMapReplyQGC::abort()
{
return m_reply;
if (_reply)
_reply->abort();
}
void QGeoMapReplyQGC::replyDestroyed()
//-----------------------------------------------------------------------------
void
QGeoTiledMapReplyQGC::replyDestroyed()
{
m_reply = 0;
_reply = 0;
}
void QGeoMapReplyQGC::networkReplyFinished()
//-----------------------------------------------------------------------------
void
QGeoTiledMapReplyQGC::networkReplyFinished()
{
if (!m_reply)
{
if (!_reply) {
return;
}
if (m_reply->error() != QNetworkReply::NoError)
{
if (_reply->error() != QNetworkReply::NoError) {
return;
}
QByteArray a = m_reply->readAll();
QByteArray a = _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;
}
}
QString format = getQGCMapEngine()->urlFactory()->getImageFormat((UrlFactory::MapType)tileSpec().mapId(), a);
if(!format.isEmpty()) {
setMapImageFormat(format);
getQGCMapEngine()->cacheTile((UrlFactory::MapType)tileSpec().mapId(), tileSpec().x(), tileSpec().y(), tileSpec().zoom(), a, format);
}
setFinished(true);
m_reply->deleteLater();
m_reply = 0;
_reply->deleteLater();
_reply = 0;
}
void QGeoMapReplyQGC::networkReplyError(QNetworkReply::NetworkError error)
//-----------------------------------------------------------------------------
void
QGeoTiledMapReplyQGC::networkReplyError(QNetworkReply::NetworkError error)
{
if (!m_reply)
{
if (!_reply) {
return;
}
if (error != QNetworkReply::OperationCanceledError) {
qWarning() << "Fetch tile error:" << _reply->errorString();
}
_reply->deleteLater();
_reply = 0;
if(!_badTile.size()) {
QFile b(":/res/notile.png");
if(b.open(QFile::ReadOnly))
_badTile = b.readAll();
}
setMapImageData(_badTile);
setMapImageFormat("png");
setFinished(true);
setCached(false);
}
if (error != QNetworkReply::OperationCanceledError)
{
setError(QGeoTiledMapReply::CommunicationError, m_reply->errorString());
//-----------------------------------------------------------------------------
void
QGeoTiledMapReplyQGC::cacheError(QGCMapTask::TaskType type, QString /*errorString*/)
{
if(type != QGCMapTask::taskFetchTile) {
qWarning() << "QGeoTiledMapReplyQGC::cacheError() for wrong task";
}
//-- Tile not in cache. Get it off the Internet.
_reply = _networkManager->get(_request);
_reply->setParent(0);
connect(_reply, SIGNAL(finished()), this, SLOT(networkReplyFinished()));
connect(_reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(networkReplyError(QNetworkReply::NetworkError)));
connect(_reply, SIGNAL(destroyed()), this, SLOT(replyDestroyed()));
}
//-----------------------------------------------------------------------------
void
QGeoTiledMapReplyQGC::cacheReply(QGCCacheTile* tile)
{
setMapImageData(tile->img());
setMapImageFormat(tile->format());
setFinished(true);
m_reply->deleteLater();
m_reply = 0;
setCached(true);
tile->deleteLater();
}
......@@ -44,31 +44,35 @@
**
****************************************************************************/
#ifndef QGEOMAPREPLYGOOGLE_H
#define QGEOMAPREPLYGOOGLE_H
#ifndef QGEOMAPREPLYQGC_H
#define QGEOMAPREPLYQGC_H
#include <QtNetwork/QNetworkReply>
#include <QtLocation/private/qgeotiledmapreply_p.h>
class QGeoMapReplyQGC : public QGeoTiledMapReply
#include "QGCMapEngineData.h"
class QGeoTiledMapReplyQGC : public QGeoTiledMapReply
{
Q_OBJECT
public:
explicit QGeoMapReplyQGC(QNetworkReply *reply, const QGeoTileSpec &spec, QObject *parent = 0);
~QGeoMapReplyQGC();
QGeoTiledMapReplyQGC(QNetworkAccessManager* networkManager, const QNetworkRequest& request, const QGeoTileSpec &spec, QObject *parent = 0);
~QGeoTiledMapReplyQGC();
void abort();
QNetworkReply *networkReply() const;
private Q_SLOTS:
private slots:
void replyDestroyed ();
void networkReplyFinished ();
void networkReplyError (QNetworkReply::NetworkError error);
void cacheReply (QGCCacheTile* tile);
void cacheError (QGCMapTask::TaskType type, QString errorString);
private:
QNetworkReply* m_reply;
QNetworkReply* _reply;
QNetworkRequest _request;
QNetworkAccessManager* _networkManager;
QByteArray _badMapBox;
QByteArray _badTile;
};
#endif // QGEOMAPREPLYGOOGLE_H
#endif // QGEOMAPREPLYQGC_H
......@@ -47,38 +47,48 @@
#include <QtLocation/private/qgeotiledmappingmanagerengine_p.h>
#include "qdebug.h"
#include "qgeoserviceproviderpluginqgc.h"
#include "qgeotiledmappingmanagerengineqgc.h"
#include "qgeocodingmanagerengineqgc.h"
#include "QGeoServiceProviderPluginQGC.h"
#include "QGeoTiledMappingManagerEngineQGC.h"
#include "QGeoCodingManagerEngineQGC.h"
Q_EXTERN_C Q_DECL_EXPORT const char *qt_plugin_query_metadata();
Q_EXTERN_C Q_DECL_EXPORT QT_PREPEND_NAMESPACE(QObject) *qt_plugin_instance();
//-----------------------------------------------------------------------------
const QT_PREPEND_NAMESPACE(QStaticPlugin) qt_static_plugin_QGeoServiceProviderFactoryQGC()
{
QT_PREPEND_NAMESPACE(QStaticPlugin) plugin = { qt_plugin_instance, qt_plugin_query_metadata};
return plugin;
}
QGeoCodingManagerEngine *QGeoServiceProviderFactoryQGC::createGeocodingManagerEngine(
//-----------------------------------------------------------------------------
QGeoCodingManagerEngine*
QGeoServiceProviderFactoryQGC::createGeocodingManagerEngine(
const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString) const
{
return new QGeoCodingManagerEngineQGC(parameters, error, errorString);
}
QGeoMappingManagerEngine *QGeoServiceProviderFactoryQGC::createMappingManagerEngine(
//-----------------------------------------------------------------------------
QGeoMappingManagerEngine*
QGeoServiceProviderFactoryQGC::createMappingManagerEngine(
const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString) const
{
return new QGeoTiledMappingManagerEngineQGC(parameters, error, errorString);
}
QGeoRoutingManagerEngine *QGeoServiceProviderFactoryQGC::createRoutingManagerEngine(
//-----------------------------------------------------------------------------
QGeoRoutingManagerEngine*
QGeoServiceProviderFactoryQGC::createRoutingManagerEngine(
const QVariantMap &, QGeoServiceProvider::Error *, QString *) const
{
// Not implemented for QGC
return NULL;
}
QPlaceManagerEngine *QGeoServiceProviderFactoryQGC::createPlaceManagerEngine(
//-----------------------------------------------------------------------------
QPlaceManagerEngine*
QGeoServiceProviderFactoryQGC::createPlaceManagerEngine(
const QVariantMap &, QGeoServiceProvider::Error *, QString *) const
{
// Not implemented for QGC
......
......@@ -44,8 +44,8 @@
**
****************************************************************************/
#ifndef QGEOSERVICEPROVIDER_GOOGLE_H
#define QGEOSERVICEPROVIDER_GOOGLE_H
#ifndef QGEOSERVICEPROVIDERQGC_H
#define QGEOSERVICEPROVIDERQGC_H
#include <QtCore/QObject>
#include <QtLocation/QGeoServiceProviderFactory>
......@@ -64,4 +64,4 @@ public:
QPlaceManagerEngine* createPlaceManagerEngine (const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString) const;
};
#endif // QGEOSERVICEPROVIDER_GOOGLE_H
#endif // QGEOSERVICEPROVIDERQGC_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/QNetworkRequest>
#include <QtLocation/private/qgeotilespec_p.h>
#include "QGCMapEngine.h"
#include "QGeoTileFetcherQGC.h"
#include "QGeoMapReplyQGC.h"
//-----------------------------------------------------------------------------
QGeoTileFetcherQGC::QGeoTileFetcherQGC(QGeoTiledMappingManagerEngine *parent)
: QGeoTileFetcher(parent)
, _networkManager(new QNetworkAccessManager(this))
{
}
//-----------------------------------------------------------------------------
QGeoTileFetcherQGC::~QGeoTileFetcherQGC()
{
}
//-----------------------------------------------------------------------------
QGeoTiledMapReply*
QGeoTileFetcherQGC::getTileImage(const QGeoTileSpec &spec)
{
//-- Build URL
QNetworkRequest request = getQGCMapEngine()->urlFactory()->getTileURL((UrlFactory::MapType)spec.mapId(), spec.x(), spec.y(), spec.zoom(), _networkManager);
return new QGeoTiledMapReplyQGC(_networkManager, request, spec);
}
......@@ -44,12 +44,12 @@
**
****************************************************************************/
#ifndef QGEOTILEFETCHERGOOGLE_H
#define QGEOTILEFETCHERGOOGLE_H
#ifndef QGEOTILEFETCHERQGC_H
#define QGEOTILEFETCHERQGC_H
#include <QtLocation/private/qgeotilefetcher_p.h>
#include <QtLocation/private/qgeotilecache_p.h>
#include "OpenPilotMaps.h"
#include "QGCMapUrlEngine.h"
class QGeoTiledMappingManagerEngine;
class QNetworkAccessManager;
......@@ -57,19 +57,13 @@ class QNetworkAccessManager;
class QGeoTileFetcherQGC : public QGeoTileFetcher
{
Q_OBJECT
public:
explicit QGeoTileFetcherQGC(QGeoTiledMappingManagerEngine *parent = 0);
explicit QGeoTileFetcherQGC (QGeoTiledMappingManagerEngine *parent = 0);
~QGeoTileFetcherQGC();
void setUserAgent(const QByteArray &userAgent);
private:
QGeoTiledMapReply* getTileImage(const QGeoTileSpec &spec);
QNetworkAccessManager* m_networkManager;
QByteArray m_userAgent;
OpenPilot::UrlFactory* m_UrlFactory;
QString m_Language;
QGeoTiledMapReply* getTileImage (const QGeoTileSpec &spec);
private:
QNetworkAccessManager* _networkManager;
};
#endif // QGEOTILEFETCHERGOOGLE_H
#endif // QGEOTILEFETCHERQGC_H
......@@ -44,8 +44,8 @@
**
****************************************************************************/
#ifndef QGEOTILEDMAPPINGMANAGERENGINEGOOGLE_H
#define QGEOTILEDMAPPINGMANAGERENGINEGOOGLE_H
#ifndef QGEOTILEDMAPPINGMANAGERENGINEQGC_H
#define QGEOTILEDMAPPINGMANAGERENGINEQGC_H
#include <QtLocation/QGeoServiceProvider>
#if QT_VERSION >= 0x050500
......@@ -62,6 +62,8 @@ public:
};
#endif
class QGeoTileFetcherQGC;
class QGeoTiledMappingManagerEngineQGC : public QGeoTiledMappingManagerEngine
{
Q_OBJECT
......@@ -81,4 +83,4 @@ private:
#endif
};
#endif // QGEOTILEDMAPPINGMANAGERENGINEGOOGLE_H
#endif // QGEOTILEDMAPPINGMANAGERENGINEQGC_H
This diff is collapsed.
This diff is collapsed.
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2016 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
/// @author Gus Grubba <mavlink@grubba.com>
#ifndef OfflineMapsManager_H
#define OfflineMapsManager_H
#include "QmlObjectListModel.h"
#include "QGCToolbox.h"
#include "QGCLoggingCategory.h"
#include "QGCMapEngine.h"
#include "QGCMapTileSet.h"
Q_DECLARE_LOGGING_CATEGORY(QGCMapEngineManagerLog)
class QGCMapEngineManager : public QGCTool
{
Q_OBJECT
public:
QGCMapEngineManager(QGCApplication* app);
~QGCMapEngineManager();
Q_PROPERTY(int tileX0 READ tileX0 NOTIFY tileX0Changed)
Q_PROPERTY(int tileX1 READ tileX1 NOTIFY tileX1Changed)
Q_PROPERTY(int tileY0 READ tileY0 NOTIFY tileY0Changed)
Q_PROPERTY(int tileY1 READ tileY1 NOTIFY tileY1Changed)
Q_PROPERTY(quint64 tileCount READ tileCount NOTIFY tileCountChanged)
Q_PROPERTY(QString tileCountStr READ tileCountStr NOTIFY tileCountChanged)
Q_PROPERTY(quint64 tileSize READ tileSize NOTIFY tileSizeChanged)
Q_PROPERTY(QString tileSizeStr READ tileSizeStr NOTIFY tileSizeChanged)
Q_PROPERTY(bool crazySize READ crazySize NOTIFY crazySizeChanged)
Q_PROPERTY(QmlObjectListModel* tileSets READ tileSets NOTIFY tileSetsChanged)
Q_PROPERTY(QStringList mapList READ mapList CONSTANT)
Q_PROPERTY(QString mapboxToken READ mapboxToken WRITE setMapboxToken NOTIFY mapboxTokenChanged)
Q_PROPERTY(quint32 maxMemCache READ maxMemCache WRITE setMaxMemCache NOTIFY maxMemCacheChanged)
Q_PROPERTY(quint32 maxDiskCache READ maxDiskCache WRITE setMaxDiskCache NOTIFY maxDiskCacheChanged)
Q_PROPERTY(QString errorMessage READ errorMessage NOTIFY errorMessageChanged)
//-- Disk Space in MB
Q_PROPERTY(quint32 freeDiskSpace READ freeDiskSpace NOTIFY freeDiskSpaceChanged)
Q_PROPERTY(quint32 diskSpace READ diskSpace CONSTANT)
Q_INVOKABLE void loadTileSets ();
Q_INVOKABLE void updateForCurrentView (double lon0, double lat0, double lon1, double lat1, int minZoom, int maxZoom, const QString& mapName);
Q_INVOKABLE void startDownload (const QString& name, const QString& description, const QString& mapType, const QImage& image = QImage());
Q_INVOKABLE void saveSetting (const QString& key, const QString& value);
Q_INVOKABLE QString loadSetting (const QString& key, const QString& defaultValue);
Q_INVOKABLE void deleteTileSet (QGCCachedTileSet* tileSet);
Q_INVOKABLE QString getUniqueName ();
Q_INVOKABLE bool findName (const QString& name);
int tileX0 () { return _totalSet.tileX0; }
int tileX1 () { return _totalSet.tileX1; }
int tileY0 () { return _totalSet.tileY0; }
int tileY1 () { return _totalSet.tileY1; }
quint64 tileCount () { return _totalSet.tileCount; }
QString tileCountStr ();
quint64 tileSize () { return _totalSet.tileSize; }
QString tileSizeStr ();
bool crazySize () { return _crazySize; }
QStringList mapList ();
QString mapboxToken ();
QmlObjectListModel* tileSets () { return &_tileSets; }
quint32 maxMemCache ();
quint32 maxDiskCache ();
QString errorMessage () { return _errorMessage; }
quint64 freeDiskSpace () { return _freeDiskSpace; }
quint64 diskSpace () { return _diskSpace; }
void setMapboxToken (QString token);
void setMaxMemCache (quint32 size);
void setMaxDiskCache (quint32 size);
void setErrorMessage (const QString& error) { _errorMessage = error; emit errorMessageChanged(); }
// Override from QGCTool
void setToolbox(QGCToolbox *toolbox);
signals:
void tileX0Changed ();
void tileX1Changed ();
void tileY0Changed ();
void tileY1Changed ();
void tileCountChanged ();
void tileSizeChanged ();
void crazySizeChanged ();
void mapboxTokenChanged ();
void tileSetsChanged ();
void maxMemCacheChanged ();
void maxDiskCacheChanged ();
void errorMessageChanged ();
void freeDiskSpaceChanged ();
public slots:
void taskError (QGCMapTask::TaskType type, QString error);
private slots:
void _tileSetSaved (QGCCachedTileSet* set);
void _tileSetFetched (QGCCachedTileSet* tileSets);
void _tileSetDeleted (quint64 setID);
void _updateTotals (quint32 totaltiles, quint64 totalsize, quint32 defaulttiles, quint64 defaultsize);
void _resetCompleted ();
private:
void _clearTileSets ();
void _updateDiskFreeSpace ();
private:
QGCTileSet _totalSet;
bool _crazySize;
double _topleftLat;
double _topleftLon;
double _bottomRightLat;
double _bottomRightLon;
int _minZoom;
int _maxZoom;
quint64 _setID;
quint32 _freeDiskSpace;
quint32 _diskSpace;
QmlObjectListModel _tileSets;
QString _errorMessage;
};
#endif
/****************************************************************************
**
** 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"
QGeoTileFetcherQGC::QGeoTileFetcherQGC(QGeoTiledMappingManagerEngine *parent)
: QGeoTileFetcher(parent)
, m_networkManager(new QNetworkAccessManager(this))
#if defined Q_OS_MAC
, m_userAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101 Firefox/21.0")
#elif defined Q_OS_WIN32
, m_userAgent("Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7")
#else
, m_userAgent("Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:21.0) Gecko/20130331 Firefox/21.0")
#endif
, m_UrlFactory(NULL)
{
QStringList langs = QLocale::system().uiLanguages();
if (langs.length() > 0) {
m_Language = langs[0];
}
m_UrlFactory = new OpenPilot::UrlFactory(m_networkManager);
}
QGeoTileFetcherQGC::~QGeoTileFetcherQGC()
{
if(m_UrlFactory)
delete m_UrlFactory;
}
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);
}
......@@ -56,6 +56,7 @@ This file is part of the QGROUNDCONTROL project
#endif
#include <iostream>
#include "QGCMapEngine.h"
/* SDL does ugly things to main() */
#ifdef main
......@@ -218,6 +219,8 @@ int main(int argc, char *argv[])
qRegisterMetaType<QList<QPair<QByteArray,QByteArray> > >();
app->_initCommon();
//-- Initialize Cache System
getQGCMapEngine()->init();
int exitCode = 0;
......@@ -251,6 +254,8 @@ int main(int argc, char *argv[])
}
delete app;
//-- Shutdown Cache System
destroyMapEngine();
qDebug() << "After app delete";
......
......@@ -174,6 +174,19 @@ Item {
checked = true
}
}
QGCButton {
width: parent.width * 0.85
height: ScreenTools.defaultFontPixelHeight * 2.5
text: "Offline Maps"
exclusiveGroup: panelActionGroup
anchors.horizontalCenter: parent.horizontalCenter
onClicked: {
if(__rightPanel.source != "OfflineMap.qml") {
__rightPanel.source = "OfflineMap.qml"
}
checked = true
}
}
QGCButton {
width: parent.width * 0.85
height: ScreenTools.defaultFontPixelHeight * 2.5
......
......@@ -133,7 +133,6 @@ Rectangle {
height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width
}
//-----------------------------------------------------------------
//-- Map Providers
Row {
......
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