Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions include/air_space/air_space_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@

#include <math/vec3D.h>

struct BlockedAirCorridor {
struct Point {
Vec3D vec;
std::size_t id {0};
};

struct AirCorridor {
std::size_t id1{0};
std::size_t id2{0};

bool operator==(const BlockedAirCorridor& other) const {
bool operator==(const AirCorridor& other) const {
return (id1 == other.id1 && id2 == other.id2) ||
(id1 == other.id2 && id2 == other.id1);
}
Expand All @@ -28,16 +33,14 @@ struct HighReliefZone {
};

struct AirSpace {
QVector<Vec3D> points;
QSet<BlockedAirCorridor> air_corridors;
QVector<Point> points;
QSet<AirCorridor> air_corridors;
QVector<Pvo> pvo_list;
QVector<HighReliefZone> high_relief_zones;
};

inline unsigned int qHash(const BlockedAirCorridor& key, uint seed = 0) {
std::size_t id_a = std::min(key.id1, key.id2);
std::size_t id_b = std::max(key.id1, key.id2);
return qHash(std::make_pair(id_a, id_b), seed);
inline uint qHash(const AirCorridor& corridor, uint seed = 0) {
return ::qHash(corridor.id1, seed) ^ ::qHash(corridor.id2, seed);
}

#endif
10 changes: 1 addition & 9 deletions include/json/airspace_loader/airspace_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@
#include <QSet>

#include "math/vec3D.h"

struct AirSpace {
QVector<Vec3D> points;
QSet<BlockedAirCorridor> air_corridors;
QVector<Pvo> pvo_list;
QVector<HighReliefZone> high_relief_zones;
};
#include <air_space/air_space_data.h>

class AirspaceLoader {
public:
Expand All @@ -31,6 +25,4 @@ class AirspaceLoader {
static AirSpace _ConstructAirspace(QJsonArray& arr);
};

#endif

#endif
2 changes: 1 addition & 1 deletion include/math/vec3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Vec3D {
double z { 0.0 };

Vec3D() = default;
Vec3D(double x_, double y_, double z_) : x(x_), y(y_), z(z_) {}
Vec3D(double x_, double y_, double z_ = 0) : x(x_), y(y_), z(z_) {}

Vec3D operator+(const Vec3D& other) const { return {x + other.x, y + other.y, z + other.z}; }
Vec3D operator-(const Vec3D& other) const { return {x - other.x, y - other.y, z - other.z}; }
Expand Down
11 changes: 6 additions & 5 deletions src/json/airspace_loader/airspace.loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,18 @@ AirSpace AirspaceLoader::_ConstructAirspace(QJsonArray& arr) {
QJsonArray pointsArray = arr[0].toArray();
for (const auto& item : pointsArray) {
QJsonObject obj = item.toObject();
Vec3D point;
point.x = obj["x"].toDouble();
point.y = obj["y"].toDouble();
point.z = 0;
Point point;
point.id = obj["id"].toInt();
point.vec.x = obj["x"].toDouble();
point.vec.y = obj["y"].toDouble();
point.vec.z = 0;
result.points.append(point);
}

QJsonArray corridorsArray = arr[1].toArray();
for (const auto& item : corridorsArray) {
QJsonObject obj = item.toObject();
BlockedAirCorridor corridor;
AirCorridor corridor;
corridor.id1 = obj["id1"].toInteger();
corridor.id2 = obj["id2"].toInteger();
result.air_corridors.insert(corridor);
Expand Down