From 2e9c693e678fa0ea219e00028eb9922b43e9c83b Mon Sep 17 00:00:00 2001 From: mfranz Date: Sat, 23 Jun 2007 15:28:08 +0000 Subject: [PATCH] use geodinfo() function to retrieve the terrain elevation for a coordinate --- Nasal/geo.nas | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/Nasal/geo.nas b/Nasal/geo.nas index 775f3c46b..5fc4c9ee7 100644 --- a/Nasal/geo.nas +++ b/Nasal/geo.nas @@ -315,16 +315,9 @@ var _put_model = func(path, lat, lon, elev_m = nil, hdg = 0, pitch = 0, roll = 0 } -var terr_tree = nil; -var terr_lon = nil; -var terr_lat = nil; -var terr_elev = nil; - var elevation = func(lat, lon) { - terr_lat.setDoubleValue(lat); - terr_lon.setDoubleValue(lon); - var success = fgcommand("terrain-elevation", terr_tree); - return success ? terr_elev.getValue() : nil; + var d = geodinfo(lat, lon); + return d == nil ? nil : d[0]; } @@ -367,15 +360,6 @@ _setlistener("/sim/signals/nasal-dir-initialized", func { acos = math.acos; mod = math.mod; - terr_tree = props.Node.new(); - terr_lat = terr_tree.getNode("latitude-deg", 1); - terr_lon = terr_tree.getNode("longitude-deg", 1); - terr_elev = terr_tree.getNode("elevation-m", 1); - - terr_lat.setDoubleValue(0.0); - terr_lon.setDoubleValue(0.0); - terr_elev.setDoubleValue(-9999.0); - aircraft_lat = props.globals.getNode("/position/latitude-deg", 1); aircraft_lon = props.globals.getNode("/position/longitude-deg", 1); aircraft_alt = props.globals.getNode("/position/altitude-ft", 1);