TERR - more consistent green areas display
This commit is contained in:
parent
008087d516
commit
ada64f22b7
1 changed files with 61 additions and 48 deletions
|
@ -96,6 +96,9 @@ var updateTerrain = func {
|
||||||
|
|
||||||
me.radar_cleared = 0;
|
me.radar_cleared = 0;
|
||||||
|
|
||||||
|
var altmin = 9999;
|
||||||
|
var altmax = -9999;
|
||||||
|
|
||||||
for (var row = 0; row < len; row += 1) {
|
for (var row = 0; row < len; row += 1) {
|
||||||
|
|
||||||
if (trn[row] == nil) {
|
if (trn[row] == nil) {
|
||||||
|
@ -111,17 +114,17 @@ 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 (elev>me.max_altitude) me.max_altitude = elev;
|
if (elev>altmax) altmax = elev;
|
||||||
if (me.is_terrain) {
|
if (me.is_terrain) {
|
||||||
if (elev<me.min_altitude) me.min_altitude = elev;
|
if (elev<altmin) altmin = elev;
|
||||||
if (elev < basealtft) 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;
|
||||||
if (alert_level > 0 and a < 6 and grad > 3) {
|
if (alert_level > 0 and a <= 6) {
|
||||||
if (alert_level == 1 and (grad == 3 or grad == 4)) grad = 12; # solid yellow
|
if (alert_level == 1 and grad != 5) grad = 12; # solid yellow
|
||||||
else if (alert_level == 2 and grad == 5) grad = 13; # solid red
|
else if (alert_level == 2 and grad == 5) grad = 13; # solid red
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -135,9 +138,13 @@ var updateTerrain = func {
|
||||||
if (diff>=lowaltft) grad = 3; # lite yellow
|
if (diff>=lowaltft) grad = 3; # lite yellow
|
||||||
else {
|
else {
|
||||||
if (me.bands_range > 0 and elev > me.bands_minalt) {
|
if (me.bands_range > 0 and elev > me.bands_minalt) {
|
||||||
grad = 9 - int((me.bands_maxalt - elev) / me.bands_range);
|
if (elev >= me.green_altitude) grad = 9; # solid green
|
||||||
if (grad>9) grad = 9; # solid green
|
else {
|
||||||
else if (grad<6) grad = 6; #light green
|
grad = 8 - int((me.bands_maxalt - elev) / me.bands_range); # 9 -
|
||||||
|
#if (grad>9) grad = 9; # solid green
|
||||||
|
if (grad>8) grad = 8; # high green
|
||||||
|
else if (grad<6) grad = 6; #light green
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -153,8 +160,6 @@ var updateTerrain = func {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (me.min_altitude > me.max_altitude) me.min_altitude = me.max_altitude; # occurs on sea areas
|
|
||||||
|
|
||||||
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;
|
||||||
|
@ -162,6 +167,20 @@ var updateTerrain = func {
|
||||||
else trn[r].setFile(me.imgpath ~ me.tile_list[imgx]).show();
|
else trn[r].setFile(me.imgpath ~ me.tile_list[imgx]).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (altmax != -9999) {
|
||||||
|
|
||||||
|
if (altmin > altmax) altmin = altmax; # occurs on sea areas
|
||||||
|
|
||||||
|
if (me.max_altitude == -9999) {
|
||||||
|
me.min_altitude = altmin;
|
||||||
|
me.max_altitude = altmax;
|
||||||
|
} else {
|
||||||
|
if (altmin<me.min_altitude) me.min_altitude = altmin;
|
||||||
|
if (altmax>me.max_altitude) me.max_altitude = altmax;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
me.radar_beacon += 1;
|
me.radar_beacon += 1;
|
||||||
if (me.radar_beacon >= (me.tileradiusw*2)) {
|
if (me.radar_beacon >= (me.tileradiusw*2)) {
|
||||||
me.restart_beacon();
|
me.restart_beacon();
|
||||||
|
@ -172,48 +191,49 @@ var updateTerrain = func {
|
||||||
|
|
||||||
var update_altitudes = func {
|
var update_altitudes = func {
|
||||||
|
|
||||||
me.terrain_minalt.setValue(me.min_altitude);
|
var maxalt = int(me.max_altitude);
|
||||||
me.terrain_maxalt.setValue(me.max_altitude);
|
me.terrain_minalt.setValue(int(me.min_altitude));
|
||||||
|
me.terrain_maxalt.setValue(maxalt);
|
||||||
|
|
||||||
var altdif = me.max_altitude - me.refaltitudeft;
|
if (me.avg_maxalt == -9999) {
|
||||||
|
me.avg_minalt = int(me.min_altitude);
|
||||||
|
me.avg_maxalt = maxalt;
|
||||||
|
} else {
|
||||||
|
me.avg_minalt = math.avg(me.avg_minalt,me.min_altitude);
|
||||||
|
me.avg_maxalt = math.avg(me.avg_maxalt,maxalt);
|
||||||
|
}
|
||||||
|
|
||||||
|
var altdif = maxalt - me.refaltitudeft;
|
||||||
if (altdif <= 0) {
|
if (altdif <= 0) {
|
||||||
if (altdif >= me.reflowaltft) me.terrain_maxcol.setValue(1);
|
if (altdif >= me.reflowaltft) me.terrain_maxcol.setValue(1);
|
||||||
else me.terrain_maxcol.setValue(0);
|
else me.terrain_maxcol.setValue(0);
|
||||||
} else {
|
} else {
|
||||||
if (altdif>2000) me.terrain_maxcol.setValue(2);
|
if (altdif>=2000) me.terrain_maxcol.setValue(2);
|
||||||
else me.terrain_maxcol.setValue(1);
|
else me.terrain_maxcol.setValue(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (me.avg_maxalt == -9999) {
|
me.avg_diffalt = me.avg_maxalt - me.avg_minalt;
|
||||||
me.avg_minalt = me.min_altitude;
|
|
||||||
me.avg_maxalt = me.max_altitude;
|
|
||||||
} else {
|
|
||||||
#if (me.min_altitude < me.avg_minalt) me.avg_minalt = me.min_altitude;else
|
|
||||||
me.avg_minalt = math.round((me.avg_minalt * 2 + me.min_altitude) / 3);
|
|
||||||
#if (me.max_altitude > me.avg_maxalt) me.avg_maxalt = me.max_altitude;else
|
|
||||||
me.avg_maxalt = math.round((me.avg_maxalt * 2 + me.max_altitude) / 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
me.avg_peakalt = me.avg_maxalt - me.avg_minalt;
|
if (me.onground == 0 and (maxalt + 200) < me.refaltitudeft) { # 200 ft tollerance
|
||||||
|
|
||||||
if (me.onground == 0 and (me.max_altitude + 250) < me.refaltitudeft) { # 250 ft tollerance
|
|
||||||
me.hialtmode = 1;
|
me.hialtmode = 1;
|
||||||
var mxrange = math.max(2400,int(me.avg_peakalt*0.25));
|
var mxrange = math.max(1600,int((me.avg_maxalt - me.basealtitudeft) * 0.3));
|
||||||
var range = math.min(mxrange,(me.avg_maxalt - me.avg_minalt)) - 250;
|
var range = math.min(mxrange,me.avg_diffalt);
|
||||||
if (range < 360) { # min elev number
|
if (range < 160) { # min elev number
|
||||||
me.bands_range = 0;
|
me.bands_range = 0;
|
||||||
} else {
|
} else {
|
||||||
me.bands_range = int(range / 4);
|
|
||||||
me.bands_maxalt = me.avg_maxalt;
|
me.bands_maxalt = me.avg_maxalt;
|
||||||
me.bands_minalt = math.max( me.avg_maxalt - range, me.avg_minalt + 400 );
|
me.bands_minalt = math.max( me.avg_maxalt - range, me.avg_minalt + me.basealtitudeft );
|
||||||
|
me.bands_range = int( (me.bands_maxalt - me.bands_minalt) / 4);
|
||||||
}
|
}
|
||||||
|
me.green_altitude = math.max(maxalt - 1200, me.avg_maxalt - me.bands_range);
|
||||||
} else {
|
} else {
|
||||||
me.hialtmode = 0;
|
me.hialtmode = 0;
|
||||||
#me.avg_minalt = 9999;
|
#me.avg_minalt = 9999;
|
||||||
}
|
}
|
||||||
|
|
||||||
me.min_altitude = 9999;
|
me.min_altitude = 9999;
|
||||||
me.max_altitude = -9999;
|
me.max_altitude = -9999;
|
||||||
|
me.avg_maxalt = -9999;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,9 +259,10 @@ var init = func {
|
||||||
me.request_clear = 0;
|
me.request_clear = 0;
|
||||||
me.min_altitude = 9999;
|
me.min_altitude = 9999;
|
||||||
me.max_altitude = -9999;
|
me.max_altitude = -9999;
|
||||||
|
me.green_altitude = 0; # max altitude for solid green (peak color)
|
||||||
me.avg_minalt = 9999;
|
me.avg_minalt = 9999;
|
||||||
me.avg_maxalt = -9999;
|
me.avg_maxalt = -9999;
|
||||||
me.avg_peakalt = nil;
|
me.avg_diffalt = nil;
|
||||||
me.maxalt_col = 0; # 0 = grn, 1 = yel, 2 = red
|
me.maxalt_col = 0; # 0 = grn, 1 = yel, 2 = red
|
||||||
me.bands_minalt = 0;
|
me.bands_minalt = 0;
|
||||||
me.bands_maxalt = 0;
|
me.bands_maxalt = 0;
|
||||||
|
@ -335,9 +356,10 @@ var draw = func {
|
||||||
if (me.layer.display_hidden == 1) {
|
if (me.layer.display_hidden == 1) {
|
||||||
me.layer.display_hidden = 0;
|
me.layer.display_hidden = 0;
|
||||||
me.clear();
|
me.clear();
|
||||||
|
me.terrain_maxalt.setValue(-9999);
|
||||||
me.min_altitude = 9999;
|
me.min_altitude = 9999;
|
||||||
me.max_altitude = -9999;
|
me.max_altitude = -9999;
|
||||||
me.terrain_maxalt.setValue(-9999);
|
me.avg_maxalt = -9999;
|
||||||
me.reference = nil;
|
me.reference = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,9 +377,9 @@ var draw = func {
|
||||||
me.reflowaltft = (pts.Gear.position[1].getValue()) ? -250 : -500;
|
me.reflowaltft = (pts.Gear.position[1].getValue()) ? -250 : -500;
|
||||||
me.onground = pts.Gear.wow[0].getValue();
|
me.onground = pts.Gear.wow[0].getValue();
|
||||||
|
|
||||||
if (me.min_altitude != 9999) me.update_altitudes();
|
if (me.max_altitude != -9999) me.update_altitudes();
|
||||||
|
|
||||||
var flatalt = (me.avg_peakalt == nil or me.avg_peakalt>499) ? 400 : 140;
|
var flatalt = (me.avg_diffalt == nil or me.avg_diffalt>499) ? 400 : 180;
|
||||||
|
|
||||||
var vspeed30s = int(getprop("velocities/vertical-speed-fps") * 30);
|
var vspeed30s = int(getprop("velocities/vertical-speed-fps") * 30);
|
||||||
if (vspeed30s<-500) me.refaltitudeft = math.max(me.avg_minalt , me.refaltitudeft + vspeed30s);
|
if (vspeed30s<-500) me.refaltitudeft = math.max(me.avg_minalt , me.refaltitudeft + vspeed30s);
|
||||||
|
@ -404,19 +426,10 @@ var draw = func {
|
||||||
print("set REFALT [blwbase]: "~me.basealtitudeft);
|
print("set REFALT [blwbase]: "~me.basealtitudeft);
|
||||||
}
|
}
|
||||||
} else if (fmgc.FMGCInternal.phase >= 2) {
|
} else if (fmgc.FMGCInternal.phase >= 2) {
|
||||||
me.basealtitudeft = math.avg(me.basealtitudeft,flatalt + me.groundaltft,int(flatalt + me.avg_minalt));
|
if (me.avg_minalt != 9999) me.basealtitudeft = int(math.avg(me.basealtitudeft,flatalt + me.avg_minalt));
|
||||||
#if (me.basealtitudeft > me.avg_maxalt) {
|
|
||||||
# if (me.avg_maxalt < 1000) me.basealtitudeft = 0; # 1000ft min elev number
|
|
||||||
# else me.basealtitudeft = int(400 + me.avg_minalt);
|
|
||||||
# print("set REFALT [blwmin]: "~me.basealtitudeft);
|
|
||||||
#}
|
|
||||||
#else if (me.basealtitudeft == 0 and me.avg_maxalt >= 1000) { # 1000ft min elev number
|
|
||||||
# me.basealtitudeft = int(400 + me.avg_minalt);
|
|
||||||
# print("set REFALT [abvmin]: "~me.basealtitudeft);
|
|
||||||
#}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue