Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: display outbound leg information for holds
- Loading branch information
Showing
20 changed files
with
349 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include "Measurement.h" | ||
#include "MeasurementUnit.h" | ||
|
||
namespace UKControllerPlugin::Geometry { | ||
|
||
Measurement::Measurement(std::unique_ptr<MeasurementUnit> unit, double value) : unit(std::move(unit)), value(value) | ||
{ | ||
assert(this->unit && "Invalid unit in measurement"); | ||
} | ||
|
||
Measurement::~Measurement() = default; | ||
} // 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#pragma once | ||
#include "MeasurementUnit.h" | ||
|
||
namespace UKControllerPlugin::Geometry { | ||
|
||
struct MeasurementUnit; | ||
|
||
/** | ||
* A measurement, comprising a unit and a value | ||
*/ | ||
struct Measurement | ||
{ | ||
public: | ||
Measurement(std::unique_ptr<MeasurementUnit> unit, double value); | ||
~Measurement(); | ||
|
||
// The unit for the measurement | ||
std::unique_ptr<MeasurementUnit> unit; | ||
|
||
// The value of the measurement | ||
double value; | ||
}; | ||
} // 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include "MeasurementUnit.h" | ||
|
||
namespace UKControllerPlugin::Geometry { | ||
auto MeasurementUnit::operator==(const MeasurementUnitType& type) const -> bool | ||
{ | ||
return this->type == type; | ||
} | ||
} // 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#pragma once | ||
#include "MeasurementUnitType.h" | ||
|
||
namespace UKControllerPlugin::Geometry { | ||
struct MeasurementUnit | ||
{ | ||
MeasurementUnit(MeasurementUnitType type, std::string description) | ||
: type(type), description(std::move(description)){}; | ||
|
||
// An enum representing the unit type | ||
MeasurementUnitType type; | ||
|
||
// A description of the unit | ||
std::string description; | ||
|
||
[[nodiscard]] auto operator==(const MeasurementUnitType& type) const -> bool; | ||
}; | ||
} // 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include "MeasurementUnit.h" | ||
#include "MeasurementUnitFactory.h" | ||
|
||
namespace UKControllerPlugin::Geometry { | ||
|
||
auto UnitTypeFromString(const std::string& unitString) -> MeasurementUnitType | ||
{ | ||
if (unitString == "s") { | ||
return MeasurementUnitType::Seconds; | ||
} | ||
|
||
if (unitString == "min") { | ||
return MeasurementUnitType::Minutes; | ||
} | ||
|
||
if (unitString == "nm") { | ||
return MeasurementUnitType::NauticalMiles; | ||
} | ||
|
||
return MeasurementUnitType::None; | ||
} | ||
|
||
auto UnitToString(MeasurementUnitType unit) -> std::string | ||
{ | ||
if (unit == MeasurementUnitType::Seconds) { | ||
return "Seconds"; | ||
} | ||
|
||
if (unit == MeasurementUnitType::Minutes) { | ||
return "Minutes"; | ||
} | ||
|
||
if (unit == MeasurementUnitType::NauticalMiles) { | ||
return "NM"; | ||
} | ||
|
||
return "??"; | ||
} | ||
|
||
auto UnitFromString(const std::string& unitString) -> std::unique_ptr<MeasurementUnit> | ||
{ | ||
const auto unitType = UnitTypeFromString(unitString); | ||
return std::make_unique<MeasurementUnit>(unitType, UnitToString(unitType)); | ||
} | ||
|
||
auto UnitStringValid(const std::string& unitString) -> bool | ||
{ | ||
return UnitTypeFromString(unitString) != MeasurementUnitType::None; | ||
} | ||
} // 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#pragma once | ||
#include "MeasurementUnitType.h" | ||
|
||
namespace UKControllerPlugin::Geometry { | ||
struct MeasurementUnit; | ||
|
||
[[nodiscard]] auto UnitFromString(const std::string& unitString) -> std::unique_ptr<MeasurementUnit>; | ||
[[nodiscard]] auto UnitStringValid(const std::string& unitString) -> bool; | ||
} // 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#pragma once | ||
|
||
namespace UKControllerPlugin::Geometry { | ||
enum class MeasurementUnitType : unsigned int | ||
{ | ||
None, | ||
Seconds, | ||
Minutes, | ||
NauticalMiles, | ||
}; | ||
} // 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
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,61 @@ | ||
#include "geometry/MeasurementUnit.h" | ||
#include "geometry/MeasurementUnitType.h" | ||
#include "geometry/MeasurementUnitFactory.h" | ||
|
||
using UKControllerPlugin::Geometry::MeasurementUnitType; | ||
using UKControllerPlugin::Geometry::UnitFromString; | ||
using UKControllerPlugin::Geometry::UnitStringValid; | ||
|
||
namespace UKControllerPluginTest::Geometry { | ||
class MeasurementUnitFactoryTest : public testing::Test | ||
{ | ||
}; | ||
|
||
TEST_F(MeasurementUnitFactoryTest, ItReturnsSecondsFromString) | ||
{ | ||
const auto unit = UnitFromString("s"); | ||
EXPECT_EQ(*unit, MeasurementUnitType::Seconds); | ||
EXPECT_EQ(unit->description, "Seconds"); | ||
} | ||
|
||
TEST_F(MeasurementUnitFactoryTest, ItReturnsMinutesFromString) | ||
{ | ||
const auto unit = UnitFromString("min"); | ||
EXPECT_EQ(*unit, MeasurementUnitType::Minutes); | ||
EXPECT_EQ(unit->description, "Minutes"); | ||
} | ||
|
||
TEST_F(MeasurementUnitFactoryTest, ItReturnsNauticalMilesFromString) | ||
{ | ||
const auto unit = UnitFromString("nm"); | ||
EXPECT_EQ(*unit, MeasurementUnitType::NauticalMiles); | ||
EXPECT_EQ(unit->description, "NM"); | ||
} | ||
|
||
TEST_F(MeasurementUnitFactoryTest, ItReturnsUnknownUnitFromString) | ||
{ | ||
const auto unit = UnitFromString("abc"); | ||
EXPECT_EQ(*unit, MeasurementUnitType::None); | ||
EXPECT_EQ(unit->description, "??"); | ||
} | ||
|
||
TEST_F(MeasurementUnitFactoryTest, StringIsValidSeconds) | ||
{ | ||
EXPECT_TRUE(UnitStringValid("s")); | ||
} | ||
|
||
TEST_F(MeasurementUnitFactoryTest, StringIsValidMinutes) | ||
{ | ||
EXPECT_TRUE(UnitStringValid("min")); | ||
} | ||
|
||
TEST_F(MeasurementUnitFactoryTest, StringIsValidNauticalMiles) | ||
{ | ||
EXPECT_TRUE(UnitStringValid("nm")); | ||
} | ||
|
||
TEST_F(MeasurementUnitFactoryTest, StringIsNotValidUnknownString) | ||
{ | ||
EXPECT_FALSE(UnitStringValid("abc")); | ||
} | ||
} // namespace UKControllerPluginTest::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
Oops, something went wrong.