Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
0878dfa2
Commit
0878dfa2
authored
Mar 22, 2017
by
Gus Grubba
Committed by
GitHub
Mar 22, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4817 from dogmaphobic/exportTileSet
Map Tile Set Import/Export
parents
fbc34cc5
71813e49
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
974 additions
and
49 deletions
+974
-49
QGCMapEngineData.h
src/QtLocationPlugin/QGCMapEngineData.h
+78
-1
QGCMapTileSet.cpp
src/QtLocationPlugin/QGCMapTileSet.cpp
+12
-0
QGCMapTileSet.h
src/QtLocationPlugin/QGCMapTileSet.h
+6
-0
QGCTileCacheWorker.cpp
src/QtLocationPlugin/QGCTileCacheWorker.cpp
+310
-27
QGCTileCacheWorker.h
src/QtLocationPlugin/QGCTileCacheWorker.h
+4
-1
OfflineMap.qml
src/QtLocationPlugin/QMLControl/OfflineMap.qml
+380
-16
QGCMapEngineManager.cc
src/QtLocationPlugin/QMLControl/QGCMapEngineManager.cc
+147
-0
QGCMapEngineManager.h
src/QtLocationPlugin/QMLControl/QGCMapEngineManager.h
+33
-0
SetupView.qml
src/VehicleSetup/SetupView.qml
+4
-4
No files found.
src/QtLocationPlugin/QGCMapEngineData.h
View file @
0878dfa2
...
...
@@ -119,7 +119,9 @@ public:
taskUpdateTileDownloadState
,
taskDeleteTileSet
,
taskPruneCache
,
taskReset
taskReset
,
taskExport
,
taskImport
};
QGCMapTask
(
TaskType
type
)
...
...
@@ -365,5 +367,80 @@ signals:
void
resetCompleted
();
};
//-----------------------------------------------------------------------------
class
QGCExportTileTask
:
public
QGCMapTask
{
Q_OBJECT
public:
QGCExportTileTask
(
QVector
<
QGCCachedTileSet
*>
sets
,
QString
path
)
:
QGCMapTask
(
QGCMapTask
::
taskExport
)
,
_sets
(
sets
)
,
_path
(
path
)
{}
~
QGCExportTileTask
()
{
}
QVector
<
QGCCachedTileSet
*>
sets
()
{
return
_sets
;
}
QString
path
()
{
return
_path
;
}
void
setExportCompleted
()
{
emit
actionCompleted
();
}
void
setProgress
(
int
percentage
)
{
emit
actionProgress
(
percentage
);
}
private:
QVector
<
QGCCachedTileSet
*>
_sets
;
QString
_path
;
signals:
void
actionCompleted
();
void
actionProgress
(
int
percentage
);
};
//-----------------------------------------------------------------------------
class
QGCImportTileTask
:
public
QGCMapTask
{
Q_OBJECT
public:
QGCImportTileTask
(
QString
path
,
bool
replace
)
:
QGCMapTask
(
QGCMapTask
::
taskImport
)
,
_path
(
path
)
,
_replace
(
replace
)
{}
~
QGCImportTileTask
()
{
}
QString
path
()
{
return
_path
;
}
bool
replace
()
{
return
_replace
;
}
void
setImportCompleted
()
{
emit
actionCompleted
();
}
void
setProgress
(
int
percentage
)
{
emit
actionProgress
(
percentage
);
}
private:
QString
_path
;
bool
_replace
;
signals:
void
actionCompleted
();
void
actionProgress
(
int
percentage
);
};
#endif // QGC_MAP_ENGINE_DATA_H
src/QtLocationPlugin/QGCMapTileSet.cpp
View file @
0878dfa2
...
...
@@ -52,6 +52,7 @@ QGCCachedTileSet::QGCCachedTileSet(const QString& name)
,
_noMoreTiles
(
false
)
,
_batchRequested
(
false
)
,
_manager
(
NULL
)
,
_selected
(
false
)
{
}
...
...
@@ -349,3 +350,14 @@ QGCCachedTileSet::setManager(QGCMapEngineManager* mgr)
{
_manager
=
mgr
;
}
//-----------------------------------------------------------------------------
void
QGCCachedTileSet
::
setSelected
(
bool
sel
)
{
_selected
=
sel
;
emit
selectedChanged
();
if
(
_manager
)
{
emit
_manager
->
selectedCountChanged
();
}
}
src/QtLocationPlugin/QGCMapTileSet.h
View file @
0878dfa2
...
...
@@ -72,6 +72,8 @@ public:
Q_PROPERTY
(
quint32
errorCount
READ
errorCount
NOTIFY
errorCountChanged
)
Q_PROPERTY
(
QString
errorCountStr
READ
errorCountStr
NOTIFY
errorCountChanged
)
Q_PROPERTY
(
bool
selected
READ
selected
WRITE
setSelected
NOTIFY
selectedChanged
)
Q_INVOKABLE
void
createDownloadTask
();
Q_INVOKABLE
void
resumeDownloadTask
();
Q_INVOKABLE
void
cancelDownloadTask
();
...
...
@@ -109,7 +111,9 @@ public:
bool
downloading
()
{
return
_downloading
;
}
quint32
errorCount
()
{
return
_errorCount
;
}
QString
errorCountStr
();
bool
selected
()
{
return
_selected
;
}
void
setSelected
(
bool
sel
);
void
setName
(
QString
name
)
{
_name
=
name
;
}
void
setMapTypeStr
(
QString
typeStr
)
{
_mapTypeStr
=
typeStr
;
}
void
setTopleftLat
(
double
lat
)
{
_topleftLat
=
lat
;
}
...
...
@@ -142,6 +146,7 @@ signals:
void
savedTileSizeChanged
();
void
completeChanged
();
void
errorCountChanged
();
void
selectedChanged
();
private
slots
:
void
_tileListFetched
(
QList
<
QGCTile
*>
tiles
);
...
...
@@ -181,6 +186,7 @@ private:
bool
_noMoreTiles
;
bool
_batchRequested
;
QGCMapEngineManager
*
_manager
;
bool
_selected
;
};
#endif // QGC_MAP_TILE_SET_H
...
...
src/QtLocationPlugin/QGCTileCacheWorker.cpp
View file @
0878dfa2
This diff is collapsed.
Click to expand it.
src/QtLocationPlugin/QGCTileCacheWorker.h
View file @
0878dfa2
...
...
@@ -59,13 +59,16 @@ private:
void
_deleteTileSet
(
QGCMapTask
*
mtask
);
void
_resetCacheDatabase
(
QGCMapTask
*
mtask
);
void
_pruneCache
(
QGCMapTask
*
mtask
);
void
_exportSets
(
QGCMapTask
*
mtask
);
void
_importSets
(
QGCMapTask
*
mtask
);
bool
_testTask
(
QGCMapTask
*
mtask
);
void
_testInternet
();
quint64
_findTile
(
const
QString
hash
);
bool
_findTileSetID
(
const
QString
name
,
quint64
&
setID
);
void
_updateSetTotals
(
QGCCachedTileSet
*
set
);
bool
_init
();
void
_createDB
(
);
bool
_createDB
(
QSqlDatabase
*
db
,
bool
createDefault
=
true
);
quint64
_getDefaultTileSet
();
void
_updateTotals
();
...
...
src/QtLocationPlugin/QMLControl/OfflineMap.qml
View file @
0878dfa2
This diff is collapsed.
Click to expand it.
src/QtLocationPlugin/QMLControl/QGCMapEngineManager.cc
View file @
0878dfa2
...
...
@@ -11,6 +11,11 @@
/// @file
/// @author Gus Grubba <mavlink@grubba.com>
#if !defined(__mobile__)
#include "QGCFileDialog.h"
#include "MainWindow.h"
#endif
#include "QGCMapEngineManager.h"
#include "QGCApplication.h"
#include "QGCMapTileSet.h"
...
...
@@ -36,6 +41,9 @@ QGCMapEngineManager::QGCMapEngineManager(QGCApplication* app)
,
_setID
(
UINT64_MAX
)
,
_freeDiskSpace
(
0
)
,
_diskSpace
(
0
)
,
_actionProgress
(
0
)
,
_importAction
(
ActionNone
)
,
_importReplace
(
false
)
{
}
...
...
@@ -308,6 +316,9 @@ QGCMapEngineManager::taskError(QGCMapTask::TaskType type, QString error)
case
QGCMapTask
:
:
taskReset
:
task
=
"Reset Tile Sets"
;
break
;
case
QGCMapTask
:
:
taskExport
:
task
=
"Export Tile Sets"
;
break
;
default:
task
=
"Database Error"
;
break
;
...
...
@@ -351,6 +362,142 @@ QGCMapEngineManager::findName(const QString& name)
return
false
;
}
//-----------------------------------------------------------------------------
void
QGCMapEngineManager
::
selectAll
()
{
for
(
int
i
=
0
;
i
<
_tileSets
.
count
();
i
++
)
{
QGCCachedTileSet
*
set
=
qobject_cast
<
QGCCachedTileSet
*>
(
_tileSets
.
get
(
i
));
Q_ASSERT
(
set
);
set
->
setSelected
(
true
);
}
}
//-----------------------------------------------------------------------------
void
QGCMapEngineManager
::
selectNone
()
{
for
(
int
i
=
0
;
i
<
_tileSets
.
count
();
i
++
)
{
QGCCachedTileSet
*
set
=
qobject_cast
<
QGCCachedTileSet
*>
(
_tileSets
.
get
(
i
));
Q_ASSERT
(
set
);
set
->
setSelected
(
false
);
}
}
//-----------------------------------------------------------------------------
int
QGCMapEngineManager
::
selectedCount
()
{
int
count
=
0
;
for
(
int
i
=
0
;
i
<
_tileSets
.
count
();
i
++
)
{
QGCCachedTileSet
*
set
=
qobject_cast
<
QGCCachedTileSet
*>
(
_tileSets
.
get
(
i
));
Q_ASSERT
(
set
);
if
(
set
->
selected
())
{
count
++
;
}
}
return
count
;
}
//-----------------------------------------------------------------------------
bool
QGCMapEngineManager
::
importSets
(
QString
path
)
{
_importAction
=
ActionNone
;
emit
importActionChanged
();
QString
dir
=
path
;
if
(
dir
.
isEmpty
())
{
#if defined(__mobile__)
//-- TODO: This has to be something fixed
dir
=
QDir
(
QDir
::
homePath
()).
filePath
(
QString
(
"export_%1.db"
).
arg
(
QDateTime
::
currentDateTime
().
toTime_t
()));
#else
dir
=
QGCFileDialog
::
getOpenFileName
(
MainWindow
::
instance
(),
"Export Tile Set"
,
QDir
::
homePath
(),
"Tile Sets (*.qgctiledb)"
);
#endif
}
if
(
!
dir
.
isEmpty
())
{
_importAction
=
ActionImporting
;
emit
importActionChanged
();
QGCImportTileTask
*
task
=
new
QGCImportTileTask
(
dir
,
_importReplace
);
connect
(
task
,
&
QGCImportTileTask
::
actionCompleted
,
this
,
&
QGCMapEngineManager
::
_actionCompleted
);
connect
(
task
,
&
QGCImportTileTask
::
actionProgress
,
this
,
&
QGCMapEngineManager
::
_actionProgressHandler
);
connect
(
task
,
&
QGCMapTask
::
error
,
this
,
&
QGCMapEngineManager
::
taskError
);
getQGCMapEngine
()
->
addTask
(
task
);
return
true
;
}
return
false
;
}
//-----------------------------------------------------------------------------
bool
QGCMapEngineManager
::
exportSets
(
QString
path
)
{
_importAction
=
ActionNone
;
emit
importActionChanged
();
QString
dir
=
path
;
if
(
dir
.
isEmpty
())
{
#if defined(__mobile__)
dir
=
QDir
(
QDir
::
homePath
()).
filePath
(
QString
(
"export_%1.db"
).
arg
(
QDateTime
::
currentDateTime
().
toTime_t
()));
#else
dir
=
QGCFileDialog
::
getSaveFileName
(
MainWindow
::
instance
(),
"Export Tile Set"
,
QDir
::
homePath
(),
"Tile Sets (*.qgctiledb)"
,
"qgctiledb"
,
true
);
#endif
}
if
(
!
dir
.
isEmpty
())
{
QVector
<
QGCCachedTileSet
*>
sets
;
for
(
int
i
=
0
;
i
<
_tileSets
.
count
();
i
++
)
{
QGCCachedTileSet
*
set
=
qobject_cast
<
QGCCachedTileSet
*>
(
_tileSets
.
get
(
i
));
Q_ASSERT
(
set
);
if
(
set
->
selected
())
{
sets
.
append
(
set
);
}
}
if
(
sets
.
count
())
{
_importAction
=
ActionExporting
;
emit
importActionChanged
();
QGCExportTileTask
*
task
=
new
QGCExportTileTask
(
sets
,
dir
);
connect
(
task
,
&
QGCExportTileTask
::
actionCompleted
,
this
,
&
QGCMapEngineManager
::
_actionCompleted
);
connect
(
task
,
&
QGCExportTileTask
::
actionProgress
,
this
,
&
QGCMapEngineManager
::
_actionProgressHandler
);
connect
(
task
,
&
QGCMapTask
::
error
,
this
,
&
QGCMapEngineManager
::
taskError
);
getQGCMapEngine
()
->
addTask
(
task
);
return
true
;
}
}
return
false
;
}
//-----------------------------------------------------------------------------
void
QGCMapEngineManager
::
_actionProgressHandler
(
int
percentage
)
{
_actionProgress
=
percentage
;
emit
actionProgressChanged
();
}
//-----------------------------------------------------------------------------
void
QGCMapEngineManager
::
_actionCompleted
()
{
ImportAction
oldState
=
_importAction
;
_importAction
=
ActionDone
;
emit
importActionChanged
();
//-- If we just imported, reload it all
if
(
oldState
==
ActionImporting
)
{
loadTileSets
();
}
}
//-----------------------------------------------------------------------------
void
QGCMapEngineManager
::
resetAction
()
{
_importAction
=
ActionNone
;
emit
importActionChanged
();
}
//-----------------------------------------------------------------------------
QString
QGCMapEngineManager
::
getUniqueName
()
...
...
src/QtLocationPlugin/QMLControl/QGCMapEngineManager.h
View file @
0878dfa2
...
...
@@ -29,6 +29,14 @@ public:
QGCMapEngineManager
(
QGCApplication
*
app
);
~
QGCMapEngineManager
();
enum
ImportAction
{
ActionNone
,
ActionImporting
,
ActionExporting
,
ActionDone
,
};
Q_ENUMS
(
ImportAction
)
Q_PROPERTY
(
int
tileX0
READ
tileX0
NOTIFY
tileX0Changed
)
Q_PROPERTY
(
int
tileX1
READ
tileX1
NOTIFY
tileX1Changed
)
Q_PROPERTY
(
int
tileY0
READ
tileY0
NOTIFY
tileY0Changed
)
...
...
@@ -46,6 +54,12 @@ public:
//-- Disk Space in MB
Q_PROPERTY
(
quint32
freeDiskSpace
READ
freeDiskSpace
NOTIFY
freeDiskSpaceChanged
)
Q_PROPERTY
(
quint32
diskSpace
READ
diskSpace
CONSTANT
)
//-- Tile set export
Q_PROPERTY
(
int
selectedCount
READ
selectedCount
NOTIFY
selectedCountChanged
)
Q_PROPERTY
(
int
actionProgress
READ
actionProgress
NOTIFY
actionProgressChanged
)
Q_PROPERTY
(
ImportAction
importAction
READ
importAction
NOTIFY
importActionChanged
)
Q_PROPERTY
(
bool
importReplace
READ
importReplace
WRITE
setImportReplace
NOTIFY
importReplaceChanged
)
Q_INVOKABLE
void
loadTileSets
();
Q_INVOKABLE
void
updateForCurrentView
(
double
lon0
,
double
lat0
,
double
lon1
,
double
lat1
,
int
minZoom
,
int
maxZoom
,
const
QString
&
mapName
);
...
...
@@ -55,6 +69,11 @@ public:
Q_INVOKABLE
void
deleteTileSet
(
QGCCachedTileSet
*
tileSet
);
Q_INVOKABLE
QString
getUniqueName
();
Q_INVOKABLE
bool
findName
(
const
QString
&
name
);
Q_INVOKABLE
void
selectAll
();
Q_INVOKABLE
void
selectNone
();
Q_INVOKABLE
bool
exportSets
(
QString
path
=
QString
());
Q_INVOKABLE
bool
importSets
(
QString
path
=
QString
());
Q_INVOKABLE
void
resetAction
();
int
tileX0
()
{
return
_totalSet
.
tileX0
;
}
int
tileX1
()
{
return
_totalSet
.
tileX1
;
}
...
...
@@ -72,10 +91,15 @@ public:
QString
errorMessage
()
{
return
_errorMessage
;
}
quint64
freeDiskSpace
()
{
return
_freeDiskSpace
;
}
quint64
diskSpace
()
{
return
_diskSpace
;
}
int
selectedCount
();
int
actionProgress
()
{
return
_actionProgress
;
}
ImportAction
importAction
()
{
return
_importAction
;
}
bool
importReplace
()
{
return
_importReplace
;
}
void
setMapboxToken
(
QString
token
);
void
setMaxMemCache
(
quint32
size
);
void
setMaxDiskCache
(
quint32
size
);
void
setImportReplace
(
bool
replace
)
{
_importReplace
=
replace
;
emit
importReplaceChanged
();
}
void
setErrorMessage
(
const
QString
&
error
)
{
_errorMessage
=
error
;
emit
errorMessageChanged
();
}
...
...
@@ -95,6 +119,10 @@ signals:
void
maxDiskCacheChanged
();
void
errorMessageChanged
();
void
freeDiskSpaceChanged
();
void
selectedCountChanged
();
void
actionProgressChanged
();
void
importActionChanged
();
void
importReplaceChanged
();
public
slots
:
void
taskError
(
QGCMapTask
::
TaskType
type
,
QString
error
);
...
...
@@ -105,6 +133,8 @@ private slots:
void
_tileSetDeleted
(
quint64
setID
);
void
_updateTotals
(
quint32
totaltiles
,
quint64
totalsize
,
quint32
defaulttiles
,
quint64
defaultsize
);
void
_resetCompleted
();
void
_actionCompleted
();
void
_actionProgressHandler
(
int
percentage
);
private:
void
_updateDiskFreeSpace
();
...
...
@@ -122,6 +152,9 @@ private:
quint32
_diskSpace
;
QmlObjectListModel
_tileSets
;
QString
_errorMessage
;
int
_actionProgress
;
ImportAction
_importAction
;
bool
_importReplace
;
};
#endif
src/VehicleSetup/SetupView.qml
View file @
0878dfa2
...
...
@@ -232,14 +232,14 @@ Rectangle {
}
Repeater
{
model
:
_corePlugin
.
settingsPages
visible
:
_corePlugin
.
options
.
combineSettingsAndSetup
model
:
_corePlugin
?
_corePlugin
.
settingsPages
:
[]
visible
:
_corePlugin
&&
_corePlugin
.
options
.
combineSettingsAndSetup
SubMenuButton
{
imageResource
:
modelData
.
icon
setupIndicator
:
false
exclusiveGroup
:
setupButtonGroup
text
:
modelData
.
title
visible
:
_corePlugin
.
options
.
combineSettingsAndSetup
visible
:
_corePlugin
&&
_corePlugin
.
options
.
combineSettingsAndSetup
onClicked
:
panelLoader
.
setSource
(
modelData
.
url
)
Layout.fillWidth
:
true
}
...
...
@@ -312,7 +312,7 @@ Rectangle {
SubMenuButton
{
setupIndicator
:
false
exclusiveGroup
:
setupButtonGroup
visible
:
QGroundControl
.
multiVehicleManager
.
parameterReadyVehicleAvailable
&&
_corePlugin
.
showAdvancedUI
visible
:
QGroundControl
.
multiVehicleManager
&&
QGroundControl
.
multiVehicleManager
.
parameterReadyVehicleAvailable
&&
_corePlugin
.
showAdvancedUI
text
:
"
Parameters
"
Layout.fillWidth
:
true
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment