Board index FlightGear Development Nasal

Precision Approach Radar (PAR)

Nasal is the scripting language of FlightGear.

Precision Approach Radar (PAR)

Postby rleibner » Mon Mar 12, 2018 11:55 pm

Hi all,

Since Spoken CGA has been replaced by the PAR addon, I think it's natural to move here the comments, feedback and discussion.

You can find PAR v.:0.0.5 here and all its documentation here.

Regards
Rodolfo
*************************
Non-shared knowledge is lost knowledge
User avatar
rleibner
 
Posts: 269
Joined: Fri May 19, 2017 8:17 pm
Location: Uruguay - SUMU
Callsign: CX-BEX
Version: next
OS: Ubuntu 18.04.4

Re: Precision Approach Radar (PAR)

Postby clm76 » Fri Mar 16, 2018 8:51 am

For information :
Line 59 of "par.nas" :
Code: Select all
var myGroup =  sk.root.createChild("group").set("font", "LiberationFonts/LiberationMono-Regular.ttf");

doesn't implement the font.
So I suggest to replace this line by :
Code: Select all
var myGroup =  sk.root.createChild("group");

and replace line 67 :
Code: Select all
m.frontGroup =  sk.root.createChild("group");

by :
Code: Select all
m.frontGroup =  sk.root.createChild("group").set("font","LiberationFonts/LiberationMono-Regular.ttf");

------------------
Line 362 :
Code: Select all
for(var i=1; i<size(nodes); i+=1) call(me.updateMark,[nodes[i]],me,var err = []);

You can replace
Code: Select all
var err = []

by
Code: Select all
err = []

The variable "err" is already defined at the top of the code (line 25). It's not very important but it prevents to redefine the variable and using garbage collector.
clm76
 
Posts: 204
Joined: Tue Oct 30, 2012 9:18 pm
Location: France - LFOH
Callsign: F-GCLM
Version: 2020.4.0
OS: Linux Mint 20.2

Re: Precision Approach Radar (PAR)

Postby rleibner » Fri Mar 16, 2018 3:33 pm

I agree, clm76. But we must be sure that all users have available the source that we choose:
Alant wrote in Fri Mar 02, 2018 10:25 pm:Be aware that the Liberation font family is not included in a standard windows installation.

It would be great if we had collaborators of Win and Mac: we could choose the best font that exists in the 3 OS.

EDITED:
In the meantime we ca try:
Code: Select all
var dir = directory(getprop("/sim/fg-root")~'/Fonts'); # get directory
foreach(d;dir) if( d=="LiberationFonts")
  m.frontGroup.set("font","LiberationFonts/LiberationMono-Regular.ttf");
Rodolfo
*************************
Non-shared knowledge is lost knowledge
User avatar
rleibner
 
Posts: 269
Joined: Fri May 19, 2017 8:17 pm
Location: Uruguay - SUMU
Callsign: CX-BEX
Version: next
OS: Ubuntu 18.04.4

Re: Precision Approach Radar (PAR)

Postby Alant » Fri Mar 16, 2018 4:57 pm

Today I noticed that Fgdata hasa Fonts directory, which includes liberation etc.

The question is- does FG use this directory with Linux, MACOS and Windows?

With Windows copying fonts to the system fonts directory does the trick.

Alan
Alant
 
Posts: 1219
Joined: Wed Jun 23, 2010 6:58 am
Location: Portugal
Callsign: Tarnish99
Version: latest Git
OS: Windows 10/11

Re: Precision Approach Radar (PAR)

Postby clm76 » Fri Mar 16, 2018 5:51 pm

rleibner wrote in Fri Mar 16, 2018 3:33 pm: It would be great if we had collaborators of Win and Mac: we could choose the best font that exists in the 3 OS.

I asked the french community which have Linux, Win and Mac users and the answer was "no problem with theses fonts".
In the plane I'm developping, all the SVG texts use the Liberation fonts because they are part of FG.
clm76
 
Posts: 204
Joined: Tue Oct 30, 2012 9:18 pm
Location: France - LFOH
Callsign: F-GCLM
Version: 2020.4.0
OS: Linux Mint 20.2

