Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+72
@@ -0,0 +1,72 @@
|
||||
#include "markerhelper.h"
|
||||
#include <QDebug>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <qeventloop.h>
|
||||
#include <qqmlengine.h>
|
||||
#include <QNetworkReply>
|
||||
MarkerHelper::MarkerHelper() {
|
||||
m_manager = new QNetworkAccessManager(this);
|
||||
}
|
||||
void MarkerHelper::startSimulation(QString replayId) {
|
||||
|
||||
}
|
||||
void MarkerHelper::postObject(QString replayId,int id, double lat, double lng, QString status, QString partie) {
|
||||
// Erstelle das GeoJSON-Objekt
|
||||
QString sidic;
|
||||
|
||||
if(status == "damaged") {
|
||||
sidic = "10061000001212000000"; // SIDIC CODE FOR SMYBOL ( DAMAGED )
|
||||
} else if (status == "destroyed") {
|
||||
sidic = "10031500001202000000"; // SIDIC CODE FOR SMYBOL ( DESTROYED )
|
||||
} else if (status == "fully_capable") {
|
||||
sidic = "30031020000000000000"; // SIDIC CODE FOR SYMBOL ( FULLY_CAPALE )
|
||||
}
|
||||
|
||||
QJsonObject geoJson;
|
||||
geoJson.insert("type", "Feature");
|
||||
|
||||
QJsonObject geometry;
|
||||
geometry.insert("type", "Point");
|
||||
|
||||
QJsonArray coordinates;
|
||||
coordinates.append(lng);
|
||||
coordinates.append(lat);
|
||||
geometry.insert("coordinates", coordinates);
|
||||
|
||||
QJsonObject properties;
|
||||
properties.insert("id", id);
|
||||
properties.insert("timestamp", QDateTime::currentMSecsSinceEpoch());
|
||||
properties.insert("replay_id", replayId);
|
||||
properties.insert("parties", partie);
|
||||
properties.insert("sidic", sidic);
|
||||
|
||||
geoJson.insert("properties", properties);
|
||||
geoJson.insert("geometry", geometry);
|
||||
|
||||
QJsonDocument jsonDoc(geoJson);
|
||||
QByteArray jsonData = jsonDoc.toJson();
|
||||
|
||||
QNetworkRequest request;
|
||||
|
||||
request.setUrl(QUrl("http://localhost:8080/objects"));
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
||||
|
||||
QSslConfiguration sslConfig = QSslConfiguration::defaultConfiguration();
|
||||
|
||||
sslConfig.setPeerVerifyMode(QSslSocket::VerifyNone);
|
||||
request.setSslConfiguration(sslConfig);
|
||||
|
||||
QNetworkReply *reply = m_manager->post(request, jsonData);
|
||||
|
||||
connect(reply, &QNetworkReply::finished, [reply] {
|
||||
if (reply->error() == QNetworkReply::NoError) {
|
||||
QByteArray response = reply->readAll();
|
||||
// Verarbeite die Antwort
|
||||
} else {
|
||||
qDebug() << "Error sending GeoJSON:" << reply->errorString();
|
||||
}
|
||||
reply->deleteLater();
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user