-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
446 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#include "GlideslopeDriftEstimator.h" | ||
#include "GlideslopeDriftTagItem.h" | ||
#include "euroscope/EuroScopeCFlightPlanInterface.h" | ||
#include "euroscope/EuroScopeCRadarTargetInterface.h" | ||
#include "runway/Runway.h" | ||
#include "runway/RunwayCollection.h" | ||
#include "tag/TagData.h" | ||
|
||
namespace UKControllerPlugin::Approach { | ||
GlideslopeDriftTagItem::GlideslopeDriftTagItem( | ||
std::shared_ptr<const GlideslopeDriftEstimator> glideslopeDriftEstimator, | ||
std::shared_ptr<const Runway::RunwayCollection> runways) | ||
: glideslopeDriftEstimator(glideslopeDriftEstimator), runways(runways) | ||
{ | ||
assert(this->glideslopeDriftEstimator != nullptr && "Glideslope drift estimator cannot be null"); | ||
assert(this->runways != nullptr && "Runways cannot be null"); | ||
} | ||
|
||
std::string GlideslopeDriftTagItem::GetTagItemDescription(int tagItemId) const | ||
{ | ||
switch (tagItemId) { | ||
case 132: | ||
return "Glideslope Deviation"; | ||
default: | ||
throw std::invalid_argument("Invalid tag item ID"); | ||
} | ||
} | ||
|
||
void GlideslopeDriftTagItem::SetTagItemData(Tag::TagData& tagData) | ||
{ | ||
const auto& flightplan = tagData.GetFlightplan(); | ||
|
||
// Get the runway | ||
const auto runway = | ||
runways->GetByAirfieldAndIdentifier(flightplan.GetDestination(), flightplan.GetArrivalRunway()); | ||
if (runway == nullptr) { | ||
return; | ||
} | ||
|
||
// Make sure we're upwind of the runway | ||
if (std::abs(tagData.GetRadarTarget().GetPosition().DirectionTo(runway->Threshold()) - runway->Heading()) > | ||
90) { | ||
return; | ||
} | ||
|
||
// Calculate the drift and make sure we're somewhat close | ||
const auto drift = glideslopeDriftEstimator->CalculateGlideslopeDrift(tagData.GetRadarTarget(), *runway); | ||
if (drift.perpendicularDistanceFromLocaliser > 15) { | ||
return; | ||
} | ||
|
||
if (drift.localiserRange > 25) { | ||
return; | ||
} | ||
|
||
// Set the tag colour based on the drift | ||
if (std::abs(drift.drift) < 300) { | ||
tagData.SetTagColour(RGB(2, 48, 32)); | ||
} else { | ||
tagData.SetTagColour(RGB(255, 0, 0)); | ||
} | ||
|
||
// If we're massively out, abbreviate the string | ||
if (drift.drift > 999) { | ||
tagData.SetItemString(">1k"); | ||
return; | ||
} else if (drift.drift < -999) { | ||
tagData.SetItemString("<1k"); | ||
return; | ||
} | ||
|
||
// Set the tag item string | ||
const auto driftSign = drift.drift >= 0 ? "+" : ""; | ||
tagData.SetItemString(driftSign + std::to_string(drift.drift)); | ||
} | ||
} // namespace UKControllerPlugin::Approach |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma once | ||
#include "tag/TagItemInterface.h" | ||
|
||
namespace UKControllerPlugin { | ||
namespace Runway { | ||
class RunwayCollection; | ||
} // namespace Runway | ||
} // namespace UKControllerPlugin | ||
|
||
namespace UKControllerPlugin::Approach { | ||
|
||
class GlideslopeDriftEstimator; | ||
|
||
class GlideslopeDriftTagItem : public Tag::TagItemInterface | ||
{ | ||
public: | ||
GlideslopeDriftTagItem( | ||
std::shared_ptr<const GlideslopeDriftEstimator> glideslopeDriftEstimator, | ||
std::shared_ptr<const Runway::RunwayCollection> runways); | ||
auto GetTagItemDescription(int tagItemId) const -> std::string override; | ||
void SetTagItemData(Tag::TagData& tagData) override; | ||
|
||
private: | ||
// The glideslope drift estimator | ||
std::shared_ptr<const GlideslopeDriftEstimator> glideslopeDriftEstimator; | ||
|
||
// The runways | ||
std::shared_ptr<const Runway::RunwayCollection> runways; | ||
}; | ||
|
||
} // namespace UKControllerPlugin::Approach |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#pragma once | ||
|
||
namespace UKControllerPlugin::Geometry { | ||
[[nodiscard]] inline auto NauticalMilesToFeet(double nauticalMiles) -> double | ||
{ | ||
return nauticalMiles * 6076.115; | ||
} | ||
|
||
[[nodiscard]] inline auto FeetToNauticalMiles(double feet) -> double | ||
{ | ||
return feet / 6076.115; | ||
} | ||
} // namespace UKControllerPlugin::Geometry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.