| 1 |
# WARNING: *.draw files will be deprecated, see: http://wiki.flightgear.org/MapStructure |
| 2 |
var draw_traffic = func(group, traffic, lod=0) |
| 3 |
{ |
| 4 |
var a = traffic; |
| 5 |
var tcas_group = group; |
| 6 |
|
| 7 |
var callsign = a.getNode("callsign").getValue(); |
| 8 |
# print("Drawing traffic for:", callsign ); |
| 9 |
var lat = a.getNode("position/latitude-deg").getValue(); |
| 10 |
var lon = a.getNode("position/longitude-deg").getValue(); |
| 11 |
var alt = a.getNode("position/altitude-ft").getValue(); |
| 12 |
var dist = a.getNode("radar/range-nm").getValue(); |
| 13 |
var threatLvl = a.getNode("tcas/threat-level",1).getValue(); |
| 14 |
var raSense = a.getNode("tcas/ra-sense",1).getValue(); |
| 15 |
var vspeed = a.getNode("velocities/vertical-speed-fps").getValue()*60; |
| 16 |
var altDiff = alt - getprop("/position/altitude-ft"); |
| 17 |
|
| 18 |
var tcas_grp = tcas_group.createChild("group", callsign); |
| 19 |
|
| 20 |
var text_tcas = tcas_grp.createChild("text") |
| 21 |
.setDrawMode( canvas.Text.TEXT ) |
| 22 |
.setText(sprintf("%+02.0f",altDiff/100)) |
| 23 |
.setFont("LiberationFonts/LiberationSans-Regular.ttf") |
| 24 |
.setColor(1,1,1) |
| 25 |
.setFontSize(28) |
| 26 |
.setAlignment("center-center"); |
| 27 |
if (altDiff > 0) |
| 28 |
text_tcas.setTranslation(0,-40); |
| 29 |
else |
| 30 |
text_tcas.setTranslation(0,40); |
| 31 |
if(vspeed >= 500) { |
| 32 |
var arrow_tcas = canvas.draw_tcas_arrow_above_500(tcas_grp); |
| 33 |
} elsif (vspeed < 500) { |
| 34 |
var arrow_tcas = canvas.draw_tcas_arrow_below_500(tcas_grp); |
| 35 |
} |
| 36 |
|
| 37 |
## TODO: threat level symbols should also be moved to *.draw files |
| 38 |
var icon_tcas = tcas_grp.createChild("path") |
| 39 |
.setStrokeLineWidth(3); |
| 40 |
if (threatLvl == 3) { |
| 41 |
# resolution advisory |
| 42 |
icon_tcas.moveTo(-17,-17) |
| 43 |
.horiz(34) |
| 44 |
.vert(34) |
| 45 |
.horiz(-34) |
| 46 |
.close() |
| 47 |
.setColor(1,0,0) |
| 48 |
.setColorFill(1,0,0); |
| 49 |
text_tcas.setColor(1,0,0); |
| 50 |
arrow_tcas.setColor(1,0,0); |
| 51 |
} elsif (threatLvl == 2) { |
| 52 |
# traffic advisory |
| 53 |
icon_tcas.moveTo(-17,0) |
| 54 |
.arcSmallCW(17,17,0,34,0) |
| 55 |
.arcSmallCW(17,17,0,-34,0) |
| 56 |
.setColor(1,0.5,0) |
| 57 |
.setColorFill(1,0.5,0); |
| 58 |
text_tcas.setColor(1,0.5,0); |
| 59 |
arrow_tcas.setColor(1,0.5,0); |
| 60 |
} elsif (threatLvl == 1) { |
| 61 |
# proximate traffic |
| 62 |
icon_tcas.moveTo(-10,0) |
| 63 |
.lineTo(0,-17) |
| 64 |
.lineTo(10,0) |
| 65 |
.lineTo(0,17) |
| 66 |
.close() |
| 67 |
.setColor(1,1,1) |
| 68 |
.setColorFill(1,1,1); |
| 69 |
} else { |
| 70 |
# other traffic |
| 71 |
icon_tcas.moveTo(-10,0) |
| 72 |
.lineTo(0,-17) |
| 73 |
.lineTo(10,0) |
| 74 |
.lineTo(0,17) |
| 75 |
.close() |
| 76 |
.setColor(1,1,1); |
| 77 |
} |
| 78 |
|
| 79 |
tcas_grp.setGeoPosition(lat, lon) |
| 80 |
.set("z-index",4); |
| 81 |
|
| 82 |
|
| 83 |
#settimer(func drawtraffic(group), 2); # updates are handled by the model, not by the view! |
| 84 |
}; |