Updates to allow weather system and atis to interact better.
This commit is contained in:
parent
982bdf8930
commit
4a40bb1151
2 changed files with 21 additions and 9 deletions
|
@ -39,7 +39,8 @@ SG_USING_STD(cout);
|
||||||
#include <simgear/misc/sg_path.hxx>
|
#include <simgear/misc/sg_path.hxx>
|
||||||
|
|
||||||
//#ifndef FG_OLD_WEATHER
|
//#ifndef FG_OLD_WEATHER
|
||||||
//#include <WeatherCM/FGLocalWeatherDatabase.h>
|
//sorry, that works only with the new weather system
|
||||||
|
#include <WeatherCM/FGLocalWeatherDatabase.h>
|
||||||
//#else
|
//#else
|
||||||
//# include <Weather/weather.hxx>
|
//# include <Weather/weather.hxx>
|
||||||
//#endif
|
//#endif
|
||||||
|
@ -97,13 +98,14 @@ string FGATIS::get_transmission() {
|
||||||
|
|
||||||
string transmission = "";
|
string transmission = "";
|
||||||
double visibility;
|
double visibility;
|
||||||
double temperature;
|
|
||||||
char buf[10];
|
char buf[10];
|
||||||
int phonetic_id;
|
int phonetic_id;
|
||||||
string phonetic_id_string;
|
string phonetic_id_string;
|
||||||
string time_str = fgGetString("sim/time/gmt-string");
|
string time_str = fgGetString("sim/time/gmt-string");
|
||||||
int hours;
|
int hours;
|
||||||
int minutes;
|
// int minutes;
|
||||||
|
sgVec3 position = { lat, lon, elev };
|
||||||
|
FGPhysicalProperty stationweather = WeatherDatabase->get(position);
|
||||||
|
|
||||||
// Only update every so-many loops - FIXME - possibly register this with the event scheduler
|
// Only update every so-many loops - FIXME - possibly register this with the event scheduler
|
||||||
// Ack this doesn't work since the static counter is shared between all instances of FGATIS
|
// Ack this doesn't work since the static counter is shared between all instances of FGATIS
|
||||||
|
@ -137,13 +139,13 @@ string FGATIS::get_transmission() {
|
||||||
// Get the temperature
|
// Get the temperature
|
||||||
// (Hardwire it for now since the global property returns the temperature at the current altitude
|
// (Hardwire it for now since the global property returns the temperature at the current altitude
|
||||||
//temperature = fgGetDouble("/environment/weather/temperature-K");
|
//temperature = fgGetDouble("/environment/weather/temperature-K");
|
||||||
temperature = 15 + 273.15;
|
sprintf(buf, "%i", int(stationweather.Temperature - 273.15));
|
||||||
sprintf(buf, "%i", int(temperature - 273.15));
|
|
||||||
transmission += " Temperature ";
|
transmission += " Temperature ";
|
||||||
transmission += buf;
|
transmission += buf;
|
||||||
transmission += " degrees Celcius";
|
transmission += " degrees Celcius";
|
||||||
|
|
||||||
// Get the pressure / altimeter
|
// Get the pressure / altimeter
|
||||||
|
// pressure is: stationweather.AirPressure in Pascal
|
||||||
|
|
||||||
// Get the visibility
|
// Get the visibility
|
||||||
visibility = fgGetDouble("/environment/visibility-m");
|
visibility = fgGetDouble("/environment/visibility-m");
|
||||||
|
@ -170,16 +172,24 @@ string FGATIS::get_transmission() {
|
||||||
FGRunways runways( path.c_str() );
|
FGRunways runways( path.c_str() );
|
||||||
|
|
||||||
//Set the heading to into the wind
|
//Set the heading to into the wind
|
||||||
double hdg = fgGetDouble("/environment/wind-from-heading-deg");
|
double wind_x = stationweather.Wind[0];
|
||||||
double speed = fgGetDouble("/environment/wind-speed-knots");
|
double wind_y = stationweather.Wind[1];
|
||||||
|
|
||||||
//cout << "in atis.cxx, hdg = " << hdg << " speed = " << speed << endl;
|
double speed = sqrt( wind_x*wind_x + wind_y*wind_y ) * SG_METER_TO_NM / (60.0*60.0);
|
||||||
|
double hdg;
|
||||||
|
|
||||||
//If no wind use 270degrees
|
//If no wind use 270degrees
|
||||||
if(speed == 0) {
|
if(speed == 0) {
|
||||||
hdg = 270;
|
hdg = 270;
|
||||||
transmission += " Winds light and variable";
|
transmission += " Winds light and variable";
|
||||||
} else {
|
} else {
|
||||||
|
// //normalize the wind to get the direction
|
||||||
|
//wind_x /= speed; wind_y /= speed;
|
||||||
|
|
||||||
|
hdg = - atan2 ( wind_x, wind_y ) * SG_RADIANS_TO_DEGREES ;
|
||||||
|
if (hdg < 0.0)
|
||||||
|
hdg += 360.0;
|
||||||
|
|
||||||
//add a description of the wind to the transmission
|
//add a description of the wind to the transmission
|
||||||
char buf2[72];
|
char buf2[72];
|
||||||
sprintf(buf2, "%s %i %s %i %s", " Winds ", int(speed), " knots from ", int(hdg), " degrees");
|
sprintf(buf2, "%s %i %s %i %s", " Winds ", int(speed), " knots from ", int(hdg), " degrees");
|
||||||
|
|
|
@ -60,12 +60,14 @@ HISTORY
|
||||||
|
|
||||||
#include <plib/sg.h>
|
#include <plib/sg.h>
|
||||||
|
|
||||||
|
#include <simgear/misc/props.hxx>
|
||||||
|
#include <simgear/constants.h>
|
||||||
|
|
||||||
#include "sphrintp.h"
|
#include "sphrintp.h"
|
||||||
|
|
||||||
#include "FGPhysicalProperties.h"
|
#include "FGPhysicalProperties.h"
|
||||||
#include "FGPhysicalProperty.h"
|
#include "FGPhysicalProperty.h"
|
||||||
|
|
||||||
|
|
||||||
#include "FGWeatherFeature.h"
|
#include "FGWeatherFeature.h"
|
||||||
#include "FGWeatherDefs.h"
|
#include "FGWeatherDefs.h"
|
||||||
#include "FGThunderstorm.h"
|
#include "FGThunderstorm.h"
|
||||||
|
|
Loading…
Add table
Reference in a new issue