• 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.

Course to selected waypoint

Messages
36
Hi.
I am writing a text gauge in which after clicking on a selected waypoint number,will be displayed the course to this waypoint.
For now,I have a script base in which,after entering a waypoint number(in the script file),displays its ID.
Ultimately,it would display a course to selected waypoint, but so far no code wants to work.
Unfortunately,I do not know how to do it using the -WPT1, WPT2, WPT3 buttons.
I tried various ways with XML and nothing works.
So I have two questions:
1.What code should I use to display a course to the selected waypoint instead of the "waypoint ID".
I tried to paste the code from line 29-"((A: GPS WP BEARING, Degrees) (A: Plane heading degrees gyro, degrees) - dnor)"
instead of -"(@ c: FlightPlanWaypointIdent)" from line 28, but it only indicates the course to waypoint 1.
2.What code to use so that the buttons,created by me,change the waypoint number to display.
Thx,
Rob.
XML:
<Gauge Name="Test" Version="1.0">


    <Macro Name="c">C:fs9gps</Macro>

    
 <Element>
     <Rectangle Width="200" Height="200" FillColor="white" Bright="No"/>
 

        <Element>
          <Position X="1" Y="1"/>
           <Select>
             <Value>
              sp0 1 (@c:FlightPlanWaypointsNumber) s0 l0 sp0   <!-- PT1. By changing the first sp0 value to 3,2 or 1,I change the waypoint  to 3,2 or 1,displayed in PT2. -->
             </Value>
            </Select>
          </Element>
  
        <Element>
           <Position X="1" Y="1"/>
           <FormattedText X="200" Y="200"  Font="Glassga" FontSize="20" LineSpacing="30" Color="blue" BackgroundColor="transparent" Bright="Yes">
             <String>   
              %WPT 1%
            \n%WPT 2%
            \n%WPT 3%
            \n%CRS TO SLCTD WPT: %( sp0 1 (@c:FlightPlanWaypointsNumber)
                if{ l0 (&gt;@c:FlightPlanWaypointIndex)  (@c:FlightPlanWaypointIdent) } )%!s!%  <!-- PT2. Waypoint data displayed on the basis of variables introduced in PT1. -->
            \n%CRS TO NXT WPT: %((A:GPS WP BEARING,Degrees) (A:Plane heading degrees gyro,degrees) - dnor )%!d!% <!-- PT3. Always displays the course to the next waypoint. -->
               </String>
            </FormattedText>
         </Element>     

 </Element>
 
 <!-- Waypoint select buttons -->
  <Mouse>
 
 <Area Left="1" Width="200" Top="1" Height="30">
             <Cursor Type="Hand"/>
         <Click>

         </Click>
     <Tooltip>WP1</Tooltip>
   </Area>
  
 <Area Left="1" Width="200" Top="40" Height="30">
             <Cursor Type="Hand"/>
         <Click>

         </Click>
     <Tooltip>WP2</Tooltip>
   </Area>
  
 <Area Left="1" Width="200" Top="70" Height="30">
             <Cursor Type="Hand"/>
         <Click>

         </Click>
     <Tooltip>WP3</Tooltip>
   </Area>
  
 </Mouse>
 
</Gauge>
g.png
 
After you select the desired waypoint index number, instead of looking at A:GPS WP bearing, retrieve the lat/lon of your selected waypoint using FlightPlanWaypointLatitude and Longitude.

Next, use GeoCalc variables to get bearing and/or distance from your aircraft to FlightPlanWaypointLatitude and Longitude.

For this, (A: PLANE LATITUDE, degrees) (>C:fs9gps:GeoCalcLatitude1, degrees) and (C:fs9gps:FlightPlanWaypointLatitude, degrees) (>C:fs9gps:GeoCalcLatitude2, degrees). Similar for Longitude.

Last, read (C:fs9gps:GeoCalcBearing, degrees) for bearing (true) to the indexed waypoint.


There are several issues with your XML. So, why don't you take a look at this gauge to see how to get Ident and Course to a waypoint selected by mouse click.

I split it into more Elements than you for instructional purposes:

