Browse Source

first implementation of binary representation of elevation data

QGC4.4
Sebastian Verling 7 years ago
parent
commit
7b00e7a32f
  1. 14
      src/QtLocationPlugin/QGeoMapReplyQGC.cpp
  2. 12
      src/TerrainTile.cc
  3. 2
      src/TerrainTile.h

14
src/QtLocationPlugin/QGeoMapReplyQGC.cpp

@ -52,9 +52,6 @@ @@ -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() @@ -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) {
emit aborted();
return;
} else {
a = TerrainTile::serialize(json);
a = TerrainTile::serialize(a);
if (a.isEmpty()) {
emit aborted();
return;
}
}
}
setMapImageData(a);
if(!format.isEmpty()) {

12
src/TerrainTile.cc

@ -111,11 +111,17 @@ QGeoCoordinate TerrainTile::centerCoordinate(void) const @@ -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;

2
src/TerrainTile.h

@ -89,7 +89,7 @@ public: @@ -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;

Loading…
Cancel
Save