Rename important date to milestone

This commit is contained in:
Ylva Selling
2023-04-11 15:58:24 -04:00
parent 5a1caf31dc
commit bb7079a845
4 changed files with 28 additions and 44 deletions
@@ -5,7 +5,7 @@ local Mission = {
TimeRange = { Start = "2004 MAR 02 00:00:00", End = "2016 SEP 30 00:00:00" },
Description = "ESA's Rosetta mission was the first to rendezvous with a comet, the first to follow a comet on its orbit around the Sun, and the first to deploy a lander to a comet's surface. Comets are time capsules containing primitive material left over from the epoch when the Sun and its planets formed. By studying the gas, dust and structure of the nucleus and organic materials associated with the comet, via both remote and in situ observations, the Rosetta mission is unlocking the history and evolution of our Solar System.",
Media = { Image = "https://www.cosmos.esa.int/documents/522118/522182/Rosetta_logo.png/cd85878d-2fac-e086-e32a-df0eaee5e505?t=1614026031720" },
ImportantDates = {
Milestones = {
{
Name = "Launch",
Date = "2004 MAR 02 09:00:00"
@@ -22,7 +22,8 @@ local Mission = {
Name = "Mars gravity assist",
Date = "2007 FEB 25 00:00:00",
Description = "The Rosetta swing-by of Mars is the second of four gravity assist manoeuvres that are required to place Rosetta on course for its final destination: comet 67P/Churyumov-Gerasimenko. The closest approach of the swing-by will take place at 01:54 UT, 25 February 2007, when the spacecraft will pass 250 km above the surface of Mars.",
Image = "https://www.esa.int/var/esa/storage/images/esa_multimedia/images/2007/02/image_of_mars_seen_by_osiris/10287257-2-eng-GB/Image_of_Mars_seen_by_OSIRIS_pillars.jpg"
Image = "https://www.esa.int/var/esa/storage/images/esa_multimedia/images/2007/02/image_of_mars_seen_by_osiris/10287257-2-eng-GB/Image_of_Mars_seen_by_OSIRIS_pillars.jpg",
Link = "https://sci.esa.int/web/rosetta/-/40697-rosetta-mars-swing-by"
},
{
Name = "Second Earth gravity assist",
+3 -3
View File
@@ -37,7 +37,7 @@ namespace openspace {
namespace documentation { struct Documentation; }
struct ImportantDate {
struct Milestone {
std::string name;
Time date;
std::optional<std::string> description;
@@ -117,7 +117,7 @@ public:
*
* \return All important dates
*/
const std::vector<ImportantDate>& importantDates() const;
const std::vector<Milestone>& milestones() const;
/**
@@ -177,7 +177,7 @@ protected:
/// Actions associated with the phase
std::vector<std::string> _actions;
/// Important dates
std::vector<ImportantDate> _importantDates;
std::vector<Milestone> _milestones;
};
/**
+5 -22
View File
@@ -35,12 +35,6 @@
using nlohmann::json;
namespace {
constexpr const char* EventKey = "event";
constexpr const char* StartSubscription = "start_subscription";
constexpr const char* StopSubscription = "stop_subscription";
} // namespace
namespace openspace {
bool MissionTopic::isDone() const {
@@ -48,7 +42,6 @@ bool MissionTopic::isDone() const {
}
nlohmann::json MissionTopic::missionJson() const {
const std::map<std::string, Mission>& missions =
global::missionManager->missionMap();
@@ -81,9 +74,9 @@ nlohmann::json MissionTopic::createPhaseJson(const MissionPhase& phase) const {
phases.push_back(subphaseJson);
}
json importantDates = json::array();
const std::vector<ImportantDate>& dates = phase.importantDates();
for (const ImportantDate& date : dates) {
json milestones = json::array();
const std::vector<Milestone>& dates = phase.milestones();
for (const Milestone& date : dates) {
json jsonDate = {
{ "date", std::string(date.date.ISO8601())},
{ "name", date.name }
@@ -98,7 +91,7 @@ nlohmann::json MissionTopic::createPhaseJson(const MissionPhase& phase) const {
if (date.link.has_value()) {
jsonDate["link"] = date.link.value();
}
importantDates.push_back(jsonDate);
milestones.push_back(jsonDate);
}
std::string startTimeString = std::string(Time(phase.timeRange().start).ISO8601());
@@ -117,23 +110,13 @@ nlohmann::json MissionTopic::createPhaseJson(const MissionPhase& phase) const {
{ "image", phase.image() },
{ "link", phase.link() }
}},
{ "importantDates" , importantDates }
{ "milestones" , milestones }
};
return phaseJson;
}
void MissionTopic::handleJson(const nlohmann::json& input) {
//const std::string& event = input.at(EventKey).get<std::string>();
//if (event == StartSubscription) {
// // TODO: subsribe to misisons to emit events
// // missionManager.subscribe(); ...
//}
//else if (event == StopSubscription) {
// // TODO: Unsubsribe to misisons
// // missionManager.subscribe(); ...
// return;
//}
nlohmann::json data = { {"missions", missionJson()} };
_connection->sendJson(wrappedPayload(data));
}
+17 -17
View File
@@ -66,7 +66,7 @@ namespace {
std::optional<std::vector<std::string>> actions;
// Important dates
struct ImportantDates {
struct Milestone {
// An image that can be presented to the user during this phase of a mission
std::string date;
std::string name;
@@ -74,7 +74,7 @@ namespace {
std::optional<std::string> image;
std::optional<std::string> link;
};
std::optional<std::vector<ImportantDates>> importantDates;
std::optional<std::vector<Milestone>> milestones;
};
#include "mission_codegen.cpp"
} // namespace
@@ -162,22 +162,22 @@ MissionPhase::MissionPhase(const ghoul::Dictionary& dictionary) {
_actions = p.actions.value_or(_actions);
}
if (p.importantDates.has_value()) {
_importantDates.reserve(p.importantDates->size());
for (int i = 0; i < p.importantDates->size(); i++) {
std::string name = p.importantDates.value()[i].name;
Time newTime = Time(p.importantDates.value()[i].date);
ImportantDate newDate = { name, newTime };
if (p.importantDates.value()[i].description.has_value()) {
newDate.description = p.importantDates.value()[i].description.value();
if (p.milestones.has_value()) {
_milestones.reserve(p.milestones->size());
for (int i = 0; i < p.milestones->size(); i++) {
std::string name = p.milestones.value()[i].name;
Time newTime = Time(p.milestones.value()[i].date);
Milestone newDate = { name, newTime };
if (p.milestones.value()[i].description.has_value()) {
newDate.description = p.milestones.value()[i].description.value();
}
if (p.importantDates.value()[i].image.has_value()) {
newDate.image = p.importantDates.value()[i].image.value();
if (p.milestones.value()[i].image.has_value()) {
newDate.image = p.milestones.value()[i].image.value();
}
if (p.importantDates.value()[i].link.has_value()) {
newDate.link = p.importantDates.value()[i].link.value();
if (p.milestones.value()[i].link.has_value()) {
newDate.link = p.milestones.value()[i].link.value();
}
_importantDates.emplace_back(newDate);
_milestones.emplace_back(newDate);
}
}
}
@@ -202,8 +202,8 @@ const std::string& MissionPhase::link() const {
return _link;
}
const std::vector<ImportantDate>& MissionPhase::importantDates() const {
return _importantDates;
const std::vector<Milestone>& MissionPhase::milestones() const {
return _milestones;
}
const std::vector<MissionPhase>& MissionPhase::phases() const {