Debian Codegraph @

Nasal/canvas/map/vor.draw

raw
1 # WARNING: *.draw files will be deprecated, see: http://wiki.flightgear.org/MapStructure
2 var draw_vor = func (group, vor, controller=nil, lod = 0) {
3
4 if (0) {
5 if (controller == nil)
6 print("Ooops, VOR controller undefined!");
7 else
8 debug.dump( controller );
9 }
10
11 var lat = vor.lat;
12 var lon = vor.lon;
13 var name = vor.id;
14 var freq = vor.frequency;
15 var range = vor.range_nm;
16
17 # FIXME: Hack - implement a real controller for this!
18 var rangeNm = (controller!=nil) ? controller['query_range']() : 50;
19
20 var vor_grp = group.createChild("group",name);
21 var icon_vor = vor_grp.createChild("path", "vor-icon-" ~ name)
22 .moveTo(-15,0)
23 .lineTo(-7.5,12.5)
24 .lineTo(7.5,12.5)
25 .lineTo(15,0)
26 .lineTo(7.5,-12.5)
27 .lineTo(-7.5,-12.5)
28 .close()
29 .setStrokeLineWidth(3)
30 .setColor(0,0.6,0.85);
31
32 # next check if the current VOR is tuned, if so show it
33 # for this to work, we need a controller hash with an "is_tuned" member that points to a callback
34 # (set up by the layer managing this view)
35 # for an example, see the NavDisplay.newMFD() in navdisplay.mfd
36
37 if (controller != nil and controller['is_tuned'](freq/100)) {
38 # print("VOR is tuned:", name);
39 var radius = (range/rangeNm)*345;
40 var range_vor = vor_grp.createChild("path", "range-vor-" ~ name)
41 .moveTo(-radius,0)
42 .arcSmallCW(radius,radius,0,2*radius,0)
43 .arcSmallCW(radius,radius,0,-2*radius,0)
44 .setStrokeLineWidth(3)
45 .setStrokeDashArray([5, 15, 5, 15, 5])
46 .setColor(0,1,0);
47
48 var course = controller['get_tuned_course'](freq/100);
49 vor_grp.createChild("path", "radial-vor-" ~ name)
50 .moveTo(0,-radius)
51 .vert(2*radius)
52 .setStrokeLineWidth(3)
53 .setStrokeDashArray([15, 5, 15, 5, 15])
54 .setColor(0,1,0)
55 .setRotation(course*D2R);
56 icon_vor.setColor(0,1,0);
57 }
58 vor_grp.setGeoPosition(lat, lon)
59 .set("z-index",3);
60 }