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
28c84d39
Unverified
Commit
28c84d39
authored
Aug 03, 2018
by
Don Gagne
Committed by
GitHub
Aug 03, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6756 from DonLakeFlyer/TerrainDouble
Terrain Tiles: Persist header info as doubles
parents
efbf70dc
7c2e38fd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
80 deletions
+68
-80
QGCMapUrlEngine.h
src/QtLocationPlugin/QGCMapUrlEngine.h
+1
-1
TerrainTile.cc
src/TerrainTile.cc
+57
-78
TerrainTile.h
src/TerrainTile.h
+10
-1
No files found.
src/QtLocationPlugin/QGCMapUrlEngine.h
View file @
28c84d39
...
...
@@ -75,7 +75,7 @@ public:
EsriWorldSatellite
=
7001
,
EsriTerrain
=
7002
,
AirmapElevation
=
800
0
AirmapElevation
=
800
1
};
UrlFactory
();
...
...
src/TerrainTile.cc
View file @
28c84d39
...
...
@@ -53,81 +53,50 @@ TerrainTile::TerrainTile(QByteArray byteArray)
,
_gridSizeLon
(
-
1
)
,
_isValid
(
false
)
{
QDataStream
stream
(
byteArray
);
int
cTileHeaderBytes
=
static_cast
<
int
>
(
sizeof
(
TileInfo_t
));
int
cTileBytesAvailable
=
byteArray
.
size
();
float
lat
,
lon
;
if
(
stream
.
atEnd
())
{
qWarning
()
<<
"Terrain tile binary data does not contain all data"
;
if
(
cTileBytesAvailable
<
cTileHeaderBytes
)
{
qWarning
()
<<
"Terrain tile binary data too small for TileInfo_s header"
;
return
;
}
stream
>>
lat
;
if
(
stream
.
atEnd
())
{
qWarning
()
<<
"Terrain tile binary data does not contain all data"
;
return
;
}
stream
>>
lon
;
_southWest
.
setLatitude
(
lat
);
_southWest
.
setLongitude
(
lon
);
if
(
stream
.
atEnd
())
{
qWarning
()
<<
"Terrain tile binary data does not contain all data"
;
return
;
}
stream
>>
lat
;
if
(
stream
.
atEnd
())
{
qWarning
()
<<
"Terrain tile binary data does not contain all data"
;
return
;
}
stream
>>
lon
;
_northEast
.
setLatitude
(
lat
);
_northEast
.
setLongitude
(
lon
);
const
TileInfo_t
*
tileInfo
=
reinterpret_cast
<
const
TileInfo_t
*>
(
byteArray
.
constData
());
_southWest
.
setLatitude
(
tileInfo
->
swLat
);
_southWest
.
setLongitude
(
tileInfo
->
swLon
);
_northEast
.
setLatitude
(
tileInfo
->
neLat
);
_northEast
.
setLongitude
(
tileInfo
->
neLon
);
_minElevation
=
tileInfo
->
minElevation
;
_maxElevation
=
tileInfo
->
maxElevation
;
_avgElevation
=
tileInfo
->
avgElevation
;
_gridSizeLat
=
tileInfo
->
gridSizeLat
;
_gridSizeLon
=
tileInfo
->
gridSizeLon
;
if
(
stream
.
atEnd
())
{
qWarning
()
<<
"Terrain tile binary data does not contain all data"
;
return
;
}
stream
>>
_minElevation
;
if
(
stream
.
atEnd
())
{
qWarning
()
<<
"Terrain tile binary data does not contain all data"
;
return
;
}
stream
>>
_maxElevation
;
if
(
stream
.
atEnd
())
{
qWarning
()
<<
"Terrain tile binary data does not contain all data"
;
return
;
}
stream
>>
_avgElevation
;
if
(
stream
.
atEnd
())
{
qWarning
()
<<
"Terrain tile binary data does not contain all data"
;
return
;
}
stream
>>
_gridSizeLat
;
if
(
stream
.
atEnd
())
{
qWarning
()
<<
"Terrain tile binary data does not contain all data"
;
qCDebug
(
TerrainTileLog
)
<<
"Loading terrain tile: "
<<
_southWest
<<
" - "
<<
_northEast
;
qCDebug
(
TerrainTileLog
)
<<
"min:max:avg:sizeLat:sizeLon"
<<
_minElevation
<<
_maxElevation
<<
_avgElevation
<<
_gridSizeLat
<<
_gridSizeLon
;
int
cTileDataBytes
=
static_cast
<
int
>
(
sizeof
(
int16_t
))
*
_gridSizeLat
*
_gridSizeLon
;
if
(
cTileBytesAvailable
<
cTileHeaderBytes
+
cTileDataBytes
)
{
qWarning
()
<<
"Terrain tile binary data too small for tile data"
;
return
;
}
stream
>>
_gridSizeLon
;
qCDebug
(
TerrainTileLog
)
<<
"Loading terrain tile: "
<<
_southWest
<<
" - "
<<
_northEast
;
qCDebug
(
TerrainTileLog
)
<<
"min:max:avg:sizeLat:sizeLon"
<<
_minElevation
<<
_maxElevation
<<
_avgElevation
<<
_gridSizeLat
<<
_gridSizeLon
;
_data
=
new
int16_t
*
[
_gridSizeLat
];
for
(
int
k
=
0
;
k
<
_gridSizeLat
;
k
++
)
{
_data
[
k
]
=
new
int16_t
[
_gridSizeLon
];
}
int
valueIndex
=
0
;
const
int16_t
*
pTileData
=
reinterpret_cast
<
const
int16_t
*>
(
&
reinterpret_cast
<
const
uint8_t
*>
(
byteArray
.
constData
())[
cTileHeaderBytes
]);
for
(
int
i
=
0
;
i
<
_gridSizeLat
;
i
++
)
{
if
(
i
==
0
)
{
_data
=
new
int16_t
*
[
_gridSizeLat
];
for
(
int
k
=
0
;
k
<
_gridSizeLat
;
k
++
)
{
_data
[
k
]
=
new
int16_t
[
_gridSizeLon
];
}
}
for
(
int
j
=
0
;
j
<
_gridSizeLon
;
j
++
)
{
if
(
stream
.
atEnd
())
{
qWarning
()
<<
"Terrain tile binary data does not contain all data"
;
return
;
}
stream
>>
_data
[
i
][
j
];
_data
[
i
][
j
]
=
pTileData
[
valueIndex
++
];
}
}
_isValid
=
true
;
return
;
}
...
...
@@ -176,8 +145,6 @@ QByteArray TerrainTile::serialize(QByteArray input)
return
emptyArray
;
}
QByteArray
byteArray
;
QDataStream
stream
(
&
byteArray
,
QIODevice
::
WriteOnly
);
if
(
!
document
.
isObject
())
{
qCDebug
(
TerrainTileLog
)
<<
"Terrain tile json doc is no object"
;
QByteArray
emptyArray
;
...
...
@@ -231,10 +198,6 @@ QByteArray TerrainTile::serialize(QByteArray input)
QByteArray
emptyArray
;
return
emptyArray
;
}
stream
<<
static_cast
<
float
>
(
swArray
[
0
].
toDouble
());
stream
<<
static_cast
<
float
>
(
swArray
[
1
].
toDouble
());
stream
<<
static_cast
<
float
>
(
neArray
[
0
].
toDouble
());
stream
<<
static_cast
<
float
>
(
neArray
[
1
].
toDouble
());
// Stats
const
QJsonObject
&
statsObject
=
dataObject
[
_jsonStatsKey
].
toObject
();
...
...
@@ -248,30 +211,46 @@ QByteArray TerrainTile::serialize(QByteArray input)
QByteArray
emptyArray
;
return
emptyArray
;
}
stream
<<
static_cast
<
int16_t
>
(
statsObject
[
_jsonMinElevationKey
].
toInt
());
stream
<<
static_cast
<
int16_t
>
(
statsObject
[
_jsonMaxElevationKey
].
toInt
());
stream
<<
static_cast
<
float
>
(
statsObject
[
_jsonAvgElevationKey
].
toDouble
());
// Carpet
const
QJsonArray
&
carpetArray
=
dataObject
[
_jsonCarpetKey
].
toArray
();
int
gridSizeLat
=
carpetArray
.
count
();
stream
<<
static_cast
<
int16_t
>
(
gridSizeLat
);
int
gridSizeLon
=
0
;
qCDebug
(
TerrainTileLog
)
<<
"Received tile has size in latitude direction: "
<<
carpetArray
.
count
();
int
gridSizeLon
=
carpetArray
[
0
].
toArray
().
count
();
qCDebug
(
TerrainTileLog
)
<<
"Received tile has size in latitude direction: "
<<
gridSizeLat
;
qCDebug
(
TerrainTileLog
)
<<
"Received tile has size in longitued direction: "
<<
gridSizeLon
;
TileInfo_t
tileInfo
;
tileInfo
.
swLat
=
swArray
[
0
].
toDouble
();
tileInfo
.
swLon
=
swArray
[
1
].
toDouble
();
tileInfo
.
neLat
=
neArray
[
0
].
toDouble
();
tileInfo
.
neLon
=
neArray
[
1
].
toDouble
();
tileInfo
.
minElevation
=
static_cast
<
int16_t
>
(
statsObject
[
_jsonMinElevationKey
].
toInt
());
tileInfo
.
maxElevation
=
static_cast
<
int16_t
>
(
statsObject
[
_jsonMaxElevationKey
].
toInt
());
tileInfo
.
avgElevation
=
statsObject
[
_jsonAvgElevationKey
].
toDouble
();
tileInfo
.
gridSizeLat
=
static_cast
<
int16_t
>
(
gridSizeLat
);
tileInfo
.
gridSizeLon
=
static_cast
<
int16_t
>
(
gridSizeLon
);
int
cTileHeaderBytes
=
static_cast
<
int
>
(
sizeof
(
TileInfo_t
));
int
cTileDataBytes
=
static_cast
<
int
>
(
sizeof
(
int16_t
))
*
gridSizeLat
*
gridSizeLon
;
QByteArray
byteArray
(
cTileHeaderBytes
+
cTileDataBytes
,
0
);
TileInfo_t
*
pTileInfo
=
reinterpret_cast
<
TileInfo_t
*>
(
byteArray
.
data
());
int16_t
*
pTileData
=
reinterpret_cast
<
int16_t
*>
(
&
reinterpret_cast
<
uint8_t
*>
(
byteArray
.
data
())[
cTileHeaderBytes
]);
*
pTileInfo
=
tileInfo
;
int
valueIndex
=
0
;
for
(
int
i
=
0
;
i
<
gridSizeLat
;
i
++
)
{
const
QJsonArray
&
row
=
carpetArray
[
i
].
toArray
();
if
(
i
==
0
)
{
gridSizeLon
=
row
.
count
();
stream
<<
static_cast
<
int16_t
>
(
gridSizeLon
);
qCDebug
(
TerrainTileLog
)
<<
"Received tile has size in longitued direction: "
<<
row
.
count
();
}
if
(
row
.
count
()
<
gridSizeLon
)
{
qCDebug
(
TerrainTileLog
)
<<
"Expected row array of "
<<
gridSizeLon
<<
", instead got "
<<
row
.
count
();
QByteArray
emptyArray
;
return
emptyArray
;
}
for
(
int
j
=
0
;
j
<
gridSizeLon
;
j
++
)
{
stream
<<
static_cast
<
int16_t
>
(
row
[
j
].
toDouble
());
pTileData
[
valueIndex
++
]
=
static_cast
<
int16_t
>
(
row
[
j
].
toDouble
());
}
}
...
...
src/TerrainTile.h
View file @
28c84d39
...
...
@@ -95,6 +95,15 @@ public:
static
constexpr
double
terrainAltitudeSpacing
=
30
.
0
;
private:
typedef
struct
{
double
swLat
,
swLon
,
neLat
,
neLon
;
int16_t
minElevation
;
int16_t
maxElevation
;
double
avgElevation
;
int16_t
gridSizeLat
;
int16_t
gridSizeLon
;
}
TileInfo_t
;
inline
int
_latToDataIndex
(
double
latitude
)
const
;
inline
int
_lonToDataIndex
(
double
longitude
)
const
;
...
...
@@ -103,7 +112,7 @@ private:
int16_t
_minElevation
;
/// Minimum elevation in tile
int16_t
_maxElevation
;
/// Maximum elevation in tile
float
_avgElevation
;
/// Average elevation of the tile
double
_avgElevation
;
/// Average elevation of the tile
int16_t
**
_data
;
/// 2D elevation data array
int16_t
_gridSizeLat
;
/// data grid size in latitude direction
...
...
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