high/low aircraft relative altitude modes
|
@ -10,7 +10,11 @@ var element_type = "group";
|
||||||
var terrain_minalt = props.globals.initNode("/custom/terrain/min-altitude", 0,"INT");
|
var terrain_minalt = props.globals.initNode("/custom/terrain/min-altitude", 0,"INT");
|
||||||
var terrain_maxalt = props.globals.initNode("/custom/terrain/max-altitude", -9999,"INT");
|
var terrain_maxalt = props.globals.initNode("/custom/terrain/max-altitude", -9999,"INT");
|
||||||
|
|
||||||
var tile_list = ["*black*","tile_01.png","tile_02.png","tile_03.png","tile_04.png","tile_06.png","tile_09.png","tile_s1.png"];
|
var tile_list = [
|
||||||
|
nil,"tile_gl.png","tile_gh.png","tile_yl.png","tile_yh.png","tile_rh.png", # 0-5 low alt
|
||||||
|
"tile_gl.png","tile_gh.png","tile_gs.png",nil, # 6-9 hi alt
|
||||||
|
"tile_ml.png","tile_cl.png" # 10 magenta - 11 cyan (water)
|
||||||
|
];
|
||||||
|
|
||||||
var is_terrain = 0;
|
var is_terrain = 0;
|
||||||
|
|
||||||
|
@ -36,6 +40,7 @@ var updateTerrain = func {
|
||||||
if (me.request_clear == 1) {
|
if (me.request_clear == 1) {
|
||||||
me.request_clear = 0;
|
me.request_clear = 0;
|
||||||
me.clear();
|
me.clear();
|
||||||
|
me.group.setVisible(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
var RAD2DEG = 57.2957795;
|
var RAD2DEG = 57.2957795;
|
||||||
|
@ -44,15 +49,17 @@ var updateTerrain = func {
|
||||||
var pos_lat = me.reference.lat();
|
var pos_lat = me.reference.lat();
|
||||||
var pos_lon = me.reference.lon();
|
var pos_lon = me.reference.lon();
|
||||||
|
|
||||||
var heading = me.reference.heading;
|
var heading = me.refheading;
|
||||||
var altitudeft = me.reference.altitudeft;
|
var altitudeft = me.refaltitudeft;
|
||||||
|
var lowaltft = me.reflowaltft;
|
||||||
|
var basealtft = me.basealtitudeft;
|
||||||
|
|
||||||
var side = (math.mod(me.radar_beacon,2)==0) ? "L" : "R";
|
var side = (math.mod(me.radar_beacon,2)==0) ? "L" : "R";
|
||||||
var a = int(me.radar_beacon/2);
|
var a = int(me.radar_beacon/2);
|
||||||
var col = a;
|
var col = a + 0.5;
|
||||||
|
|
||||||
if (side == "R") {
|
if (side == "R") {
|
||||||
col = -1 + (-1 * a);
|
col = -col;
|
||||||
}
|
}
|
||||||
|
|
||||||
var trn = me.terrlayer[side ~ a];
|
var trn = me.terrlayer[side ~ a];
|
||||||
|
@ -67,6 +74,8 @@ var updateTerrain = func {
|
||||||
|
|
||||||
var elevft = [];
|
var elevft = [];
|
||||||
|
|
||||||
|
me.radar_cleared = 0;
|
||||||
|
|
||||||
for (var row = 0; row < len; row += 1) {
|
for (var row = 0; row < len; row += 1) {
|
||||||
|
|
||||||
if (trn[row] == nil) {
|
if (trn[row] == nil) {
|
||||||
|
@ -80,36 +89,44 @@ var updateTerrain = func {
|
||||||
var elev = me.get_elevation(point_lat, point_lon);
|
var elev = me.get_elevation(point_lat, point_lon);
|
||||||
var grad = 0; #black
|
var grad = 0; #black
|
||||||
if (elev != nil) {
|
if (elev != nil) {
|
||||||
if (me.is_terrain) {
|
if (elev<me.min_altitude) me.min_altitude = elev;
|
||||||
if (elev<me.min_altitude) me.min_altitude = elev;
|
else if (elev>me.max_altitude) me.max_altitude = elev;
|
||||||
else if (elev>me.max_altitude) me.max_altitude = elev;
|
if (me.is_terrain) {
|
||||||
if (elev < me.basealtitudeft) grad = 0; # < 400 near runway use blank
|
if (elev < basealtft) grad = 0; # < 400 near runway use blank
|
||||||
else {
|
else {
|
||||||
var diff = elev - altitudeft;
|
var diff = elev - altitudeft;
|
||||||
if (diff>=0) {
|
if (diff>=0) {
|
||||||
grad = int(diff/1000) + 3;
|
grad = int(diff/1000) + 3;
|
||||||
if (grad>5) grad = 5;
|
if (grad>5) grad = 5;
|
||||||
} else {
|
} else {
|
||||||
if (diff>-500) grad = 3; # lite yellow
|
if (me.hialtmode == 0) {
|
||||||
else {
|
if (diff>=lowaltft) grad = 3; # lite yellow
|
||||||
grad = 2 + int(diff/1000);
|
else {
|
||||||
if (grad<0) grad = 0;
|
grad = 2 + int(diff/1000);
|
||||||
}
|
if (grad<0) grad = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (diff>=lowaltft) grad = 3; # lite yellow
|
||||||
|
else {
|
||||||
|
if (me.bands_range > 0 and elev > me.bands_minalt) {
|
||||||
|
elev -= me.bands_minalt;
|
||||||
|
grad = int(elev / (me.bands_range / 3)) + 6;
|
||||||
|
if (grad>8) grad = 8; # solid green
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var diff = elev - altitudeft;
|
grad = 11; #water
|
||||||
if (diff>=-2000) grad = 7; #sea
|
|
||||||
}
|
}
|
||||||
append(elevft,grad); # 0-5
|
append(elevft,grad); # 0-5
|
||||||
} else {
|
} else {
|
||||||
append(elevft,6); # magenta
|
append(elevft,0); # no data - black (magenta)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
me.radar_cleared = 0;
|
|
||||||
|
|
||||||
for (var r=0; r < len; r+=1) {
|
for (var r=0; r < len; r+=1) {
|
||||||
var imgx = elevft[r];
|
var imgx = elevft[r];
|
||||||
if (imgx == -1) continue;
|
if (imgx == -1) continue;
|
||||||
|
@ -122,21 +139,31 @@ var updateTerrain = func {
|
||||||
me.update_altitudes();
|
me.update_altitudes();
|
||||||
me.restart_beacon();
|
me.restart_beacon();
|
||||||
}
|
}
|
||||||
|
|
||||||
#me.last_request = getprop("sim/time/elapsed-sec");
|
|
||||||
me.fetching = 0;
|
me.fetching = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
var update_altitudes = func {
|
var update_altitudes = func {
|
||||||
me.terrain_minalt.setValue(me.min_altitude);
|
me.terrain_minalt.setValue(me.min_altitude);
|
||||||
me.terrain_maxalt.setValue(me.max_altitude);
|
me.terrain_maxalt.setValue(me.max_altitude);
|
||||||
|
|
||||||
|
if (me.max_altitude < me.refaltitudeft) {
|
||||||
|
me.hialtmode = 1;
|
||||||
|
} else {
|
||||||
|
me.hialtmode = 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var restart_beacon = func {
|
var restart_beacon = func {
|
||||||
me.radar_beacon = 0;
|
me.radar_beacon = 0;
|
||||||
me.radar_cycle += 1;
|
me.radar_cycle += 1;
|
||||||
me.min_altitude = 9999;
|
me.bands_minalt = me.min_altitude;
|
||||||
|
me.bands_maxalt = math.max(1000,me.max_altitude); # band min limit to 1000 ft - trivial
|
||||||
|
me.bands_range = me.bands_maxalt - me.bands_minalt;
|
||||||
|
me.min_altitude = 9999;
|
||||||
me.max_altitude = -9999;
|
me.max_altitude = -9999;
|
||||||
|
me.reference = nil;
|
||||||
};
|
};
|
||||||
|
|
||||||
var init = func {
|
var init = func {
|
||||||
|
@ -155,9 +182,13 @@ var init = func {
|
||||||
me.visible = 0;
|
me.visible = 0;
|
||||||
me.min_altitude = 9999;
|
me.min_altitude = 9999;
|
||||||
me.max_altitude = -9999;
|
me.max_altitude = -9999;
|
||||||
|
me.bands_minalt = 0;
|
||||||
|
me.bands_maxalt = 0;
|
||||||
|
me.bands_range = 0;
|
||||||
me.basealtitudeft = nil;
|
me.basealtitudeft = nil;
|
||||||
me.reference = nil;
|
me.reference = nil;
|
||||||
me.onfailure = 0;
|
me.onfailure = 0;
|
||||||
|
me.hialtmode = 0; # high aircraft relative altitude mode
|
||||||
|
|
||||||
var tile = me.tile;
|
var tile = me.tile;
|
||||||
|
|
||||||
|
@ -196,14 +227,10 @@ var init = func {
|
||||||
me.terrlayer["L" ~ c] = grplx;
|
me.terrlayer["L" ~ c] = grplx;
|
||||||
me.terrlayer["R" ~ c] = grprx;
|
me.terrlayer["R" ~ c] = grprx;
|
||||||
}
|
}
|
||||||
|
|
||||||
setlistener("/controls/switches/terr_on_nd_l", func{
|
|
||||||
me.request_clear = 1;
|
|
||||||
});
|
|
||||||
|
|
||||||
setlistener("/ECAM/warnings/timer/nav-gpws-terr-fault", func{
|
#setlistener("/ECAM/warnings/timer/nav-gpws-terr-fault", func{ # TODO need further investigations
|
||||||
me.onfailure = getprop("/ECAM/warnings/timer/nav-gpws-terr-fault");
|
# me.onfailure = getprop("/ECAM/warnings/timer/nav-gpws-terr-fault");
|
||||||
});
|
#});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -236,19 +263,20 @@ var draw = func {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (me.radar_beacon == 0) { # update aircraft reference
|
if (me.reference == nil) { # update aircraft reference
|
||||||
|
|
||||||
var ref = geo.aircraft_position();
|
var ref = geo.aircraft_position();
|
||||||
me.reference = ref;
|
me.reference = ref;
|
||||||
if (ref != nil) {
|
if (ref != nil) {
|
||||||
me.reference.heading = getprop("orientation/heading-magnetic-deg");
|
me.refheading = getprop("orientation/heading-magnetic-deg");
|
||||||
me.reference.altitudeft = ref.alt() * 3.2808399;
|
|
||||||
|
|
||||||
if (me.basealtitudeft == nil) {
|
var refalt = ref.alt() * 3.2808399;
|
||||||
|
me.refaltitudeft = refalt;
|
||||||
|
me.reflowaltft = (pts.Gear.position[1].getValue()) ? -250 : -500;
|
||||||
|
|
||||||
|
if (fmgc.FMGCInternal.phase<2) {
|
||||||
#var basealtft = me.get_elevation(ref.lat,ref.lon);
|
#var basealtft = me.get_elevation(ref.lat,ref.lon);
|
||||||
var basealtft = ref.alt() * 3.2808399;
|
me.basealtitudeft = refalt + 400;
|
||||||
if (basealtft == nil) basealtft = 0;
|
|
||||||
me.basealtitudeft = basealtft + 400;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (fmgc.FMGCInternal.phase >= 5 and me.basealtitudeft == 0) {
|
#if (fmgc.FMGCInternal.phase >= 5 and me.basealtitudeft == 0) {
|
||||||
|
@ -260,19 +288,26 @@ var draw = func {
|
||||||
#else if ((fmgc.FMGCInternal.phase > 1 and fmgc.FMGCInternal.phase < 5) and (me.basealtitudeft != 0)) {
|
#else if ((fmgc.FMGCInternal.phase > 1 and fmgc.FMGCInternal.phase < 5) and (me.basealtitudeft != 0)) {
|
||||||
# me.basealtitudeft = 0;
|
# me.basealtitudeft = 0;
|
||||||
#}
|
#}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (me.layer.display_changed == 1) {
|
||||||
|
me.layer.display_changed = 0;
|
||||||
|
me.request_clear = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
var range = me.layer.map.getRange(); # Range of Navigation Display
|
||||||
|
var update_size = (range != me.range);
|
||||||
|
me.range = range;
|
||||||
|
|
||||||
|
if(update_size){
|
||||||
|
me.request_clear = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
me.updateTerrain(); # left
|
||||||
|
if (math.mod(me.radar_beacon,2)==1) me.updateTerrain(); # right
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var range = me.layer.map.getRange(); # Range of Navigation Display
|
|
||||||
var update_size = (range != me.range);
|
|
||||||
me.range = range;
|
|
||||||
|
|
||||||
if(update_size){
|
|
||||||
me.request_clear = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
me.updateTerrain(); # left
|
|
||||||
if (math.mod(me.radar_beacon,2)==1) me.updateTerrain(); # right
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
BIN
Models/Instruments/ND/canvas/res/terrain/tile_cl.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
Models/Instruments/ND/canvas/res/terrain/tile_gh.png
Normal file
After Width: | Height: | Size: 2 KiB |
Before Width: | Height: | Size: 182 B After Width: | Height: | Size: 182 B |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
BIN
Models/Instruments/ND/canvas/res/terrain/tile_rh.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 182 B After Width: | Height: | Size: 182 B |
Before Width: | Height: | Size: 1.8 KiB |
BIN
Models/Instruments/ND/canvas/res/terrain/tile_yh.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 2 KiB After Width: | Height: | Size: 2 KiB |
Before Width: | Height: | Size: 181 B After Width: | Height: | Size: 181 B |
|
@ -97,6 +97,8 @@ canvas.NDStyles["Airbus"] = {
|
||||||
(nd.adirs_property.getValue() == 1 or (adirs_3.getValue() == 1 and att_switch.getValue() == nd.attitude_heading_setting));
|
(nd.adirs_property.getValue() == 1 or (adirs_3.getValue() == 1 and att_switch.getValue() == nd.attitude_heading_setting));
|
||||||
if (visible) {
|
if (visible) {
|
||||||
layer.update();
|
layer.update();
|
||||||
|
} else {
|
||||||
|
layer.display_changed = 1;
|
||||||
}
|
}
|
||||||
layer.group.setVisible(visible);
|
layer.group.setVisible(visible);
|
||||||
}, # end of layer update predicate
|
}, # end of layer update predicate
|
||||||
|
|