Re: Precision Approach Radar (PAR)

Postby rleibner » Fri Mar 16, 2018 8:49 pm

Fine !
So I'm uploading the changes just now.
Rodolfo
*************************
Non-shared knowledge is lost knowledge
User avatar
rleibner
 
Posts: 269
Joined: Fri May 19, 2017 8:17 pm
Location: Uruguay - SUMU
Callsign: CX-BEX
Version: next
OS: Ubuntu 18.04.4

Re: Precision Approach Radar (PAR)

Postby Thorsten » Sat Mar 17, 2018 7:58 am

The question is- does FG use this directory with Linux, MACOS and Windows?


At least my Win 10 setup and my Linux setup use the FG-side font directory.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Precision Approach Radar (PAR)

Postby rleibner » Sat Mar 17, 2018 1:08 pm

Thorsten wrote in Sat Mar 17, 2018 7:58 am:At least my Win 10 setup and my Linux setup use the FG-side font directory.
We only need to check it on MAC. Anyway, I tested to set a non-existing font: No problem, the default font is used with no other consequence than a warning
canvas::Text: No such font: FooFonts/Foo-Regular.ttf
Rodolfo
*************************
Non-shared knowledge is lost knowledge
User avatar
rleibner
 
Posts: 269
Joined: Fri May 19, 2017 8:17 pm
Location: Uruguay - SUMU
Callsign: CX-BEX
Version: next
OS: Ubuntu 18.04.4

Re: Precision Approach Radar (PAR)

Postby clm76 » Sat Apr 07, 2018 10:54 am

To avoid a blue vertical line when the PAR is launched,

Image

