| 1 | /* |
| 2 | * SPDX-FileName: AINotifications.hxx |
| 3 | * SPDX-FileComment: Emesary notifications for AI system |
| 4 | * SPDX-FileCopyrightText: Richard Harrison; April 2020. |
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 6 | */ |
| 7 | |
| 8 | #pragma once |
| 9 | |
| 10 | #include <simgear/emesary/Emesary.hxx> |
| 11 | #include <simgear/math/SGMath.hxx> |
| 12 | |
| 13 | |
| 14 | class NearestCarrierToNotification : public simgear::Emesary::INotification |
| 15 | { |
| 16 | public: |
| 17 | explicit NearestCarrierToNotification(SGGeod _comparisonPosition) : position(), |
| 18 | comparisonPosition(_comparisonPosition), |
| 19 | heading(0), |
| 20 | vckts(0), |
| 21 | deckheight(0), |
| 22 | distanceMeters(std::numeric_limits<double>::max()), |
| 23 | carrier(0) |
| 24 | { |
| 25 | } |
| 26 | |
| 27 | /*virtual ~NearestCarrierToNotification() |
| 28 | { |
| 29 | if (position) |
| 30 | delete position; |
| 31 | position = 0; |
| 32 | }*/ |
| 33 | const char* GetType() override { return "NearestCarrierToNotification"; } |
| 34 | |
| 35 | const SGGeod* GetPosition() const { return position; } |
| 36 | double GetHeading() const { return heading; } |
| 37 | double GetVckts() const { return vckts; } |
| 38 | double GetDeckheight() const { return deckheight; } |
| 39 | const class FGAICarrier* GetCarrier() const { return carrier; } |
| 40 | double GetDistanceMeters() const { return distanceMeters; } |
| 41 | std::string GetCarrierIdent() const { return carrierIdent; } |
| 42 | double GetDistanceToMeters(const SGGeod& pos) const |
| 43 | { |
| 44 | if (carrier) |
| 45 | return SGGeodesy::distanceM(comparisonPosition, pos); |
| 46 | else |
| 47 | return std::numeric_limits<double>::max() - 1; |
| 48 | } |
| 49 | |
| 50 | void SetPosition(SGGeod* _position) { position = _position; } |
| 51 | |
| 52 | void SetHeading(double _heading) { heading = _heading; } |
| 53 | void SetVckts(double _vckts) { vckts = _vckts; } |
| 54 | void SetDeckheight(double _deckheight) { deckheight = _deckheight; } |
| 55 | |
| 56 | void SetCarrier(FGAICarrier* _carrier, SGGeod* _position) |
| 57 | { |
| 58 | carrier = _carrier; |
| 59 | distanceMeters = SGGeodesy::distanceM(comparisonPosition, *_position); |
| 60 | position = _position; |
| 61 | } |
| 62 | void SetDistanceMeters(double _distanceMeters) { distanceMeters = _distanceMeters; } |
| 63 | void SetCarrierIdent(const std::string& _carrierIdent) { carrierIdent = _carrierIdent; } |
| 64 | |
| 65 | SGPropertyNode_ptr GetViewPositionLatNode() { return viewPositionLatDegNode; } |
| 66 | SGPropertyNode_ptr GetViewPositionLonNode() { return viewPositionLonDegNode; } |
| 67 | SGPropertyNode_ptr GetViewPositionAltNode() { return viewPositionAltFtNode; } |
| 68 | |
| 69 | void SetViewPositionLatNode(SGPropertyNode_ptr _viewPositionLatNode) { viewPositionLatDegNode = _viewPositionLatNode; } |
| 70 | void SetViewPositionLonNode(SGPropertyNode_ptr _viewPositionLonNode) { viewPositionLonDegNode = _viewPositionLonNode; } |
| 71 | void SetViewPositionAltNode(SGPropertyNode_ptr _viewPositionAltNode) { viewPositionAltFtNode = _viewPositionAltNode; } |
| 72 | |
| 73 | |
| 74 | protected: |
| 75 | SGGeod* position; |
| 76 | SGGeod comparisonPosition; |
| 77 | |
| 78 | SGPropertyNode_ptr viewPositionLatDegNode; |
| 79 | SGPropertyNode_ptr viewPositionLonDegNode; |
| 80 | SGPropertyNode_ptr viewPositionAltFtNode; |
| 81 | |
| 82 | double heading; |
| 83 | double vckts; |
| 84 | double deckheight; |
| 85 | double distanceMeters; |
| 86 | std::string carrierIdent; |
| 87 | class FGAICarrier* carrier; |
| 88 | }; |