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
f01cd04c
Commit
f01cd04c
authored
Mar 20, 2018
by
Andreas Bircher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes
parent
e33c30c5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
30 deletions
+28
-30
TerrainQuery.cc
src/Terrain/TerrainQuery.cc
+9
-11
TerrainQuery.h
src/Terrain/TerrainQuery.h
+8
-8
TerrainTile.cc
src/TerrainTile.cc
+3
-3
TerrainTile.h
src/TerrainTile.h
+8
-8
No files found.
src/Terrain/TerrainQuery.cc
View file @
f01cd04c
...
...
@@ -229,12 +229,10 @@ TerrainOfflineAirMapQuery::TerrainOfflineAirMapQuery(QObject* parent)
void
TerrainOfflineAirMapQuery
::
requestCoordinateHeights
(
const
QList
<
QGeoCoordinate
>&
coordinates
)
{
if
(
coordinates
.
length
()
==
0
)
{
return
false
;
return
;
}
_tileBatchManager
->
addQuery
(
this
,
coordinates
);
return
false
;
_terrainTileManager
->
addCoordinateQuery
(
this
,
coordinates
);
}
void
TerrainOfflineAirMapQuery
::
requestPathHeights
(
const
QGeoCoordinate
&
fromCoord
,
const
QGeoCoordinate
&
toCoord
)
...
...
@@ -249,7 +247,7 @@ void TerrainOfflineAirMapQuery::requestCarpetHeights(const QGeoCoordinate& swCoo
void
TerrainOfflineAirMapQuery
::
_signalCoordinateHeights
(
bool
success
,
QList
<
double
>
heights
)
{
emit
coordinateHeights
(
success
,
heights
)
emit
coordinateHeights
(
success
,
heights
)
;
}
void
TerrainOfflineAirMapQuery
::
_signalPathHeights
(
bool
success
,
double
latStep
,
double
lonStep
,
const
QList
<
double
>&
heights
)
...
...
@@ -267,10 +265,10 @@ TerrainTileManager::TerrainTileManager(void)
}
void
TerrainTileManager
::
addQuery
(
TerrainOfflineAirMapQuery
*
terrainQueryInterface
,
const
QList
<
QGeoCoordinate
>&
coordinates
)
void
TerrainTileManager
::
add
Coordinate
Query
(
TerrainOfflineAirMapQuery
*
terrainQueryInterface
,
const
QList
<
QGeoCoordinate
>&
coordinates
)
{
if
(
coordinates
.
length
()
>
0
)
{
QList
<
float
>
altitudes
;
QList
<
double
>
altitudes
;
if
(
!
_getAltitudesForCoordinates
(
coordinates
,
altitudes
))
{
QueuedRequestInfo_t
queuedRequestInfo
=
{
terrainQueryInterface
,
coordinates
,
QueryMode
::
QueryModeCoordinates
};
...
...
@@ -279,11 +277,11 @@ void TerrainTileManager::addQuery(TerrainOfflineAirMapQuery* terrainQueryInterfa
}
qCDebug
(
TerrainQueryLog
)
<<
"All altitudes taken from cached data"
;
terrainQueryInterface
->
_signal
TerrainData
(
coordinates
.
count
()
==
altitudes
.
count
(),
altitudes
);
terrainQueryInterface
->
_signal
CoordinateHeights
(
coordinates
.
count
()
==
altitudes
.
count
(),
altitudes
);
}
}
bool
TerrainTileManager
::
_getAltitudesForCoordinates
(
const
QList
<
QGeoCoordinate
>&
coordinates
,
QList
<
float
>&
altitudes
)
bool
TerrainTileManager
::
_getAltitudesForCoordinates
(
const
QList
<
QGeoCoordinate
>&
coordinates
,
QList
<
double
>&
altitudes
)
{
foreach
(
const
QGeoCoordinate
&
coordinate
,
coordinates
)
{
QString
tileHash
=
_getTileHash
(
coordinate
);
...
...
@@ -322,7 +320,7 @@ bool TerrainTileManager::_getAltitudesForCoordinates(const QList<QGeoCoordinate>
void
TerrainTileManager
::
_tileFailed
(
void
)
{
QList
<
float
>
noAltitudes
;
QList
<
double
>
noAltitudes
;
foreach
(
const
QueuedRequestInfo_t
&
requestInfo
,
_requestQueue
)
{
if
(
requestInfo
.
queryMode
==
QueryMode
::
QueryModeCoordinates
)
{
...
...
@@ -393,7 +391,7 @@ void TerrainTileManager::_fetchedTile()
// now try to query the data again
for
(
int
i
=
_requestQueue
.
count
()
-
1
;
i
>=
0
;
i
--
)
{
QList
<
float
>
altitudes
;
QList
<
double
>
altitudes
;
if
(
_getAltitudesForCoordinates
(
_requestQueue
[
i
].
coordinates
,
altitudes
))
{
if
(
_requestQueue
[
i
].
queryMode
==
QueryMode
::
QueryModeCoordinates
)
{
_requestQueue
[
i
].
terrainQueryInterface
->
_signalCoordinateHeights
(
_requestQueue
[
i
].
coordinates
.
count
()
==
altitudes
.
count
(),
altitudes
);
...
...
src/Terrain/TerrainQuery.h
View file @
f01cd04c
...
...
@@ -114,18 +114,12 @@ class TerrainTileManager : public QObject {
public:
TerrainTileManager
(
void
);
void
addQuery
(
TerrainOfflineAirMapQuery
*
terrainQueryInterface
,
const
QList
<
QGeoCoordinate
>&
coordinates
);
void
add
Coordinate
Query
(
TerrainOfflineAirMapQuery
*
terrainQueryInterface
,
const
QList
<
QGeoCoordinate
>&
coordinates
);
private
slots
:
void
_fetchedTile
(
void
);
/// slot to handle fetched elevation tiles
private:
typedef
struct
{
TerrainOfflineAirMapQuery
*
terrainQueryInterface
;
QList
<
QGeoCoordinate
>
coordinates
;
QueryMode
queryMode
;
}
QueuedRequestInfo_t
;
enum
class
State
{
Idle
,
Downloading
,
...
...
@@ -137,8 +131,14 @@ private:
QueryModeCarpet
};
typedef
struct
{
TerrainOfflineAirMapQuery
*
terrainQueryInterface
;
QList
<
QGeoCoordinate
>
coordinates
;
QueryMode
queryMode
;
}
QueuedRequestInfo_t
;
void
_tileFailed
(
void
);
bool
_getAltitudesForCoordinates
(
const
QList
<
QGeoCoordinate
>&
coordinates
,
QList
<
float
>&
altitudes
);
bool
_getAltitudesForCoordinates
(
const
QList
<
QGeoCoordinate
>&
coordinates
,
QList
<
double
>&
altitudes
);
QString
_getTileHash
(
const
QGeoCoordinate
&
coordinate
);
/// Method to create a unique string for each tile
QList
<
QueuedRequestInfo_t
>
_requestQueue
;
...
...
src/TerrainTile.cc
View file @
f01cd04c
...
...
@@ -125,10 +125,10 @@ TerrainTile::TerrainTile(QJsonDocument document)
_gridSizeLon
=
row
.
count
();
qCDebug
(
TerrainTileLog
)
<<
"Received tile has size in longitued direction: "
<<
row
.
count
();
if
(
_gridSizeLon
>
0
)
{
_data
=
new
float
*
[
_gridSizeLat
];
_data
=
new
double
*
[
_gridSizeLat
];
}
for
(
int
k
=
0
;
k
<
_gridSizeLat
;
k
++
)
{
_data
[
k
]
=
new
float
[
_gridSizeLon
];
_data
[
k
]
=
new
double
[
_gridSizeLon
];
}
}
if
(
row
.
count
()
<
_gridSizeLon
)
{
...
...
@@ -154,7 +154,7 @@ bool TerrainTile::isIn(const QGeoCoordinate& coordinate) const
return
ret
;
}
float
TerrainTile
::
elevation
(
const
QGeoCoordinate
&
coordinate
)
const
double
TerrainTile
::
elevation
(
const
QGeoCoordinate
&
coordinate
)
const
{
if
(
_isValid
)
{
qCDebug
(
TerrainTileLog
)
<<
"elevation: "
<<
coordinate
<<
" , in sw "
<<
_southWest
<<
" , ne "
<<
_northEast
;
...
...
src/TerrainTile.h
View file @
f01cd04c
...
...
@@ -47,28 +47,28 @@ public:
* @param coordinate
* @return elevation
*/
float
elevation
(
const
QGeoCoordinate
&
coordinate
)
const
;
double
elevation
(
const
QGeoCoordinate
&
coordinate
)
const
;
/**
* Accessor for the minimum elevation of the tile
*
* @return minimum elevation
*/
float
minElevation
(
void
)
const
{
return
_minElevation
;
}
double
minElevation
(
void
)
const
{
return
_minElevation
;
}
/**
* Accessor for the maximum elevation of the tile
*
* @return maximum elevation
*/
float
maxElevation
(
void
)
const
{
return
_maxElevation
;
}
double
maxElevation
(
void
)
const
{
return
_maxElevation
;
}
/**
* Accessor for the average elevation of the tile
*
* @return average elevation
*/
float
avgElevation
(
void
)
const
{
return
_avgElevation
;
}
double
avgElevation
(
void
)
const
{
return
_avgElevation
;
}
/**
* Accessor for the center coordinate
...
...
@@ -84,11 +84,11 @@ private:
QGeoCoordinate
_southWest
;
/// South west corner of the tile
QGeoCoordinate
_northEast
;
/// North east corner of the tile
float
_minElevation
;
/// Minimum elevation in tile
float
_maxElevation
;
/// Maximum elevation in tile
float
_avgElevation
;
/// Average elevation of the tile
double
_minElevation
;
/// Minimum elevation in tile
double
_maxElevation
;
/// Maximum elevation in tile
double
_avgElevation
;
/// Average elevation of the tile
float
**
_data
;
/// 2D elevation data array
double
**
_data
;
/// 2D elevation data array
int
_gridSizeLat
;
/// data grid size in latitude direction
int
_gridSizeLon
;
/// data grid size in longitude direction
bool
_isValid
;
/// data loaded is valid
...
...
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