• 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

Messages
371
Country
france
Hi,

I have wrote a xml file to save the flight plan that I edit with my FMS.

But as you know, the 2 GPS functions (C:fs9gps:FlightPlanWaypointLatitude,degrees) (C:fs9gps:FlightPlanWaypointLongitude,degrees) return a value in decimal degrees.

So, the .pln file format of FSX needs degrees , minutes , seconds E/W N/S.

So, I have write a code to transform the decimal degrees in sexagimals degrees.

But in rare case (1 %) there is an error in the conversion:

here is my code :

Code:
(* Waypoint position latitude *)
(C:fs9gps:FlightPlanWaypointLatitude,degrees) abs 1 % 60 * 1 % 6000 * near 100 / (>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) }

I use the same code for the Longitude.


So , for an unknown reason , 1 times per week, I have a problem with a waypoint

For exemple, the fix "AGOPA" in France, produces this error (ICAO code "WLF AGOPA"), while all the other waypoints are properly converted


The orignal position of AGOPA in a FSx flight plan is :


Code:
 <ATCWaypoint id="AGOPA">
            <ATCWaypointType>Intersection</ATCWaypointType>
            <WorldPosition>N48° 5' 0.01",E2° 0' 35.00",+000000.00</WorldPosition>
            <ICAO>
                <ICAORegion>LF</ICAORegion>
                <ICAOIdent>AGOPA</ICAOIdent>
            </ICAO>
        </ATCWaypoint>


But when my gauge write my flight plan file, I have :

Code:
<ATCWaypoint id="AGOPA">
            <ATCWaypointType>Intersection</ATCWaypointType>
            <WorldPosition>N48° 5' 1[COLOR="Red"].[B]e-002[/B]",[/COLOR]E2° 0' 35.",+000000.00</WorldPosition>
            <ICAO>
                <ICAORegion>LF</ICAORegion>
                <ICAOIdent>AGOPA</ICAOIdent>
            </ICAO>
        </ATCWaypoint>

And my waypoint is in the antartic !!!!!!!!!! :confused:

Where is my error ?

Why that's happens ?
 
Last edited:
Hi,

I have simplified my code. But no change in the result. All the waypoints work except "AGOPA" or few others.

here is my new code :

Code:
(* Waypoint position latitude *)
[B](C:fs9gps:FlightPlanWaypointLatitude,degrees) abs 1 % 60 * 1 % 60 * (>L:Seconds,number)[/B]
(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 degres *)
'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 minute *)
'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 *)
'VarTemp' (>C:XMLVARS:SearchVarName,string) 
(L:Seconds,number) (>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)

The problem is with the seconds ; it seems as the modulo function had a bug !

now, the result is :
Code:
<ATCWaypoint id="AGOPA">
            <ATCWaypointType>Intersection</ATCWaypointType>
            <WorldPosition>N48° 5' [COLOR="Red"][B]1.4697e-002",[/B][/COLOR]E2° 0' 35.001",+000000.00</WorldPosition>
            <ICAO>
                <ICAORegion>LF</ICAORegion>
                <ICAOIdent>AGOPA</ICAOIdent>
            </ICAO>
        </ATCWaypoint>

What is this mysterious ?
 
what it means to 1.4697e-002? it really is a number or is it that it is the "e" is a code of a mathematical error
 
what it means to 1.4697e-002? it really is a number or is it that it is the "e" is a code of a mathematical error

It's a real number. e refers to "e"xponent. So, 1.4697e-002 is the same as 0.014697. You probably only have a number formatting issue.

Bob
 
Thank you for your help Bob !

I am not at home to test, but it means that I must complete my actual code for the seconds like this :

actual code
Code:
(C:fs9gps:FlightPlanWaypointLatitude,degrees) abs 1 % 60 * 1 % 60 * (>L:Seconds,number)


new code
Code:
(C:fs9gps:FlightPlanWaypointLatitude,degrees) abs 1 % 60 * 1 % 60 * (>L:Seconds,number)
(L:Seconds,number) 100 * near 100 / (>L:Seconds,number)

In this case, I must solved the problem and have only 2 digits after the decimal point.

Do you think ?
 
I become crazy !!!!!!! :mad: :eek: :confused:

by use "(L:Seconds,number) 100 * near 100 / (>L:Seconds,number)" i must have a number with only 2 digits after the comma, but not; there is always this 1.4697e-002

I don't understand !

And that's arrives only with 2 specific waypoints ! all others work perfectly !


Is there a bug in the xml langage ? a bug of my processor ?

For me, it is impossible !
 
I become crazy !!!!!!! :mad: :eek: :confused:

by use "(L:Seconds,number) 100 * near 100 / (>L:Seconds,number)" i must have a number with only 2 digits after the comma, but not; there is always this 1.4697e-002

