|
From: Tobias D. <tda...@gm...> - 2018-06-28 06:48:24
|
Btw., here's the "expose hold data to nasal" patch as I have it so far:
commit 509c30f79961f865e887b20fee77f0ae29aa25c8
Author: Tobias Dammers <tda...@gm...>
Date: Thu Jun 21 18:29:49 2018 +0200
Expose holding point data in nasal
diff --git a/src/Scripting/NasalPositioned.cxx b/src/Scripting/NasalPositioned.cxx
index 22953bb2b..eb9030b2f 100644
--- a/src/Scripting/NasalPositioned.cxx
+++ b/src/Scripting/NasalPositioned.cxx
@@ -494,6 +494,44 @@ static const char* waypointCommonGetMember(naContext c, Waypt* wpt, const char*
*out = waypointAirport(c, wpt);
} else if (!strcmp(fieldName, "runway")) {
*out = waypointRunway(c, wpt);
+ } else if (!strcmp(fieldName, "hold_is_left_handed")) {
+ Hold* hold = dynamic_cast<Hold*>(wpt);
+ if (hold)
+ *out = naNum(hold->isLeftHanded());
+ else
+ return nullptr;
+ } else if (!strcmp(fieldName, "hold_is_distance")) {
+ Hold* hold = dynamic_cast<Hold*>(wpt);
+ if (hold)
+ *out = naNum(hold->isDistance());
+ else
+ return nullptr;
+ } else if (!strcmp(fieldName, "hold_is_time")) {
+ Hold* hold = dynamic_cast<Hold*>(wpt);
+ if (hold)
+ *out = naNum(!hold->isDistance());
+ else
+ return nullptr;
+ } else if (!strcmp(fieldName, "hold_inbound_radial")) {
+ Hold* hold = dynamic_cast<Hold*>(wpt);
+ if (hold)
+ *out = naNum(hold->inboundRadial());
+ else
+ return nullptr;
+ } else if (!strcmp(fieldName, "hold_heading_radial_deg")) {
+ Hold* hold = dynamic_cast<Hold*>(wpt);
+ if (hold)
+ *out = naNum(hold->inboundRadial());
+ else
+ return nullptr;
+ } else if (!strcmp(fieldName, "hold_time_or_distance")) {
+ // This is the leg length, defined either as a time in seconds, or a
+ // distance in nm.
+ Hold* hold = dynamic_cast<Hold*>(wpt);
+ if (hold)
+ *out = naNum(hold->timeOrDistance());
+ else
+ return nullptr;
} else {
return nullptr; // member not found
}
I removed the hold_by property, and added a convenience complement
hold_is_time, which is just the opposite of hold_is_distance.
Also, I remembered the reason why I used hld_ rather than hold_: it's
what the XML procedures use.
|