• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Decimal degrees conversion random error

If you want test the gauge, (the link to download is in a previous post), she needs XMLVARS.dll and Loggerx.dll

the XMLVARs used by the gauge and that must be delared are :

'VarWaypointLongitude' (>C:XMLVARS:StoreVarName,string) is the longitude of a waypoint in Degrees, minutes, seconds
'VarWaypointLatitude' (>C:XMLVARS:StoreVarName,string) is the latitude of a waypoint in Degrees, minutes, seconds
'VarWaypointAltitude' (>C:XMLVARS:StoreVarName,string) is the allatitude of a waypoint if exists
'VarWaypointType' (>C:XMLVARS:StoreVarName,string) is the type of waypoint (vor,NDB, user, airport ...)
'VarAircraftPosition' (>C:XMLVARS:StoreVarName,string) is the start position of the aircraft(Gate , parking runway ....=
'VarFlightPlanNameFile' (>C:XMLVARS:StoreVarName,string) is the name of your saved PLN file
'VarTemp' (>C:XMLVARS:StoreVarName,string) is a temp variable to convert decimal degrees in degrees , minutes , seconds

And you must create the folder "FD_FMC" in your main FSX folder.

To use the gauge you have just to set:

- a flightplan name in 'VarFlightPlanNameFile' (>C:XMLVARS:SearchVarName,string) 'your flight plan name' (>C:XMLVARS:StringValue,string)
- the original aircraft position of the FSX flight plan that used as base (eg '26' for a runway, or 'GATE B 1" in 'VarAircraftPosition' (>C:XMLVARS:StringValue,string)

and to launch the save of the flight plan, by set to 1 (>L:Save_FPLN_Save,bool) (at the end of the record, the gauge reset the value to 0)

You can attrib this (L:Save_FPLN_Save,bool) to a button of your cockpit.


Test it
 
Last edited:
I believe the others are suggesting to compose "0.01" out of four strings "0" + "." + "0" + "1".

The issue is that small numbers, like "0.01", seem to either be represented by FS or interpreted by Logger as a string with scientific number format (e.g. 10^-2 = 1E-2=1.e-002).

Try the following (has to be refined - I've never worked with scat or logger):

Code:
(C:fs9gps:FlightPlanWaypointLatitude,degrees) abs 1 % 60 * 1 % 60 * flr (>L:Seconds,number)
(C:fs9gps:FlightPlanWaypointLatitude,degrees) abs 1 % 60 * 1 % 60 * 1 % 10 * flr (>L:tenth_Seconds_Digit,number)
(C:fs9gps:FlightPlanWaypointLatitude,degrees) abs 1 % 60 * 1 % 60 * 1 % 10 * 1% flr (>L:hundredth_Seconds_Digit,number)

(L:Seconds,number) '.' scat (L:tenth_Seconds_Digit,number) scat (L:hundredth_Seconds_Digit,number) scat (>C:XMLVARS:StringValue,string)

I believe this should generate a string "0.01" for the above example.
 
I don't think, because, I have other waypoints that result 0.02 seconds for example and that's works.
 
ok, i will try tonight, I am now at my office, and unfortunately, I havn't FSX on my computer :D
 
Francois,

Or this:

Code:
(@c:FacilityLatitude, degrees) int (>L:LatDegrees, enum)
(@c:FacilityLatitude, degrees) (L:LatDegrees, enum) - 60 * d (>L:LatMinutesDecimal, number) int (>L:LatMinutes, enum)
(L:LatMinutesDecimal, number) (L:LatMinutes, enum) - 60 * d (>L:LatSecondsDecimal, number) int (>L:LatSeconds, enum)
(L:LatSecondsDecimal, number) (L:LatSeconds, enum) - 100 * int 100 / (>L:LatSecondsPoint2, enum)

and your coordinate is in the form of

(L:LatDegrees, enum)
(L:LatMinutes, enum)
(L:LatSeconds, enum) '.' scat (L:LatSecondsPoint2, enum) scat - with two significant digits to the right of the decimal point. It avoids the scientific notation issue by truncating the seconds after the second decimal point. It's similar to other recommendations like teson's but less elegant and more brute force. Bill's is a unique one and if you're not aware of that digit extraction macro, check it out, it might come in handy from time to time. Also look at the extracting part of a string wiki.

Reading through this post, I think everyone has a workable suggestion, it just depends how you want to go about it.

I agree with the others that the issue relates to a number (in this case, angular seconds) that is very small, but not quite zero. You need 00.00, not 1.2345 e-002

I don't think the issue relates to LOGGER.

Bob
 
Last edited:
I remarked several typos in my code (as usual) - here's an update:
Code:
(C:fs9gps:FlightPlanWaypointLatitude,degrees) abs 1 % 60 * 1 % 60 * flr (>L:Seconds,number) 
(C:fs9gps:FlightPlanWaypointLatitude,degrees) abs 1 % 60 * 1 % 60 * 1 % 10 * flr (>L:tenth_Seconds_Digit,number) 
(C:fs9gps:FlightPlanWaypointLatitude,degrees) abs 1 % 60 * 1 % 60 * 1 % 10 * 1 % 10 * flr (>L:hundredth_Seconds_Digit,number) 

(L:Seconds,number) '.' scat (L:tenth_Seconds_Digit,number) scat (L:hundredth_Seconds_Digit,number) scat (>C:XMLVARS:StringValue,string)
Bob - so right :)
 
Monitor
Code:
<String>%((L:Seconds,number))%!14.12f!%</String>
to be sure that is correct prior to writing to the string. I bet it is.

Roman
 
I will try your solutions Bob and Teson.

I am sure that the issue not comes from Logger or xmlvars. For me, the issue comes from FSX xml.

the number is not so small as the original flight plan to FSX returns the value 0.01 for the seconds value for these waypoints.

And I have other waypoints where my gauge return 0.01 seconds without problem.

my brain probably too small to understand what happens....
 
Last edited:
RPMC and teson, I have just try your 2 solution;

In the 2 cases, the seconds = 0.

I think that I must do a bad thing to translate your code....

I continue to search....

The thing that I don't iunderstand, is that with my process, if I do a test as

(L:Seconds,number) 0.015 &lt; if{ 0.01 (>L:Seconds,number) }

And that doesn't work whebn the variable has 1.e-002 as value.

This is the thing that make me think that this 1.e-002 is not a number, otherwise, my test should be work .
 
Last edited:
The 5 waypoints that cause the problem have all the same latitude :

WLF AGOPA
WLF PILUL
WLF LATRA
WLF ERIXU
WLF OKASI


When I write directy with logger "(C:fs9gps:FlightPlanWaypointLatitude,degrees)"
the latitude is 48.083

If I (C:fs9gps:FlightPlanWaypointLatitude,degrees) (>L:Latittude,number) and I write with logger (L:Latittude,number) the result is the same 48.083


My gauge return : N48° 5' 1.e-002"
FSX flight planner return : N48° 5' 0.01"
A online web converter return : N48° 4' 58.7994"



This latitude : 48.083 cause a problem

Why ?

All others work !

And when I have 1.e-002 in the variable, I can not do operations, multiplications, aditions .... and no test; nothing work with the variable.
 
Last edited:
Code:
(L:Seconds,number) '.' scat (L:tenth_Seconds_Digit,number) scat (L:hundredth_Seconds_Digit,number) scat (>C:XMLVARS:StringValue,string)

Try to add a "ord chr" behind variables:
Code:
(L:Seconds,number) ord chr 
'.' scat 
(L:tenth_Seconds_Digit,number) ord chr scat 
(L:hundredth_Seconds_Digit,number) ord chr scat
(>C:XMLVARS:StringValue,string)
 
Strange...

Instead of calculating the real latitude seconds try what WP latitude seconds are written to the flight plan with the following manual attribution to WP latitude seconds:

0.01 (>C:XMLVARS:StringValue,string)
0.1 (>C:XMLVARS:StringValue,string)
'0.01' (>C:XMLVARS:StringValue,string)

I am still convinced that 1.e-002 is scientific number format.
Try calculations within xml with
1E-002
1.E-002
1e-002
maybe minuscule e doesn not work in xml?
 
Last edited:
Unfortunately, there's not a simple solution to your problem.

This issue happens because of the way FSX converts numeric values stored in the stack to string chars. The XML stack is managed as a group of bytes rather than numeric or string data. In consequence, any number retrieved from there is going to be treated as numeric if it is being assigned to a numeric variable or as a result of a XML command/string text's numeric evaluation, or rounded and converted to a string if it is being assigned to a string variable or a string text's string evaluation. Data stored and enclosed with ' ' is treated as literal string, and stored as is into a string variable, or stored as 0 into a numeric var/expression.

For example:

1234.456 (>L:Numeric,number)
displays in a <String>
when !4.1f! ----> 1234.5
when !4.2f! -----> 1234.46
when !4.3f! -----> 1234.456

1234.456 (>C:XMLVars:StringValue,string)
displays in a <String>
when !s! ----> 1234.5

Now,
'1234.456' (>C:XMLVars:StringValue,string)
displays in a <String>
when !s! ----> 1234.456
because the first and last ' make FSX store the data as literal string.

'1234.456' (>L:Numeric,number)
displays in a numeric <String>, in any case -----> 0.

Floating point numbers are converted and rounded depending on the amount of decimal chars.

For example:

123456789 shows as !s! = 123456789
123456789.1234 shows as !s! = 1.2346e+008
0.01 shows as !s! = 1.e-002

So, this is not an XMLVars nor LOGGER issue but an FSX native interpretation.

In your case, the only possible way to overcome this inconvenience is to store each digit in an individual XMLVars string variable. The ExDigit macro I wrote so long ago could be a good method, as Bill suggested, but certainly there might be others.

Hope this helps

Tom

Edit: This way is pretty much simpler: try to round the value to a decent number of decimals, and then use a case operator to extract the equivalent string. For example:

Code:
(L:Your value,number) 0.1 &lt; (L:Your value,number) 0 > and 
if{ '0.1' '0.09' '0.08' '0.07' '0.06' '0.05' '0.04' '0.03' '0.02' '0.01' '0' 11 (L:Your value,number) 100 * near case  (>C:XMLVars:StringValue,string) }
els{ (L:Your value,number)  (>C:XMLVars:StringValue,string)  }
 
Last edited:
Eureka, I have found the solution and it seems to work in all case.

here is my horrible code but it works :
Code:
(* Waypoint position latitude *)
(* latitude Hundredth of Seconds*)
(C:fs9gps:FlightPlanWaypointLatitude,degrees) abs 1 % 60 * 1 % 60 * 1 % 100 * near (>L:Hundredth_Seconds,number)
'Hundredth_Seconds_String' (>C:XMLVARS:SearchVarName,string)
(L:Hundredth_Seconds,number) 10 &lt; if{ '0' (L:Hundredth_Seconds,number) scat (>C:XMLVARS:StringValue,string) } els{ (L:Hundredth_Seconds,number) (>C:XMLVARS:StringValue,string) }    
(* latitude Seconds*)
(C:fs9gps:FlightPlanWaypointLatitude,degrees) abs 1 % 60 * 1 % 60 * near (>L:Seconds,number)
(C:fs9gps:FlightPlanWaypointLatitude,degrees) abs 1 % 60 * flr (>L:Minutes,number)
(C:fs9gps:FlightPlanWaypointLatitude,degrees) abs flr (>L:Degrees,number)
(L:Seconds,number) 60 == if{ (L:Minutes,number) 1 + (>L:Minutes,number) 0.00 (>L:Seconds,number) }
(L:Minutes,number) 60 == if{ (L:Degrees,number) 1 + (>L:Degrees,number) 0 (>L:Minutes,number) } 
(* Latitude degrees *)
'VarTemp' (>C:XMLVARS:SearchVarName,string)
(L:Degrees,number) flr (>C:XMLVARS:StringValue,string)
(C:fs9gps:FlightPlanWaypointLatitude,degrees) 0 &lt; if{ 'S' (C:XMLVARS:StringValue,string) scat (>C:XMLVARS:StringValue,string) } els{ 'N' (C:XMLVARS:StringValue,string) scat (>C:XMLVARS:StringValue,string) }
'VarWaypointLatitude' (>C:XMLVARS:SearchVarName,string) (C:XMLVARS:StringValue,string) 'VarTemp' (>C:XMLVARS:SearchVarName,string) (C:XMLVARS:StringValue,string) scat 194 chr scat '° ' scat 'VarWaypointLatitude' (>C:XMLVARS:SearchVarName,string) (>C:XMLVARS:StringValue,string)
(* Latitude minutes *)
'VarTemp' (>C:XMLVARS:SearchVarName,string) 
(L:Minutes,number) flr (>C:XMLVARS:StringValue,string)
'VarWaypointLatitude' (>C:XMLVARS:SearchVarName,string) (C:XMLVARS:StringValue,string) 'VarTemp' (>C:XMLVARS:SearchVarName,string) (C:XMLVARS:StringValue,string) scat '&apos;&apos; ' scat 'VarWaypointLatitude' (>C:XMLVARS:SearchVarName,string) (>C:XMLVARS:StringValue,string)
(* Latitude seconde et centieme de seconde *)
'Hundredth_Seconds_String' (>C:XMLVARS:SearchVarName,string) 
(L:Seconds,number) (C:XMLVARS:StringValue,string) scat 'VarTemp' (>C:XMLVARS:SearchVarName,string) (>C:XMLVARS:StringValue,string)
(C:XMLVARS:StringValue,string) slen (>G:Var9) (C:XMLVARS:StringValue,string) 0 (G:Var9) 1 - ssub (>C:XMLVARS:StringValue,string)
'VarWaypointLatitude' (>C:XMLVARS:SearchVarName,string) (C:XMLVARS:StringValue,string) 'VarTemp' (>C:XMLVARS:SearchVarName,string) (C:XMLVARS:StringValue,string) scat '"' scat 'VarWaypointLatitude' (>C:XMLVARS:SearchVarName,string) (>C:XMLVARS:StringValue,string)

I think that you find this code horrible, but this is the only one that works. I had used some trick to delete the trailing decimal point of the vars.

Now, I takeonly in consideration that the problem may occurs only when the hundredth of seconds are under 0.10. I hope that the problem will not appear for other value.


Thank you for your help


Francois
 
Last edited:
Congrats,

Why do you need 194 chr? What does it produce?

This was an interesting thread. You got further than I did. My gauges crash when I include a degrees symbol in the XML like you did ('° '). Maybe its related to the way my editor, notepad++, is configured, no idea, but I just gave up at that point.
 
Hi bob,


I am in business trip today, but i promise you that l respond to about chr194 and others characters tomorrow.

Francois
 
Hi,

According to the SDK, chr: Converts a number to a symbol.

I assume it converts 194 into the ANSI symbol:

http://www.alanwood.net/demos/ansi.html

Which is A with a caret, but I could be wrong.

When I want to print a degree symbol in a String command, I use

& #176; (without the space between the & and the #) which prints: °

Hope this helps,
 
Last edited:
Hi,

According to the SDK, chr: Converts a number to a symbol.

I assume it converts 194 into the ANSI symbol:

http://www.alanwood.net/demos/ansi.html

Which is A with a caret, but I could be wrong.

When I want to print a degree symbol in a String command, I use

& #176; (without the space between the & and the #) which prints: °

Hope this helps,

Hi Tom,

Thanks. I know that, but I wanted to know why 194.
 
Last edited:
Back
Top