I don't understand !

And that's arrives only with 2 specific waypoints ! all others work perfectly !


Is there a bug in the xml langage ? a bug of my processor ?

For me, it is impossible !

It's not a bug but rather a Floating Point effect :)

To make it simple, try using

(L:Seconds,number) 100 * near 100 / (>C:XMLVARS:StringValue,string)

Shoud work fine, but if it doesn't, the key would be to make the string in parts, digesting the number to each one of its digits and using scat for the union.

Hope this helps.

Tom
 
Here is the original flight plan created with the FSX Flight planner :
http://www.db-online.fr/francois/temp/IFR%20Orly%20to%20Merignac2.PLN




here is the flight plan saved by my gauge, after add my SID :
http://www.db-online.fr/francois/temp/ORLY.PLN

All the waypoint are ok, except "AGOPA" !

I am crazy ...........

here is the link to my flight plansaved gauge
http://www.db-online.fr/francois/temp/Save_FP.xml

line 187-206 for the latitude waypoints conversion

line 208-227 for the longitude waypoints conversion
 
Last edited:
Nobody has an idea ?

For me, that's mean that there is a bug either in the modulo function of the xml parser, or in the "near/flr" function.

I don't see other explnation

I am desesperate, all my project is stopped :banghead:
 
I have already tried tom ; same result :confused:

Ok, then let's see what is being saved to XMLVars string.

Just write an element like this (Pseudocode) :
Just notice the 1 at the end of <Visible>

Code:
<Element>
  <Visible>'TestString' (>C:XMLVARS:SearchVarName,string) (L:Seconds,number) 100 * near 100 / (>C:XMLVARS:StringValue,string) [B]1[/B]</Visible>
  <Position XY>
  <FormattedText ...etc>
  <String>('TestString' (>C:XMLVARS:SearchVarName,string) (C:XMLVARS:StringValue,string))!s!</String>
</Element>

Your output should be 1.4697e-002, if it is not then the problem is related to LOGGER string savings.

Tom
 
Have you considered using the @ExtDigit macro posted in the Wiki here?

http://fsdeveloper.com/wiki/index.php?title=XML:_Macros_-_Extracting_Digits

I will test with these macro, but I wouod like to know why threre is tis error which has no reason to appears !




Ok, then let's see what is being saved to XMLVars string.

Just write an element like this (Pseudocode) :
Just notice the 1 at the end of <Visible>

Code:
<Element>
  <Visible>'TestString' (>C:XMLVARS:SearchVarName,string) (L:Seconds,number) 100 * near 100 / (>C:XMLVARS:StringValue,string) [B]1[/B]</Visible>
  <Position XY>
  <FormattedText ...etc>
  <String>('TestString' (>C:XMLVARS:SearchVarName,string) (C:XMLVARS:StringValue,string))!s!</String>
</Element>

Your output should be 1.4697e-002, if it is not then the problem is related to LOGGER string savings.

Tom

I have test your code, but the problem is when the gauge saves the flight plan, the value of (L:seconds,number) changes 20 times in one seconds, so I have not the time to see. I see only the last value (exemple 2.03).


The problem is that it arrives, for the moment, only with five waypoints which are the same Latitude :
- PILUL , OKASI, LATRA , ERIXU and AGOPA. (WLF PILUL, WLF OKASI, .....)


These five waypoints are in France and they are the end of five SID of PARIS-Orly airport LFPO.

I have wrote hundred of flight plan with my gauge, and she had always works fine.
The error appears only with the latitude of these 5 waypoints that finish by 0.01 seconds.

Open the 2 .pln file that I have posted above, the first is an original flight plan of FSX where I have include with the FSX flight planner the waypoint AGOPA.

The second is the flight plan wrote by my gauge. Only the latitude of AGOPA has the errors in the seconds.

this is a crazy story :eek:




What's the connection with LOGGER?

What do you mean ?

I open my file by :
Code:
'FD_FMC\\' 'VarFlightPlanNameFile' (>C:XMLVARS:SearchVarName,string) (C:XMLVARS:StringValue,string) scat '.PLN' scat (>C:LOGGER:openWrite)

and I write the flight plan line aabout Latitude longitude of each waypoint with this code :
Code:
'            &lt;WorldPosition&gt;' 'VarWaypointLatitude' (>C:XMLVARS:SearchVarName,string) (C:XMLVARS:StringValue,string) scat ',' scat 'VarWaypointLongitude' (>C:XMLVARS:SearchVarName,string) (C:XMLVARS:StringValue,string) scat ',+' scat 'VarWaypointAltitude' (>C:XMLVARS:SearchVarName,string) (C:XMLVARS:StringValue,string) scat '&lt;/WorldPosition&gt;' scat (>C:LOGGER:String)
 
