diff --git a/libs/airmapd/include/airmap/airspace.h b/libs/airmapd/include/airmap/airspace.h index fdd9344734427f4980f5fc1afb9039bbd8537da2..6c51a6e328cff9e37e65fd11488f89793a16cde4 100644 --- a/libs/airmapd/include/airmap/airspace.h +++ b/libs/airmapd/include/airmap/airspace.h @@ -48,7 +48,9 @@ class Airspace { /// ControlledAirspace bundles up properties describing /// a controlled airspace. - struct ControlledAirspace {}; + struct ControlledAirspace { + std::string airspace_classification; ///< The classification of the ControlledAirspace. + }; /// SpecialUseAirspace bundles up properties describing /// a special use airspace. diff --git a/libs/airmapd/include/airmap/airspaces.h b/libs/airmapd/include/airmap/airspaces.h index 1f81c588cecac1be17ec0cc9a4d7f615ab1b4217..d4d447e9a20c5f60904528122a0c3f2c59a4e83a 100644 --- a/libs/airmapd/include/airmap/airspaces.h +++ b/libs/airmapd/include/airmap/airspaces.h @@ -24,7 +24,7 @@ class Airspaces : DoNotCopyOrMove { }; /// Result models the outcome of calling Airspaces::for_id. - using Result = Outcome, Error>; + using Result = Outcome; /// Callback describes the function signature of the callback that is /// invoked when a call to Airspaces::for_id finishes. using Callback = std::function; diff --git a/libs/airmapd/macOS/Qt.5.11.0/libairmap-qt.0.dylib b/libs/airmapd/macOS/Qt.5.11.0/libairmap-qt.0.dylib index 15b8d47896d329734b8ddd3215b96bb7f2393b9c..1a4304fad386793411fec465f259279c16f1c0af 100755 Binary files a/libs/airmapd/macOS/Qt.5.11.0/libairmap-qt.0.dylib and b/libs/airmapd/macOS/Qt.5.11.0/libairmap-qt.0.dylib differ diff --git a/src/Airmap/AirMapManager.cc b/src/Airmap/AirMapManager.cc index 44795e1a7a350f573828f5d83f5b9d5d3fee1e21..b2361fbffe509c26381c0a5cd9f6633db1cbcf55 100644 --- a/src/Airmap/AirMapManager.cc +++ b/src/Airmap/AirMapManager.cc @@ -43,9 +43,9 @@ AirMapManager::AirMapManager(QGCApplication* app, QGCToolbox* toolbox) { _logger = std::make_shared(); qt::register_types(); // TODO: still needed? - _logger->logging_category().setEnabled(QtDebugMsg, true); - _logger->logging_category().setEnabled(QtInfoMsg, true); - _logger->logging_category().setEnabled(QtWarningMsg, true); + _logger->logging_category().setEnabled(QtDebugMsg, false); + _logger->logging_category().setEnabled(QtInfoMsg, false); + _logger->logging_category().setEnabled(QtWarningMsg, false); _dispatchingLogger = std::make_shared(_logger); connect(&_shared, &AirMapSharedState::error, this, &AirMapManager::_error); connect(&_shared, &AirMapSharedState::authStatus, this, &AirMapManager::_authStatusChanged); diff --git a/src/Airmap/AirMapRestrictionManager.cc b/src/Airmap/AirMapRestrictionManager.cc index f346c6409ffc98902e0c8bb71acb19d36b471a4c..22c1ce1e2b3f4b5d8c3d16352f112a2b562fef2a 100644 --- a/src/Airmap/AirMapRestrictionManager.cc +++ b/src/Airmap/AirMapRestrictionManager.cc @@ -11,8 +11,6 @@ #include "AirMapManager.h" #include "AirspaceRestriction.h" -#include "airmap/airspaces.h" - #define RESTRICTION_UPDATE_DISTANCE 500 //-- 500m threshold for updates using namespace airmap; @@ -37,6 +35,40 @@ AirMapRestrictionManager::setROI(const QGCGeoBoundingCube& roi, bool reset) } } + +//----------------------------------------------------------------------------- +QColor +AirMapRestrictionManager::_getColor(const Airspace::Type type) +{ + if(type == Airspace::Type::airport) + return QColor(254,65,65,30); + if(type == Airspace::Type::controlled_airspace) + return QColor(254,158,65,60); + if(type == Airspace::Type::special_use_airspace) + return QColor(65,230,254,30); + if(type == Airspace::Type::tfr) + return QColor(95,230,254,30); + if(type == Airspace::Type::wildfire) + return QColor(254,120,0,30); + if(type == Airspace::Type::park) + return QColor(7,165,22,30); + if(type == Airspace::Type::power_plant) + return QColor(11,7,165,30); + if(type == Airspace::Type::heliport) + return QColor(233,57,57,30); + if(type == Airspace::Type::prison) + return QColor(100,100,100,30); + if(type == Airspace::Type::school) + return QColor(56,224,190,30); + if(type == Airspace::Type::hospital) + return QColor(56,159,224,30); + if(type == Airspace::Type::fire) + return QColor(223,83,10,30); + if(type == Airspace::Type::emergency) + return QColor(255,0,0,30); + return QColor(255,0,255,30); +} + //----------------------------------------------------------------------------- void AirMapRestrictionManager::_requestRestrictions(const QGCGeoBoundingCube& roi) @@ -54,7 +86,7 @@ AirMapRestrictionManager::_requestRestrictions(const QGCGeoBoundingCube& roi) _circles.clear(); _state = State::RetrieveItems; Airspaces::Search::Parameters params; - params.full = true; + params.full = false; params.date_time = Clock::universal_time(); //-- Geometry: Polygon Geometry::Polygon polygon; @@ -74,23 +106,24 @@ AirMapRestrictionManager::_requestRestrictions(const QGCGeoBoundingCube& roi) const std::vector& airspaces = result.value(); qCDebug(AirMapManagerLog)<<"Successful search. Items:" << airspaces.size(); for (const auto& airspace : airspaces) { + QColor color = _getColor(airspace.type()); const Geometry& geometry = airspace.geometry(); switch(geometry.type()) { case Geometry::Type::polygon: { const Geometry::Polygon& polygon = geometry.details_for_polygon(); - _addPolygonToList(polygon); + _addPolygonToList(polygon, color); } break; case Geometry::Type::multi_polygon: { const Geometry::MultiPolygon& multiPolygon = geometry.details_for_multi_polygon(); for (const auto& polygon : multiPolygon) { - _addPolygonToList(polygon); + _addPolygonToList(polygon, color); } } break; case Geometry::Type::point: { const Geometry::Point& point = geometry.details_for_point(); - _circles.append(new AirspaceCircularRestriction(QGeoCoordinate(point.latitude, point.longitude), 0.)); + _circles.append(new AirspaceCircularRestriction(QGeoCoordinate(point.latitude, point.longitude), 0., color)); // TODO: radius??? } break; @@ -114,7 +147,7 @@ AirMapRestrictionManager::_requestRestrictions(const QGCGeoBoundingCube& roi) //----------------------------------------------------------------------------- void -AirMapRestrictionManager::_addPolygonToList(const airmap::Geometry::Polygon& polygon) +AirMapRestrictionManager::_addPolygonToList(const airmap::Geometry::Polygon& polygon, const QColor color) { QVariantList polygonArray; for (const auto& vertex : polygon.outer_ring.coordinates) { @@ -126,7 +159,7 @@ AirMapRestrictionManager::_addPolygonToList(const airmap::Geometry::Polygon& pol } polygonArray.append(QVariant::fromValue(coord)); } - _polygons.append(new AirspacePolygonRestriction(polygonArray)); + _polygons.append(new AirspacePolygonRestriction(polygonArray, color)); if (polygon.inner_rings.size() > 0) { // no need to support those (they are rare, and in most cases, there's a more restrictive polygon filling the hole) qCDebug(AirMapManagerLog) << "Polygon with holes. Size: "< #include "airmap/geometry.h" +#include "airmap/airspaces.h" /** * @file AirMapRestrictionManager.h @@ -38,7 +39,8 @@ signals: private: void _requestRestrictions(const QGCGeoBoundingCube& roi); - void _addPolygonToList (const airmap::Geometry::Polygon& polygon); + void _addPolygonToList (const airmap::Geometry::Polygon& polygon, const QColor color); + QColor _getColor (const airmap::Airspace::Type type); enum class State { Idle, diff --git a/src/AirspaceManagement/AirspaceManager.cc b/src/AirspaceManagement/AirspaceManager.cc index e6124215d810913659b45375ad7d1c8778e112eb..28dc6bde3f2bf1f8452f9ad915a43ce40e240bd3 100644 --- a/src/AirspaceManagement/AirspaceManager.cc +++ b/src/AirspaceManagement/AirspaceManager.cc @@ -117,7 +117,7 @@ AirspaceManager::_setROI(const QGCGeoBoundingCube& roi) { if(_roi != roi) { _roi = roi; - _ruleUpdateTimer.start(); + _updateTimer.start(); } } diff --git a/src/AirspaceManagement/AirspaceRestriction.cc b/src/AirspaceManagement/AirspaceRestriction.cc index 6cbef59461c19774e3a3d34886404a43cfee06d2..d4f08ec5ce3eca3e1f620d1f7b95634a9e3a8d6e 100644 --- a/src/AirspaceManagement/AirspaceRestriction.cc +++ b/src/AirspaceManagement/AirspaceRestriction.cc @@ -9,20 +9,21 @@ #include "AirspaceRestriction.h" -AirspaceRestriction::AirspaceRestriction(QObject* parent) +AirspaceRestriction::AirspaceRestriction(QColor color, QObject* parent) : QObject(parent) + , _color(color) { } -AirspacePolygonRestriction::AirspacePolygonRestriction(const QVariantList& polygon, QObject* parent) - : AirspaceRestriction(parent) +AirspacePolygonRestriction::AirspacePolygonRestriction(const QVariantList& polygon, QColor color, QObject* parent) + : AirspaceRestriction(color, parent) , _polygon(polygon) { } -AirspaceCircularRestriction::AirspaceCircularRestriction(const QGeoCoordinate& center, double radius, QObject* parent) - : AirspaceRestriction(parent) +AirspaceCircularRestriction::AirspaceCircularRestriction(const QGeoCoordinate& center, double radius, QColor color, QObject* parent) + : AirspaceRestriction(color, parent) , _center(center) , _radius(radius) { diff --git a/src/AirspaceManagement/AirspaceRestriction.h b/src/AirspaceManagement/AirspaceRestriction.h index e160e1b3fb0e46b0fcc6fb193f38f035f9874f55..9affdbede39b5c18fd405b98a994ec06ceec674e 100644 --- a/src/AirspaceManagement/AirspaceRestriction.h +++ b/src/AirspaceManagement/AirspaceRestriction.h @@ -12,6 +12,7 @@ #include #include #include +#include /** * @class AirspaceRestriction @@ -22,7 +23,11 @@ class AirspaceRestriction : public QObject { Q_OBJECT public: - AirspaceRestriction(QObject* parent = nullptr); + AirspaceRestriction(QColor color, QObject* parent = nullptr); + Q_PROPERTY(QColor color READ color CONSTANT) + QColor color() { return _color; } +protected: + QColor _color; }; /** @@ -34,12 +39,9 @@ class AirspacePolygonRestriction : public AirspaceRestriction { Q_OBJECT public: - AirspacePolygonRestriction(const QVariantList& polygon, QObject* parent = nullptr); - - Q_PROPERTY(QVariantList polygon MEMBER _polygon CONSTANT) - - const QVariantList& getPolygon() const { return _polygon; } - + AirspacePolygonRestriction(const QVariantList& polygon, QColor color, QObject* parent = nullptr); + Q_PROPERTY(QVariantList polygon READ polygon CONSTANT) + QVariantList polygon() { return _polygon; } private: QVariantList _polygon; }; @@ -53,11 +55,11 @@ class AirspaceCircularRestriction : public AirspaceRestriction { Q_OBJECT public: - AirspaceCircularRestriction(const QGeoCoordinate& center, double radius, QObject* parent = nullptr); - - Q_PROPERTY(QGeoCoordinate center MEMBER _center CONSTANT) - Q_PROPERTY(double radius MEMBER _radius CONSTANT) - + AirspaceCircularRestriction(const QGeoCoordinate& center, double radius, QColor color, QObject* parent = nullptr); + Q_PROPERTY(QGeoCoordinate center READ center CONSTANT) + Q_PROPERTY(double radius READ radius CONSTANT) + QGeoCoordinate center () { return _center; } + double radius () { return _radius; } private: QGeoCoordinate _center; double _radius; diff --git a/src/FlightDisplay/FlightDisplayViewMap.qml b/src/FlightDisplay/FlightDisplayViewMap.qml index d00415fd6199943c8a178c29eb6630fea6b31636..626979f899e9a412d951f4a28ba8362c2cb989da 100644 --- a/src/FlightDisplay/FlightDisplayViewMap.qml +++ b/src/FlightDisplay/FlightDisplayViewMap.qml @@ -438,7 +438,7 @@ FlightMap { delegate: MapCircle { center: object.center radius: object.radius - color: Qt.rgba(0.94, 0.87, 0, 0.15) + color: object.color border.color: Qt.rgba(1,1,1,0.85) } } @@ -447,7 +447,7 @@ FlightMap { model: _airspaceEnabled && QGroundControl.airspaceManager.airspaceVisible ? QGroundControl.airspaceManager.airspaces.polygons : [] delegate: MapPolygon { path: object.polygon - color: Qt.rgba(0.94, 0.87, 0, 0.15) + color: object.color border.color: Qt.rgba(1,1,1,0.85) } } diff --git a/src/PlanView/PlanView.qml b/src/PlanView/PlanView.qml index d55b34a797f1e4a9c64cf851386d3a003f9397c7..58fdba3398313f2b35c1298fe14b9400f203a0c7 100644 --- a/src/PlanView/PlanView.qml +++ b/src/PlanView/PlanView.qml @@ -560,7 +560,7 @@ QGCView { delegate: MapCircle { center: object.center radius: object.radius - color: Qt.rgba(0.94, 0.87, 0, 0.1) + color: object.color border.color: Qt.rgba(1,1,1,0.65) } } @@ -569,7 +569,7 @@ QGCView { model: _airspaceEnabled && QGroundControl.airspaceManager.airspaceVisible ? QGroundControl.airspaceManager.airspaces.polygons : [] delegate: MapPolygon { path: object.polygon - color: Qt.rgba(0.94, 0.87, 0, 0.1) + color: object.color border.color: Qt.rgba(1,1,1,0.65) } }