XML:
<Gauge Name="Test" Version="1.0">

    <Size X="200" Y="200" />
    
    <Element><Position X="0" Y="0"/><Rectangle Width="200" Height="200" FillColor="gainsboro" Bright="Yes"/></Element>
    <Element Name="Click Area 1 Outline">
        <Position X="1" Y="0"/>
        <Rectangle Width="198" Height="30" Color="green" Bright="Yes"/>
    </Element>   
    <Element Name="Click Area 2 Outline">
        <Position X="1" Y="30"/>
        <Rectangle Width="198" Height="30" Color="blue" Bright="Yes"/>
    </Element>
    <Element Name="Click Area 3 Outline">
        <Position X="1" Y="60"/>
        <Rectangle Width="198" Height="30" Color="red" Bright="Yes"/>
    </Element>   
    <Element Name="WP 1">
        <Position X="4" Y="4"/>
        <FormattedText X="40" Y="9" Font="consolas" FontSize="10" LineSpacing="10" Color="green" BackgroundColor="gainsboro" Bright="Yes" Align="Right">
            <String>WPT 1</String>
        </FormattedText>
    </Element>
    <Element Name="WP 2">
        <Position X="4" Y="34"/>
        <FormattedText X="40" Y="9" Font="consolas" FontSize="10" LineSpacing="10" Color="blue" BackgroundColor="gainsboro" Bright="Yes" Align="Right">
            <String>WPT 2</String>
        </FormattedText>
    </Element>   
    <Element Name="WP 3">
        <Position X="4" Y="64"/>
        <FormattedText X="40" Y="9" Font="consolas" FontSize="10" LineSpacing="10" Color="red" BackgroundColor="gainsboro" Bright="Yes" Align="Right">
            <String>WPT 3</String>
        </FormattedText>
    </Element>       
    <Element Name="WPT IDENT">
        <Position X="4" Y="100"/>
        <FormattedText X="160" Y="9" Font="consolas" FontSize="10" LineSpacing="10" Color="#101010" BackgroundColor="gainsboro" Bright="Yes" Align="Right">
            <String>
                WAYPOINT IDENT: %((C:fs9gps:FlightPlanWaypointIdent))%!s!
            </String>
        </FormattedText>
    </Element>   
    <Element Name="COURSE TO SELECTED WAYPOINT">
        <Position X="4" Y="120"/>
        <FormattedText X="160" Y="9" Font="consolas" FontSize="10" LineSpacing="10" Color="#101010" BackgroundColor="gainsboro" Bright="Yes" Align="Right">
            <String>
                COURSE(M) TO WAYPOINT: %((A:PLANE LATITUDE, degrees) (>C:fs9gps:GeoCalcLatitude1, degrees)
                (A:PLANE LONGITUDE, degrees) (>C:fs9gps:GeoCalcLongitude1, degrees)   
                (C:fs9gps:FlightPlanWaypointLatitude, degrees) (>C:fs9gps:GeoCalcLatitude2, degrees)
                (C:fs9gps:FlightPlanWaypointLongitude, degrees) (>C:fs9gps:GeoCalcLongitude2, degrees)       
                (C:fs9gps:GeoCalcBearing, degrees) (A:MAGVAR, degrees) - dnor)%!3d!
            </String>
        </FormattedText>
    </Element>   

 <!-- Waypoint select buttons -->
    <Mouse>
        <Area Name="WPT 1" Left="0" Width="200" Top="0" Height="30">
            <Cursor Type="Hand"/>
            <Click>
                1 (>C:fs9gps:FlightPlanWaypointIndex)
            </Click>
            <Tooltip>WP1</Tooltip>
        </Area>

        <Area Name="WPT 2" Left="0" Width="200" Top="30" Height="30">
            <Cursor Type="Hand"/>
            <Click>
                2 (>C:fs9gps:FlightPlanWaypointIndex)
            </Click>
            <Tooltip>WP2</Tooltip>
        </Area>

        <Area Name="WPT 3" Left="0" Width="200" Top="60" Height="30">
            <Cursor Type="Hand"/>
            <Click>
                3 (>C:fs9gps:FlightPlanWaypointIndex)
            </Click>
            <Tooltip>WP3</Tooltip>
        </Area>
    </Mouse>
 
</Gauge>


Rob.png


Bob
 