I suggest this modification of the "par.nas" :
Code: Select all
  appendTrack: func(node) {
    var (x,y,z) =  me.xyz(node);
    var absH =  me.xyGraph.xy([x,y]);
    if (absH[1] < 150) absH[1] = 150; # To avoid vertical line
    var absV =  me.xzGraph.xy([x,z]);
    if(me.HTrack.getNumSegments()==0) {
       me.HTrack.moveTo(absH);
       me.VTrack.moveTo(absV);
    }


The result : Image

To prevent some nasal errors (and a blocage of the PAR) when "me.touchObj.alt()" equals nil, probably when the destination tile is not loaded and the PAR launched too early, I suggest these changes in the code of "par.nas" and "tools.nas"
- In par.nas :
At the top :
Code: Select all
...
var gcaCtrl = nil;
var err = [];

### New ###
var dt = nil;

In update func :
Code: Select all
  update: func() { # called by me.timer

    ### New ###
    if (me.touchObj.alt() == nil) {me.touch();dt = 0}
    else {
      if (!dt) {me.drawTerrain();me.drawCones();dt = 1}
    }
    ###########

    var nodes = me.validNodes(range:me.maxX);
    me.Hmarks.group.removeAllChildren();
    me.Vmarks.group.removeAllChildren();
    ...

This change allow to wait after a valid "me.touchObj.alt()" and when it is validated, to redraw the terrain and the cone. "dt" is for only one shot.

In xyz func :
Code: Select all
  xyz: func(node) { # Relatives to touchObj
    var (dist,delta,altitude) = me.rhoDeltaAlt(node);
    var x = dist*math.cos(delta*D2R);
    var y = dist*math.sin(delta*D2R);

    ### Change ###
    if (me.touchObj.alt() != nil) {
      var z = altitude - me.touchObj.alt()*M2FT;
    } else {var z = altitude}
    ###########

    return [x,y,z]; # as nm,nm,ft
  }, # end of xyz

This change is to prevent a nasal error when "me.touchObj.alt()" = nil.

- In tools.nas :
Code: Select all
var getVertProfile = func(geoObj,direction,resolution,dist=32) {
#  direction in deg, resolution in nm, optional dist in nm.
...
if(from !=999){
 printf("Warning: found nils between %.2fnm and %.2fnm from rwy.",from*resolution,to*resolution);
}
#for(var i=-1; i>=-steps-1; i-=1) if(h[i]!=nil) h[i]=int((h[i]-h[0])*M2FT);

    ### Change ###
    for(var i=-1; i>=-steps-1; i-=1) if(h[i]!=nil and geoObj.alt() != nil) h[i]=int((h[i]-geoObj.alt())*M2FT);
    ##############

return h; #  elevations (ft) over geoObj
}

Idem, to prevent a nasal error.
clm76
 
Posts: 204
Joined: Tue Oct 30, 2012 9:18 pm
Location: France - LFOH
Callsign: F-GCLM
Version: 2020.4.0
OS: Linux Mint 20.2

Re: Precision Approach Radar (PAR)

Postby rleibner » Thu Apr 19, 2018 6:41 pm

Thanks, Christian. I've just committed version 0.0.8.
Regarding the vertical blue line, I took your idea as you suggested it.

Regarding the Terrain Profile (when destination tile is not loaded yet) I took your idea (to use the dt flag) with 2 modifications:
  • Testing geo.elevation instead of touchObj.alt.
  • Adding a warning message at the window title.
Thanks again for your contribution. :D
Rodolfo
*************************
Non-shared knowledge is lost knowledge
User avatar
rleibner
 
Posts: 269
Joined: Fri May 19, 2017 8:17 pm
Location: Uruguay - SUMU
Callsign: CX-BEX
Version: next
OS: Ubuntu 18.04.4

Re: Precision Approach Radar (PAR)

Postby clm76 » Fri Apr 27, 2018 9:08 am

Hi,

I brought some minor changes :
1 - To display the final airport elevation :
Between line 116 and 117
Code: Select all
me.altText = canvas.plot2D.text(me.frontGroup,'',[52,291],[10,1],white,'left-baseline');

For an easier reading of hdgText and dataText (lines 115-116), I replaced " [9,1] " by " [10,1]" , like altText.

In "setIcao : func(icao) {" , between lines 272 and 273 :
Code: Select all
me.altText.setText(sprintf("alt: %i ft",me.airport.elevation*3.28084));


2 - I inverted the zoom knob : It's more natural.
In "changeZoom : func(delta) {" , line 247 :
Code: Select all
 var f = delta==1? 2 : 0.5 ;

Instead of :
Code: Select all
var f = delta==1? 0.5 : 2 ;
clm76
 
Posts: 204
Joined: Tue Oct 30, 2012 9:18 pm
Location: France - LFOH
Callsign: F-GCLM
Version: 2020.4.0
OS: Linux Mint 20.2

Re: Precision Approach Radar (PAR)

Postby rleibner » Thu May 17, 2018 7:03 pm

Thanks Christian.
I've also added:
    * If Route manager is not active and Comm freq is not available, then the default ICAO is the nearest one.
    * When Terrain profile is not available, a warning msg is shown and
    * when Terrain is plotted an audible alert signal sounds.
Rodolfo
*************************
Non-shared knowledge is lost knowledge
User avatar
rleibner
 
Posts: 269
Joined: Fri May 19, 2017 8:17 pm
Location: Uruguay - SUMU
Callsign: CX-BEX
Version: next
OS: Ubuntu 18.04.4

Re: Precision Approach Radar (PAR)

Postby vdpp » Sat Mar 16, 2019 5:49 pm

Last edited by vdpp on Sun Mar 17, 2019 5:38 pm, edited 3 times in total.
vdpp
 
Posts: 1
Joined: Sat Mar 16, 2019 5:33 pm

Re: Precision Approach Radar (PAR)

Postby wkitty42 » Sat Mar 16, 2019 6:46 pm

you have to link to the image itself... not the page hosting the image...
"You get more air close to the ground," said Angalo. "I read that in a book. You get lots of air low down, and not much when you go up."
"Why not?" said Gurder.
"Dunno. It's frightened of heights, I guess."
User avatar
wkitty42
 
Posts: 9146
Joined: Fri Feb 20, 2015 4:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 20.04


Return to Nasal

Who is online

Users browsing this forum: No registered users and 3 guests