display water and some optimization on reference calculations
This commit is contained in:
parent
91fb47704e
commit
77aa7b2429
7 changed files with 72 additions and 57 deletions
|
@ -1457,7 +1457,7 @@
|
||||||
</greater-than-equals>
|
</greater-than-equals>
|
||||||
</condition>
|
</condition>
|
||||||
<command>property-toggle</command>
|
<command>property-toggle</command>
|
||||||
<property>instrumentation/efis[0]/inputs/terr</property>
|
<property>instrumentation/efis/inputs/terr</property>
|
||||||
</binding>
|
</binding>
|
||||||
</action>
|
</action>
|
||||||
</animation>
|
</animation>
|
||||||
|
|
|
@ -64,7 +64,6 @@ var myCockpit_switches = {
|
||||||
"toggle_xtrk_error": {path: "/nd/xtrk-error", value: 0, type: "BOOL"},
|
"toggle_xtrk_error": {path: "/nd/xtrk-error", value: 0, type: "BOOL"},
|
||||||
"toggle_trk_line": {path: "/nd/trk-line", value: 0, type: "BOOL"},
|
"toggle_trk_line": {path: "/nd/trk-line", value: 0, type: "BOOL"},
|
||||||
"ADIRS3": {path: "/nd/ir-3", value: 0, type: "BOOL"},
|
"ADIRS3": {path: "/nd/ir-3", value: 0, type: "BOOL"},
|
||||||
#"toggle_terrain": {path: "/nd/terrain-on-nd", value: 0, type: "BOOL"},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var canvas_nd_base = {
|
var canvas_nd_base = {
|
||||||
|
|
|
@ -375,9 +375,9 @@ canvas.NavDisplay.update = func() # FIXME: This stuff is still too aircraft spec
|
||||||
wxr_live_enabled = 0;
|
wxr_live_enabled = 0;
|
||||||
me.set_switch('toggle_weather_live', wxr_live_enabled);
|
me.set_switch('toggle_weather_live', wxr_live_enabled);
|
||||||
|
|
||||||
var terr_enabled = getprop("/controls/switches/terr_on_nd_l");
|
#var terr_enabled = getprop("/controls/switches/terr_on_nd_l");
|
||||||
if (terr_enabled == nil) terr_enabled = 0;
|
#if (terr_enabled == nil) terr_enabled = 0;
|
||||||
if (me.get_switch('toggle_terrain') != terr_enabled) me.set_switch('toggle_terrain', terr_enabled);
|
#if (me.get_switch('toggle_terrain') != terr_enabled) me.set_switch('toggle_terrain', terr_enabled);
|
||||||
|
|
||||||
call(me.update_sub, nil, nil, caller(0)[0]); # call this in the same namespace to "steal" its variables
|
call(me.update_sub, nil, nil, caller(0)[0]); # call this in the same namespace to "steal" its variables
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ setlistener("/nasal/canvas/loaded", func() {
|
||||||
#var code = call(compile, [code], var err=[]);
|
#var code = call(compile, [code], var err=[]);
|
||||||
var code = call(func compile(code, file), [code], var err=[]);
|
var code = call(func compile(code, file), [code], var err=[]);
|
||||||
if (size(err)) {
|
if (size(err)) {
|
||||||
print("handling error");
|
#print("handling error");
|
||||||
if (substr(err[0], 0, 12) == "Parse error:") { # hack around Nasal feature
|
if (substr(err[0], 0, 12) == "Parse error:") { # hack around Nasal feature
|
||||||
var e = split(" at line ", err[0]);
|
var e = split(" at line ", err[0]);
|
||||||
if (size(e) == 2)
|
if (size(e) == 2)
|
||||||
|
|
|
@ -7,22 +7,27 @@ DotSym.makeinstance( name, __self__ );
|
||||||
|
|
||||||
var element_type = "group";
|
var element_type = "group";
|
||||||
|
|
||||||
var terrain_visible = props.globals.initNode("/custom/terrain/visible", 0,"INT");
|
|
||||||
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"];
|
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 is_terrain = 0;
|
||||||
|
|
||||||
var get_elevation = func (lat, lon) {
|
var get_elevation = func (lat, lon) {
|
||||||
var info = geodinfo(lat, lon);
|
var info = geodinfo(lat, lon);
|
||||||
var elevation = 0;
|
var elevation = 0;
|
||||||
if (info != nil) { elevation = int(info[0] * 3.2808399); }
|
if (info != nil) {
|
||||||
|
elevation = int(info[0] * 3.2808399);
|
||||||
|
me.is_terrain = (info[1] == nil) ? 1 : info[1].solid;
|
||||||
|
}
|
||||||
else { elevation = nil; }
|
else { elevation = nil; }
|
||||||
return elevation;
|
return elevation;
|
||||||
}
|
}
|
||||||
|
|
||||||
var updateTerrain = func(r_scaled){
|
var updateTerrain = func {
|
||||||
|
|
||||||
|
if (me.reference == nil) return;
|
||||||
|
|
||||||
if(me.fetching) return;
|
if(me.fetching) return;
|
||||||
|
|
||||||
|
@ -36,18 +41,11 @@ var updateTerrain = func(r_scaled){
|
||||||
var RAD2DEG = 57.2957795;
|
var RAD2DEG = 57.2957795;
|
||||||
var DEG2RAD = 0.016774532925;
|
var DEG2RAD = 0.016774532925;
|
||||||
|
|
||||||
var pos = geo.aircraft_position();
|
var pos_lat = me.reference.lat();
|
||||||
var pos_lat = pos.lat();
|
var pos_lon = me.reference.lon();
|
||||||
var pos_lon = pos.lon();
|
|
||||||
|
|
||||||
var heading = getprop("orientation/heading-magnetic-deg");
|
var heading = me.reference.heading;
|
||||||
var altitudeft = pos.alt() * 3.2808399;
|
var altitudeft = me.reference.altitudeft;
|
||||||
|
|
||||||
if (me.basealtitudeft == nil) {
|
|
||||||
var basealtft = me.get_elevation(pos_lat,pos_lon);
|
|
||||||
if (basealtft == nil) basealtft = 0;
|
|
||||||
me.basealtitudeft = basealtft + 400;
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
||||||
|
@ -82,21 +80,26 @@ var updateTerrain = func(r_scaled){
|
||||||
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.min_altitude) me.min_altitude = elev;
|
if (me.is_terrain) {
|
||||||
else if (elev>me.max_altitude) me.max_altitude = elev;
|
if (elev<me.min_altitude) me.min_altitude = elev;
|
||||||
if (elev < me.basealtitudeft) grad = 0; # < 400 (at airport) use blank - trivial
|
else if (elev>me.max_altitude) me.max_altitude = elev;
|
||||||
else {
|
if (elev < me.basealtitudeft) grad = 0; # < 400 near runway use blank
|
||||||
var diff = elev - altitudeft;
|
else {
|
||||||
if (diff>=0) {
|
var diff = elev - altitudeft;
|
||||||
grad = int(diff/1000) + 3;
|
if (diff>=0) {
|
||||||
if (grad>5) grad = 5;
|
grad = int(diff/1000) + 3;
|
||||||
} else {
|
if (grad>5) grad = 5;
|
||||||
if (diff>-500) grad = 3; # lite yellow
|
} else {
|
||||||
else {
|
if (diff>-500) 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 {
|
||||||
|
var diff = elev - altitudeft;
|
||||||
|
if (diff>=-2000) grad = 7; #sea
|
||||||
}
|
}
|
||||||
append(elevft,grad); # 0-5
|
append(elevft,grad); # 0-5
|
||||||
} else {
|
} else {
|
||||||
|
@ -149,10 +152,11 @@ var init = func {
|
||||||
me.radar_cycle = 0;
|
me.radar_cycle = 0;
|
||||||
me.radar_cleared = 1;
|
me.radar_cleared = 1;
|
||||||
me.request_clear = 0;
|
me.request_clear = 0;
|
||||||
me.basealtitudeft = nil;
|
|
||||||
me.visible = 0;
|
me.visible = 0;
|
||||||
me.min_altitude = 9999;
|
me.min_altitude = 9999;
|
||||||
me.max_altitude = -9999;
|
me.max_altitude = -9999;
|
||||||
|
me.basealtitudeft = nil;
|
||||||
|
me.reference = nil;
|
||||||
|
|
||||||
var tile = me.tile;
|
var tile = me.tile;
|
||||||
|
|
||||||
|
@ -192,14 +196,10 @@ var init = func {
|
||||||
me.terrlayer["R" ~ c] = grprx;
|
me.terrlayer["R" ~ c] = grprx;
|
||||||
}
|
}
|
||||||
|
|
||||||
#me.update_interval = 300;
|
setlistener("/controls/switches/terr_on_nd_l", func{
|
||||||
#me.last_request = 0;
|
me.request_clear = 1;
|
||||||
|
});
|
||||||
|
|
||||||
#var r_scaled = (me.fetchRad*me.viewport_radius)/me.range;
|
|
||||||
#me.fetchWXRMap(r_scaled);
|
|
||||||
|
|
||||||
#me.timeStamp = nil;
|
|
||||||
#http.load("https://api.rainviewer.com/public/maps.json").done(func(r) me.timeStamp = processRequest(r));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var clear = func {
|
var clear = func {
|
||||||
|
@ -225,22 +225,41 @@ var draw = func {
|
||||||
|
|
||||||
if(me.fetching) return;
|
if(me.fetching) return;
|
||||||
|
|
||||||
|
if (me.radar_beacon == 0) { # 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;
|
||||||
|
|
||||||
|
if (me.basealtitudeft == nil) {
|
||||||
|
var basealtft = me.get_elevation(ref.lat,ref.lon);
|
||||||
|
if (basealtft == nil) basealtft = 0;
|
||||||
|
me.basealtitudeft = basealtft + 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((fmgc.FMGCInternal.phase <= 1 or fmgc.FMGCInternal.phase >= 5) and (me.basealtitudeft == 0)) {
|
||||||
|
var basealtft = me.get_elevation(ref.lat,ref.lon);
|
||||||
|
if (basealtft == nil) basealtft = 0;
|
||||||
|
me.basealtitudeft = basealtft + 400;
|
||||||
|
# me.reference.basealtitudeft = ft + 400 # <- TODO get departure/arrival runway altitude
|
||||||
|
}
|
||||||
|
else if ((fmgc.FMGCInternal.phase > 1 and fmgc.FMGCInternal.phase < 5) and (me.basealtitudeft != 0)) {
|
||||||
|
me.basealtitudeft = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var range = me.layer.map.getRange(); # Range of Navigation Display
|
var range = me.layer.map.getRange(); # Range of Navigation Display
|
||||||
var update_size = (range != me.range);
|
var update_size = (range != me.range);
|
||||||
me.range = range;
|
me.range = range;
|
||||||
me.fetchRad = me.model.fetchRad; # Radius of radar layer to fetch
|
|
||||||
var r_scaled = (me.fetchRad*me.viewport_radius)/me.range;
|
|
||||||
|
|
||||||
if(update_size){
|
if(update_size){
|
||||||
me.request_clear = 1;
|
me.request_clear = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(me.terrain_visible.getValue() == 0){
|
me.updateTerrain(); # left
|
||||||
me.request_clear = 1;
|
if (math.mod(me.radar_beacon,2)==1) me.updateTerrain(); # right
|
||||||
me.terrain_visible.setValue(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
me.updateTerrain(r_scaled); # left
|
|
||||||
if (math.mod(me.radar_beacon,2)==1) me.updateTerrain(r_scaled); # right
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
BIN
Models/Instruments/ND/canvas/res/terrain/tile_s1.png
Normal file
BIN
Models/Instruments/ND/canvas/res/terrain/tile_s1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
|
@ -12,7 +12,6 @@ var adirs_3 = props.globals.getNode("/instrumentation/efis[0]/nd/ir-3", 1);
|
||||||
|
|
||||||
var vhdg_bug = props.globals.getNode("/it-autoflight/input/hdg",0); # ND compass position deg
|
var vhdg_bug = props.globals.getNode("/it-autoflight/input/hdg",0); # ND compass position deg
|
||||||
|
|
||||||
var terrain_visible = props.globals.getNode("/custom/terrain/visible", 0);
|
|
||||||
var terrain_minalt = props.globals.getNode("/custom/terrain/min-altitude", 0);
|
var terrain_minalt = props.globals.getNode("/custom/terrain/min-altitude", 0);
|
||||||
var terrain_maxalt = props.globals.getNode("/custom/terrain/max-altitude", -9999);
|
var terrain_maxalt = props.globals.getNode("/custom/terrain/max-altitude", -9999);
|
||||||
|
|
||||||
|
@ -96,12 +95,10 @@ canvas.NDStyles["Airbus"] = {
|
||||||
var visible = nd.get_switch("toggle_terrain") and
|
var visible = nd.get_switch("toggle_terrain") and
|
||||||
nd.get_switch("toggle_display_mode") != "PLAN" and (nd.rangeNm() <= 40) and !nd.get_switch("toggle_centered") and
|
nd.get_switch("toggle_display_mode") != "PLAN" and (nd.rangeNm() <= 40) and !nd.get_switch("toggle_centered") and
|
||||||
(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));
|
||||||
layer.group.setVisible(visible);
|
|
||||||
if (visible) {
|
if (visible) {
|
||||||
layer.update();
|
layer.update();
|
||||||
} else {
|
|
||||||
#terrain_visible.setValue(0);
|
|
||||||
}
|
}
|
||||||
|
layer.group.setVisible(visible);
|
||||||
}, # end of layer update predicate
|
}, # end of layer update predicate
|
||||||
options: {
|
options: {
|
||||||
viewport_radius: 670, #512, #706,
|
viewport_radius: 670, #512, #706,
|
||||||
|
|
Loading…
Reference in a new issue