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
9f48f6a4
Commit
9f48f6a4
authored
Sep 19, 2019
by
Pierre TILAK
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move getTileCount to MapProvider
parent
83d7845e
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
115 additions
and
53 deletions
+115
-53
ElevationMapProvider.cpp
src/QtLocationPlugin/ElevationMapProvider.cpp
+19
-0
ElevationMapProvider.h
src/QtLocationPlugin/ElevationMapProvider.h
+3
-0
MapProvider.cpp
src/QtLocationPlugin/MapProvider.cpp
+19
-1
MapProvider.h
src/QtLocationPlugin/MapProvider.h
+6
-0
QGCLocationPlugin.pri
src/QtLocationPlugin/QGCLocationPlugin.pri
+2
-0
QGCMapEngine.cpp
src/QtLocationPlugin/QGCMapEngine.cpp
+2
-16
QGCMapEngine.h
src/QtLocationPlugin/QGCMapEngine.h
+0
-35
QGCMapUrlEngine.cpp
src/QtLocationPlugin/QGCMapUrlEngine.cpp
+21
-0
QGCMapUrlEngine.h
src/QtLocationPlugin/QGCMapUrlEngine.h
+5
-1
QGCTileSet.h
src/QtLocationPlugin/QGCTileSet.h
+38
-0
No files found.
src/QtLocationPlugin/ElevationMapProvider.cpp
View file @
9f48f6a4
...
...
@@ -37,3 +37,22 @@ AirmapElevationProvider::_getURL(int x, int y, int zoom,
.
arg
(
static_cast
<
double
>
(
x
+
1
)
*
srtm1TileSize
-
180.0
);
}
QGCTileSet
AirmapElevationProvider
::
getTileCount
(
int
zoom
,
double
topleftLon
,
double
topleftLat
,
double
bottomRightLon
,
double
bottomRightLat
)
{
QGCTileSet
set
;
set
.
tileX0
=
long2tileX
(
topleftLon
,
zoom
);
set
.
tileY0
=
lat2tileY
(
bottomRightLat
,
zoom
);
set
.
tileX1
=
long2tileX
(
bottomRightLon
,
zoom
);
set
.
tileY1
=
lat2tileY
(
topleftLat
,
zoom
);
set
.
tileCount
=
(
static_cast
<
quint64
>
(
set
.
tileX1
)
-
static_cast
<
quint64
>
(
set
.
tileX0
)
+
1
)
*
(
static_cast
<
quint64
>
(
set
.
tileY1
)
-
static_cast
<
quint64
>
(
set
.
tileY0
)
+
1
);
set
.
tileSize
=
getAverageSize
()
*
set
.
tileCount
;
return
set
;
}
src/QtLocationPlugin/ElevationMapProvider.h
View file @
9f48f6a4
...
...
@@ -41,6 +41,9 @@ class AirmapElevationProvider : public ElevationProvider {
int
long2tileX
(
double
lon
,
int
z
);
int
lat2tileY
(
double
lat
,
int
z
);
QGCTileSet
getTileCount
(
int
zoom
,
double
topleftLon
,
double
topleftLat
,
double
bottomRightLon
,
double
bottomRightLat
);
protected:
...
...
src/QtLocationPlugin/MapProvider.cpp
View file @
9f48f6a4
...
...
@@ -74,4 +74,22 @@ int MapProvider::lat2tileY(double lat, int z) {
2.0
*
pow
(
2.0
,
z
)));
}
bool
MapProvider
::
_isElevationProvider
(){
return
false
;}
bool
MapProvider
::
_isElevationProvider
()
{
return
false
;
}
QGCTileSet
MapProvider
::
getTileCount
(
int
zoom
,
double
topleftLon
,
double
topleftLat
,
double
bottomRightLon
,
double
bottomRightLat
)
{
QGCTileSet
set
;
set
.
tileX0
=
long2tileX
(
topleftLon
,
zoom
);
set
.
tileY0
=
lat2tileY
(
topleftLat
,
zoom
);
set
.
tileX1
=
long2tileX
(
bottomRightLon
,
zoom
);
set
.
tileY1
=
lat2tileY
(
bottomRightLat
,
zoom
);
set
.
tileCount
=
(
static_cast
<
quint64
>
(
set
.
tileX1
)
-
static_cast
<
quint64
>
(
set
.
tileX0
)
+
1
)
*
(
static_cast
<
quint64
>
(
set
.
tileY1
)
-
static_cast
<
quint64
>
(
set
.
tileY0
)
+
1
);
set
.
tileSize
=
getAverageSize
()
*
set
.
tileCount
;
return
set
;
}
src/QtLocationPlugin/MapProvider.h
View file @
9f48f6a4
#pragma once
#include "QGCTileSet.h"
#include <QByteArray>
#include <QNetworkProxy>
#include <QNetworkReply>
...
...
@@ -35,6 +37,10 @@ class MapProvider : public QObject {
virtual
bool
_isElevationProvider
();
virtual
QGCTileSet
getTileCount
(
int
zoom
,
double
topleftLon
,
double
topleftLat
,
double
bottomRightLon
,
double
bottomRightLat
);
protected:
QString
_tileXYToQuadKey
(
int
tileX
,
int
tileY
,
int
levelOfDetail
);
int
_getServerNum
(
int
x
,
int
y
,
int
max
);
...
...
src/QtLocationPlugin/QGCLocationPlugin.pri
View file @
9f48f6a4
...
...
@@ -29,6 +29,8 @@ HEADERS += \
$$PWD/GenericMapProvider.h \
$$PWD/EsriMapProvider.h \
$$PWD/MapboxMapProvider.h \
$$PWD/QGCTileSet.h \
SOURCES += \
$$PWD/QGCMapEngine.cpp \
...
...
src/QtLocationPlugin/QGCMapEngine.cpp
View file @
9f48f6a4
...
...
@@ -250,22 +250,8 @@ QGCMapEngine::getTileCount(int zoom, double topleftLon, double topleftLat, doubl
{
if
(
zoom
<
1
)
zoom
=
1
;
if
(
zoom
>
MAX_MAP_ZOOM
)
zoom
=
MAX_MAP_ZOOM
;
QGCTileSet
set
;
if
(
mapType
!=
"Airmap Elevation"
){
set
.
tileX0
=
getQGCMapEngine
()
->
urlFactory
()
->
long2tileX
(
mapType
,
topleftLon
,
zoom
);
set
.
tileY0
=
getQGCMapEngine
()
->
urlFactory
()
->
lat2tileY
(
mapType
,
topleftLat
,
zoom
);
set
.
tileX1
=
getQGCMapEngine
()
->
urlFactory
()
->
long2tileX
(
mapType
,
bottomRightLon
,
zoom
);
set
.
tileY1
=
getQGCMapEngine
()
->
urlFactory
()
->
lat2tileY
(
mapType
,
bottomRightLat
,
zoom
);
}
else
{
set
.
tileX0
=
getQGCMapEngine
()
->
urlFactory
()
->
long2tileX
(
mapType
,
topleftLon
,
zoom
);
set
.
tileY0
=
getQGCMapEngine
()
->
urlFactory
()
->
lat2tileY
(
mapType
,
bottomRightLat
,
zoom
);
set
.
tileX1
=
getQGCMapEngine
()
->
urlFactory
()
->
long2tileX
(
mapType
,
bottomRightLon
,
zoom
);
set
.
tileY1
=
getQGCMapEngine
()
->
urlFactory
()
->
lat2tileY
(
mapType
,
topleftLat
,
zoom
);
}
set
.
tileCount
=
(
static_cast
<
quint64
>
(
set
.
tileX1
)
-
static_cast
<
quint64
>
(
set
.
tileX0
)
+
1
)
*
(
static_cast
<
quint64
>
(
set
.
tileY1
)
-
static_cast
<
quint64
>
(
set
.
tileY0
)
+
1
);
set
.
tileSize
=
getQGCMapEngine
()
->
urlFactory
()
->
averageSizeForType
(
mapType
)
*
set
.
tileCount
;
return
set
;
return
getQGCMapEngine
()
->
urlFactory
()
->
getTileCount
(
zoom
,
topleftLon
,
topleftLat
,
bottomRightLon
,
bottomRightLat
,
mapType
);
}
...
...
src/QtLocationPlugin/QGCMapEngine.h
View file @
9f48f6a4
...
...
@@ -25,41 +25,6 @@
#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
...
...
src/QtLocationPlugin/QGCMapUrlEngine.cpp
View file @
9f48f6a4
...
...
@@ -173,3 +173,24 @@ UrlFactory::lat2tileY(QString mapType, double lat, int z)
return
_providersTable
[
mapType
]
->
lat2tileY
(
lat
,
z
);
}
//-----------------------------------------------------------------------------
QGCTileSet
UrlFactory
::
getTileCount
(
int
zoom
,
double
topleftLon
,
double
topleftLat
,
double
bottomRightLon
,
double
bottomRightLat
,
QString
mapType
)
{
//QGCTileSet set;
//if(mapType != "Airmap Elevation"){
// set.tileX0 = long2tileX(mapType, topleftLon, zoom);
// set.tileY0 = lat2tileY(mapType, topleftLat, zoom);
// set.tileX1 = long2tileX(mapType, bottomRightLon, zoom);
// set.tileY1 = lat2tileY(mapType, bottomRightLat, zoom);
//}else{
// set.tileX0 = getQGCMapEngine()->urlFactory()->long2tileX(mapType, topleftLon, zoom);
// set.tileY0 = getQGCMapEngine()->urlFactory()->lat2tileY(mapType, bottomRightLat, zoom);
// set.tileX1 = getQGCMapEngine()->urlFactory()->long2tileX(mapType, bottomRightLon, zoom);
// set.tileY1 = getQGCMapEngine()->urlFactory()->lat2tileY(mapType, topleftLat, zoom);
//}
//set.tileCount = (static_cast<quint64>(set.tileX1) - static_cast<quint64>(set.tileX0) + 1) * (static_cast<quint64>(set.tileY1) - static_cast<quint64>(set.tileY0) + 1);
//set.tileSize = getQGCMapEngine()->urlFactory()->averageSizeForType(mapType) * set.tileCount;
return
_providersTable
[
mapType
]
->
getTileCount
(
zoom
,
topleftLon
,
topleftLat
,
bottomRightLon
,
bottomRightLat
);
}
src/QtLocationPlugin/QGCMapUrlEngine.h
View file @
9f48f6a4
...
...
@@ -49,7 +49,11 @@ public:
int
getIdFromType
(
QString
type
);
QString
getTypeFromId
(
int
id
);
private:
QGCTileSet
getTileCount
(
int
zoom
,
double
topleftLon
,
double
topleftLat
,
double
bottomRightLon
,
double
bottomRightLat
,
QString
mapType
);
private:
int
_timeout
;
QHash
<
QString
,
MapProvider
*>
_providersTable
;
void
registerProvider
(
QString
Name
,
MapProvider
*
provider
);
...
...
src/QtLocationPlugin/QGCTileSet.h
0 → 100644
View file @
9f48f6a4
#pragma once
#include <QString>
//-----------------------------------------------------------------------------
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
;
};
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