I will try to separate the calculation of the seconds and the hundredth of seconds.

Maybe a solution.....
 
Last edited:
I have just try to separate the seconds and hundreth of seconds calculation :

Code:
(* Waypoint position latitude *)
(C:fs9gps:FlightPlanWaypointLatitude,degrees) abs 1 % 60 * 1 % 60 * 1 % 100 * flr 100 / (>L:hundredth_Seconds,number)
(C:fs9gps:FlightPlanWaypointLatitude,degrees) abs 1 % 60 * 1 % 60 * near (>L:Seconds,number)
(L:Seconds,number) (L:hundredth_Seconds,number) + (>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) }



the result is the same
 
Nothing work

I have tried many solution and nothing work

my last test was :

Code:
'VarNumber' (>C:XMLVARS:SearchVarName,Number)
(C:fs9gps:FlightPlanWaypointLatitude,degrees) abs 1 % 60 * 1 % 60 * 1 % 100 * near (>C:XMLVARS:NumberValue,Number)
																
99 0(C:XMLVARS:NumberValue,Number) rng if{ (C:XMLVARS:NumberValue,Number) 100 / (>L:hundredth_Seconds,number)  } els{ 0.01 (>L:hundredth_Seconds,number) }

(C:fs9gps:FlightPlanWaypointLatitude,degrees) abs 1 % 60 * 1 % 60 * near (>L:Seconds,number)
(L:Seconds,number) (L:hundredth_Seconds,number) + (>L:Seconds,number)

and I've got the same result for the seconds of the latitude of AGOPA : 1.e-002

Is there a possibility in xml to detect an error (specific xml instructions...) as "On Error Goto" of the Visual Basic language ?


All other waypoints are OK.

I think that "1.e-002" is not a number in this case, but a error return of the xml.

I am sure now that it is an bug of the xml code, an error
(C:fs9gps:FlightPlanWaypointLatitude,degrees) abs 1 % 60 * 1 % 60 * 100 * near 100 / (>L:Seconds,number) causes an error with AGOPA or ERIXu ....because it is impossible that the line return a number with more than 2 digits after the comma. It is impossible.

I have try to detect the "e" with a ssub function, that doesn't work.

Nothing work

And why that's arrived only with these 5 waypoints ?


You can try the gauge in your own aircraft. I have put all the explanation in the comment header of the file.



Since 3 days, I had try all solutions. I am desesperate.......
 
Last edited:
Fdd_fr,

I haven't used the XML.Strings module at all (yet) but I believe that is where it all gets bad for you.. Formatting-wise 0.014697 is a "number" and is probably handled well by the (L:Seconds,number) you use. Try using a test gauge to confirm that this L:Var (the L:Var only) is indeed correct. The problem arises when you load it into (>C:XMLVARS:StringValue,string) because the "string" of 0.014697 is indeed 1.4697e-002. Can the XMLStrings module do this? (>C:XMLVARS:StringValue,number) or give you the return as (C:XMLVARS:StringValue,number)? If so the handling of "string" and "numbers" will be done internally. If this is so, you can then scat everything up and then finally put it into a full string for your final output. Just a hunch, I run into this often w/VB express but the IDE let's me know of the mistake.

EDIT - I see now that you've tried ",number" as a suffix.. Maybe try multiplying all the decimal seconds by 100, 1000, or 10000 prior to writing it to the >C:XMLVARS var. I could be wrong but have never seen a number like 146.94e-002 or the like. It usually happens when a number is less than 1. Then on your write output use something like ((C:XMLVARS:StringValue,number) / 1000) scat

Roman
 
Last edited:
Fdd_fr,


EDIT - I see now that you've tried ",number" as a suffix.. Maybe try multiplying all the decimal seconds by 100, 1000, or 10000 prior to writing it to the >C:XMLVARS var. I could be wrong but have never seen a number like 146.94e-002 or the like. It usually happens when a number is less than 1. Then on your write output use something like ((C:XMLVARS:StringValue,number) / 1000) scat

Roman

I have already tried this solution and in this case, the value return always 0.

For me, the only explanation that i see is the result 1.e-002 is an error caused by the modulo function (because after the modulo, the near, flr, int div don't works). because after, the modulo, I cannot do anything with the value, what is a L:var or a C:XMLVARS.

The mysterious is why that's occurs with only these 5 waypoints ?

For me, it is a error code, not a number.
 
Last edited:
I will test and display tonight the value returned by (C:fs9gps:FlightPlanWaypointLatitude,degrees) for these five waypoints.

Maybe, their values have many digits after the comma......
 
Back
Top