wow that was 3 hours debugging trying to work out why I was struggling to get
a MODULE_VAR { PLANE_LATITUDE } to cast the FLOAT64 var_value.n value into a
FLOAT as per the docs which says it’s in RADIANS. I was assuming some strange
positioning of the FLOAT inside the FLOAT64 struct member. But the simple
answer is the PLANE_LATITUDE number is in “meters latitude” & the docs need
correcting. Degrees would probably be better units unless there’s a
definitive MSFS conversion function available for WASM, but there’s a tricky
issue of anyone already coding to the “meters latitude” units.
OOPS - it seems like token variable { PLANE_LONGITUDE } is giving a completely
strange value, e.g. 0.143323755 “degrees longitude” (simvar watcher) is
reported as token var var_value.n = “6420636893184.00000000” so it might not
be a SDK documentation issue. If it’s a bug, and I should put it in Zendesk,
please let me know.
Hello @B21 You can report DevMode/SDK related bugs here
but you want to use a question rather than an idea. You are right, the units
for these token variables are wrong in the documentation, we will fix this.
Regards, Sylvain
Note that the degrees longitude are encoded as “Radians”, which is a custom
data type that encodes angles using “pi over 10”, so a half circle doesn’t
have a Float64 angle of 3.1415[…] but 0.31415[…] (you will get values in
this format for any other Radians variable too, like heading, bank angle,
etc.). You can convert these to degrees by using 180*angle/0.31415 so in this
case your 0.143323755 converts to 82.1184626547 degrees East. That said, the
docs can probably make that clearer in
https://docs.flightsimulator.com/html/Programming_Tools/SimVars/Simulation_Variable_Units.htm
because while the longitude is in degrees longitude, those degrees are not
encoded using “1 radian is the floating point value 1.0”.
@TheRealPomax I think your explanation has
the vars the wrong way round - my sim aircraft WAS at 0.143323755 degrees
East, I know where I parked the aircraft (in the UK) and also I could see that
correctly using the SimVarWatcher for (A:PLANE LONGITUDE, degrees longitude).
So I know the correct answer and the token variable has to somehow represent
that. So if get var_value.n = “6420636893184.00000000” when I request the
token var { PLANE_LONGITUDE } for the same sim aircraft still in the same
position, what’s the formula that would convert that to any number in any
units I would understand, e.g. 0.14332 deg , or the equivalent in radians?
Token var { PLANE_LATITUDE } is correct but in meters latitude (unusual
units, tbh) so { PLANE_LONGITUDE } might be encoding meters longitude but if
so it’s an incomprehensible formula. I’m guessing those vars weren’t
completed/tested when the build was shipped.
Ahh, that does change things considerably. What code are you using for the
data request? Because I’m polling MSFS via SimConnect and am getting values
back in radians, as expected.