Commit 7b00e7a3 authored by Sebastian Verling's avatar Sebastian Verling

first implementation of binary representation of elevation data

parent 612d219d
......@@ -52,9 +52,6 @@
#include <QtNetwork/QNetworkAccessManager>
#include <QFile>
#include "TerrainTile.h"
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
int QGeoTiledMapReplyQGC::_requestCount = 0;
......@@ -129,18 +126,13 @@ QGeoTiledMapReplyQGC::networkReplyFinished()
// convert "a" to binary in case we have elevation data
if ((UrlFactory::MapType)tileSpec().mapId() == UrlFactory::MapType::AirmapElevation) {
QJsonParseError parseError;
QJsonDocument json = QJsonDocument::fromJson(a, &parseError);
if (parseError.error != QJsonParseError::NoError) {
a = TerrainTile::serialize(a);
if (a.isEmpty()) {
emit aborted();
return;
} else {
a = TerrainTile::serialize(json);
if (a.isEmpty()) {
emit aborted();
return;
}
}
}
setMapImageData(a);
if(!format.isEmpty()) {
......
......@@ -111,11 +111,17 @@ QGeoCoordinate TerrainTile::centerCoordinate(void) const
return _southWest.atDistanceAndAzimuth(_southWest.distanceTo(_northEast) / 2.0, _southWest.azimuthTo(_northEast));
}
QByteArray TerrainTile::serialize(QJsonDocument document)
QByteArray TerrainTile::serialize(QByteArray input)
{
QJsonParseError parseError;
QJsonDocument document = QJsonDocument::fromJson(input, &parseError);
if (parseError.error != QJsonParseError::NoError) {
QByteArray emptyArray;
return emptyArray;
}
QByteArray byteArray;
QIODevice::OpenMode writeonly = QIODevice::WriteOnly;
QDataStream stream(&byteArray, writeonly);
QDataStream stream(&byteArray, QIODevice::WriteOnly);
if (!document.isObject()) {
qCDebug(TerrainTileLog) << "Terrain tile json doc is no object";
QByteArray emptyArray;
......
......@@ -89,7 +89,7 @@ public:
*
* @return serialized data
*/
static QByteArray serialize(QJsonDocument document);
static QByteArray serialize(QByteArray input);
private:
inline int _latToDataIndex(double latitude) const;
......@@ -98,11 +98,11 @@ private:
QGeoCoordinate _southWest; /// South west corner of the tile
QGeoCoordinate _northEast; /// North east corner of the tile
int _minElevation; /// Minimum elevation in tile
int _maxElevation; /// Maximum elevation in tile
double _avgElevation; /// Average elevation of the tile
int _minElevation; /// Minimum elevation in tile
int _maxElevation; /// Maximum elevation in tile
double _avgElevation; /// Average elevation of the tile
double** _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
......
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