diff --git a/Models/Instruments/ND/canvas/map/TERRAIN.symbol b/Models/Instruments/ND/canvas/map/TERRAIN.symbol index b1934b8e..554e9800 100644 --- a/Models/Instruments/ND/canvas/map/TERRAIN.symbol +++ b/Models/Instruments/ND/canvas/map/TERRAIN.symbol @@ -10,7 +10,11 @@ var element_type = "group"; 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 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; @@ -36,6 +40,7 @@ var updateTerrain = func { if (me.request_clear == 1) { me.request_clear = 0; me.clear(); + me.group.setVisible(1); } var RAD2DEG = 57.2957795; @@ -44,15 +49,17 @@ var updateTerrain = func { var pos_lat = me.reference.lat(); var pos_lon = me.reference.lon(); - var heading = me.reference.heading; - var altitudeft = me.reference.altitudeft; + var heading = me.refheading; + var altitudeft = me.refaltitudeft; + var lowaltft = me.reflowaltft; + var basealtft = me.basealtitudeft; var side = (math.mod(me.radar_beacon,2)==0) ? "L" : "R"; var a = int(me.radar_beacon/2); - var col = a; + var col = a + 0.5; if (side == "R") { - col = -1 + (-1 * a); + col = -col; } var trn = me.terrlayer[side ~ a]; @@ -67,6 +74,8 @@ var updateTerrain = func { var elevft = []; + me.radar_cleared = 0; + for (var row = 0; row < len; row += 1) { if (trn[row] == nil) { @@ -80,36 +89,44 @@ var updateTerrain = func { var elev = me.get_elevation(point_lat, point_lon); var grad = 0; #black if (elev != nil) { - if (me.is_terrain) { - if (elevme.max_altitude) me.max_altitude = elev; - if (elev < me.basealtitudeft) grad = 0; # < 400 near runway use blank + if (elevme.max_altitude) me.max_altitude = elev; + if (me.is_terrain) { + if (elev < basealtft) grad = 0; # < 400 near runway use blank else { var diff = elev - altitudeft; if (diff>=0) { grad = int(diff/1000) + 3; if (grad>5) grad = 5; } else { - if (diff>-500) grad = 3; # lite yellow - else { - grad = 2 + int(diff/1000); - if (grad<0) grad = 0; - } + if (me.hialtmode == 0) { + if (diff>=lowaltft) grad = 3; # lite yellow + else { + 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 { - var diff = elev - altitudeft; - if (diff>=-2000) grad = 7; #sea + grad = 11; #water } append(elevft,grad); # 0-5 } else { - append(elevft,6); # magenta + append(elevft,0); # no data - black (magenta) } } - me.radar_cleared = 0; - for (var r=0; r < len; r+=1) { var imgx = elevft[r]; if (imgx == -1) continue; @@ -122,21 +139,31 @@ var updateTerrain = func { me.update_altitudes(); me.restart_beacon(); } - - #me.last_request = getprop("sim/time/elapsed-sec"); + me.fetching = 0; }; var update_altitudes = func { me.terrain_minalt.setValue(me.min_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 { me.radar_beacon = 0; 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.reference = nil; }; var init = func { @@ -155,9 +182,13 @@ var init = func { me.visible = 0; me.min_altitude = 9999; me.max_altitude = -9999; + me.bands_minalt = 0; + me.bands_maxalt = 0; + me.bands_range = 0; me.basealtitudeft = nil; me.reference = nil; me.onfailure = 0; + me.hialtmode = 0; # high aircraft relative altitude mode var tile = me.tile; @@ -196,14 +227,10 @@ var init = func { me.terrlayer["L" ~ c] = grplx; 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{ - me.onfailure = getprop("/ECAM/warnings/timer/nav-gpws-terr-fault"); - }); + #setlistener("/ECAM/warnings/timer/nav-gpws-terr-fault", func{ # TODO need further investigations + # me.onfailure = getprop("/ECAM/warnings/timer/nav-gpws-terr-fault"); + #}); }; @@ -236,19 +263,20 @@ var draw = func { return; } - if (me.radar_beacon == 0) { # update aircraft reference + if (me.reference == nil) { # update aircraft reference var ref = geo.aircraft_position(); me.reference = ref; if (ref != nil) { - me.reference.heading = getprop("orientation/heading-magnetic-deg"); - me.reference.altitudeft = ref.alt() * 3.2808399; + me.refheading = getprop("orientation/heading-magnetic-deg"); - 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 = ref.alt() * 3.2808399; - if (basealtft == nil) basealtft = 0; - me.basealtitudeft = basealtft + 400; + me.basealtitudeft = refalt + 400; } #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)) { # 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 - }; diff --git a/Models/Instruments/ND/canvas/res/terrain/tile_cl.png b/Models/Instruments/ND/canvas/res/terrain/tile_cl.png new file mode 100644 index 00000000..1a3a3b66 Binary files /dev/null and b/Models/Instruments/ND/canvas/res/terrain/tile_cl.png differ diff --git a/Models/Instruments/ND/canvas/res/terrain/tile_gh.png b/Models/Instruments/ND/canvas/res/terrain/tile_gh.png new file mode 100644 index 00000000..ef5f7fa1 Binary files /dev/null and b/Models/Instruments/ND/canvas/res/terrain/tile_gh.png differ diff --git a/Models/Instruments/ND/canvas/res/terrain/tile_02.png b/Models/Instruments/ND/canvas/res/terrain/tile_gs.png similarity index 100% rename from Models/Instruments/ND/canvas/res/terrain/tile_02.png rename to Models/Instruments/ND/canvas/res/terrain/tile_gs.png diff --git a/Models/Instruments/ND/canvas/res/terrain/tile_01.png b/Models/Instruments/ND/canvas/res/terrain/tile_lg.png similarity index 100% rename from Models/Instruments/ND/canvas/res/terrain/tile_01.png rename to Models/Instruments/ND/canvas/res/terrain/tile_lg.png diff --git a/Models/Instruments/ND/canvas/res/terrain/tile_09.png b/Models/Instruments/ND/canvas/res/terrain/tile_lm.png similarity index 100% rename from Models/Instruments/ND/canvas/res/terrain/tile_09.png rename to Models/Instruments/ND/canvas/res/terrain/tile_lm.png diff --git a/Models/Instruments/ND/canvas/res/terrain/tile_rh.png b/Models/Instruments/ND/canvas/res/terrain/tile_rh.png new file mode 100644 index 00000000..38ed79d6 Binary files /dev/null and b/Models/Instruments/ND/canvas/res/terrain/tile_rh.png differ diff --git a/Models/Instruments/ND/canvas/res/terrain/tile_05.png b/Models/Instruments/ND/canvas/res/terrain/tile_rl.png similarity index 100% rename from Models/Instruments/ND/canvas/res/terrain/tile_05.png rename to Models/Instruments/ND/canvas/res/terrain/tile_rl.png diff --git a/Models/Instruments/ND/canvas/res/terrain/tile_06.png b/Models/Instruments/ND/canvas/res/terrain/tile_rs.png similarity index 100% rename from Models/Instruments/ND/canvas/res/terrain/tile_06.png rename to Models/Instruments/ND/canvas/res/terrain/tile_rs.png diff --git a/Models/Instruments/ND/canvas/res/terrain/tile_s1.png b/Models/Instruments/ND/canvas/res/terrain/tile_s1.png deleted file mode 100644 index ae16caf3..00000000 Binary files a/Models/Instruments/ND/canvas/res/terrain/tile_s1.png and /dev/null differ diff --git a/Models/Instruments/ND/canvas/res/terrain/tile_yh.png b/Models/Instruments/ND/canvas/res/terrain/tile_yh.png new file mode 100644 index 00000000..ef1d8073 Binary files /dev/null and b/Models/Instruments/ND/canvas/res/terrain/tile_yh.png differ diff --git a/Models/Instruments/ND/canvas/res/terrain/tile_03.png b/Models/Instruments/ND/canvas/res/terrain/tile_yl.png similarity index 100% rename from Models/Instruments/ND/canvas/res/terrain/tile_03.png rename to Models/Instruments/ND/canvas/res/terrain/tile_yl.png diff --git a/Models/Instruments/ND/canvas/res/terrain/tile_04.png b/Models/Instruments/ND/canvas/res/terrain/tile_ys.png similarity index 100% rename from Models/Instruments/ND/canvas/res/terrain/tile_04.png rename to Models/Instruments/ND/canvas/res/terrain/tile_ys.png diff --git a/Models/Instruments/ND/canvas/style.nas b/Models/Instruments/ND/canvas/style.nas index fc95edca..805010a1 100644 --- a/Models/Instruments/ND/canvas/style.nas +++ b/Models/Instruments/ND/canvas/style.nas @@ -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)); if (visible) { layer.update(); + } else { + layer.display_changed = 1; } layer.group.setVisible(visible); }, # end of layer update predicate