// Physics for ambient pressure calculation
var p0 = 101325;// sea level standard atmospheric pressure Pa
var L = 0.0065;// temperature lapse rate, = g/cp*for dry air K/m
var T0 = 288.15;// sea level standard temperature 288,15 K
var g = 9.80665;// Earth-surface gravitational acceleration 9,80665 m/s²
var M = 0.0289644;// molar mass of dry air 0,0289644 kg/mol
var R = 8.31447;// universal gas constant 8,31447 J/(mol*K)
var exp = g*M/R/L;
var fact = L/T0;
var press = p0 * Math.pow((1-altitude*fact),exp)/100;
var depth = 0.0;
depth = (press/1000.0 - 1);
if (unitElevMeters){
altStr = "-" + depth.format("%.2f") + "m";
} else {//feet
altStr = "-" + (depth*3.28084).format("%1f") + "ft";
}