Last edited:
Awesome.
Thank you, Bob.
And I was sitting on it for three days. For now, it's hard for me to understand all these "C: fs9gps:" ... o_O
I understand math, but logic in xml is not logical and confusing for me.:scratchch
I changed some of your code, adapting it to my needs ;) :
XML:
<Gauge Name="Test" Version="1.0">

 <Element>
     <Rectangle Width="200" Height="200" FillColor="white" Bright="No"/>
        <Element>
           <Position X="1" Y="1"/>
           <FormattedText X="200" Y="200"  Font="Glassga" FontSize="20" LineSpacing="30" Color="blue" BackgroundColor="transparent" Bright="Yes">
             <String>
               %WPT 1%
            \n%WPT 2%
            \n%WPT 3%
            \n%CRS TO SLCTD WPT: %((A:PLANE LATITUDE, degrees) (>C:fs9gps:GeoCalcLatitude1, degrees)
                (A:PLANE LONGITUDE, degrees) (>C:fs9gps:GeoCalcLongitude1, degrees)   
                (C:fs9gps:FlightPlanWaypointLatitude, degrees) (>C:fs9gps:GeoCalcLatitude2, degrees)
                (C:fs9gps:FlightPlanWaypointLongitude, degrees) (>C:fs9gps:GeoCalcLongitude2, degrees)       
                (C:fs9gps:GeoCalcBearing, degrees) (A:Plane heading degrees gyro,degrees) - dnor )%!3d!
              </String>
            </FormattedText>
         </Element>     

    <Element Name="WPT IDENT">
        <Position X="1" Y="150"/>
        <FormattedText X="200" Y="20" Font="Glassga" FontSize="20" LineSpacing="20" Color="blue" BackgroundColor="transparent" Bright="Yes">
            <String>
                WAYPOINT IDENT: %((C:fs9gps:FlightPlanWaypointIdent))%!s!
            </String>
        </FormattedText>
    </Element>           
 </Element>
 
 <!-- Waypoint select buttons -->
  <Mouse>
  <Area Left="1" Width="200" Top="1" Height="30">
             <Cursor Type="Hand"/>
         <Click>
                1 (>C:fs9gps:FlightPlanWaypointIndex)
         </Click>
     <Tooltip>WP1</Tooltip>
   </Area>
  
 <Area Left="1" Width="200" Top="40" Height="30">
             <Cursor Type="Hand"/>
         <Click>
                2 (>C:fs9gps:FlightPlanWaypointIndex)
         </Click>
     <Tooltip>WP2</Tooltip>
   </Area>
  
 <Area Left="1" Width="200" Top="70" Height="30">
             <Cursor Type="Hand"/>
         <Click>
               3 (>C:fs9gps:FlightPlanWaypointIndex)
         </Click>
     <Tooltip>WP3</Tooltip>
   </Area>
 </Mouse>
 
</Gauge>

XML is a bit illogical-mathematical language, for me.
For this I would have asked - could you explain to me how this script works:
XML:
%((A:PLANE LATITUDE, degrees) (>C:fs9gps:GeoCalcLatitude1, degrees)
(A:PLANE LONGITUDE, degrees) (>C:fs9gps:GeoCalcLongitude1, degrees)   
(C:fs9gps:FlightPlanWaypointLatitude, degrees) (>C:fs9gps:GeoCalcLatitude2, degrees)
(C:fs9gps:FlightPlanWaypointLongitude, degrees) (>C:fs9gps:GeoCalcLongitude2, degrees)       
(C:fs9gps:GeoCalcBearing, degrees) (A:Plane heading degrees gyro,degrees) - dnor )%
1. Are all lines between % and % executed as one continuous equation, or each line is a separate equation.
2. There are no mathematical characters between variables (there is no +, -, *, /), except "- dnor" at the end which I understand.
Answer in the easiest way, please.
Thank you again and best regards.
 
Psuedo code:
Code:
Move PLANE LATITUDE to GeoCalcLatitude1
Move PLANE LONGITUDE to GeoCalcLongitude1
Move FlightPlanWaypointLatitude to GeoCalcLatitude2
Move FlightPlanWaypointLongitude to GeoCalcLongitude2
// COMMENT: At this point GeoCalcBearing contains the resulting great circle course value towards the waypoint's lat/lon from the aircraft's lat/lon
Subtract Plane heading degrees gyro from GeoCalcBearing (which is the result of setting the lat/lon values above) and then normalize it.
That value is what results between the % signs.
 
WOW, and that's what I call a simple explanation ;)
Thank you WarpD.
Although it has little to do with math ... But XML is not mathematics. :confused:
Best Regards.
Rob
 
Back
Top