Weather information at a specified location can also be obtained directly through API function GetAtmoshere that is exported by as_btstrp.dll This is meant to be used by aircraft Flight Management Computers a way to get "live" (or forecast) weather information at a specified way point at various flying altitudes. By design it only contains information that may be useful for such functionality as winds, pressure and temperature and not for example precipitation or other information. Here's the declaration of the function:
bool GetAtmosphere(double lat, double lon, unsigned time_offset, WxData* data, unsigned data_size );
Parameters:
- lat, lon: The latitude and longitude in degrees of the waypoint
- time_offset: The time offset (in seconds) from current base ACTIVE SKY active time. For example if this has value 240*60 (and ACTIVE SKY is in live real time mode), forecast weather conditions at the specified way point 4 hours from now are requested
- data is an array of WxData structs with a length data_size. The WxData definition is :
1 2 3 4 5 6 7 8
| struct WxData
{
int AltFt; // (In) The requested altitude (MSL in feet)
double Pressure; // (Out) The returned pressure (in hectoPascals)
double Temperature; // (Out) The returned temperature (in Celsius)
double WindDirection; // (Out) The returned wind direction (in degrees)
double WindSpeed; // (Out) The returned wind speed (in knots)
}; |
The allocation of the memory (and memory management) for this array is the responsibility of the caller. The caller sets the AltFt value for each instance of WxData and then once the function returns, the values for temperature, winds and pressure will be populated at the specified fields.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| double lat = 40.520843;
double lon = 22.971601; // The lat/lon of LGTS airport
unsigned time_offset = 0; // We need current data (no forecast)
unsigned data_size = 2; // We need data for 2 altitudes
WxData* data = new WxData[data_size];
data[0].AltFt = 6000;
data[1].AltFt = 34000;
if (GetAtmosphere(lat, lon, time_offset, data, data_size))
{
for (int i = 0;i < data_size;i++)
{
// data[i].AltFt) should be 6000 and 34000
// data[i].Pressure the ambient pressure at 6000 and 34000 ft
// data[i].WindDirection) the wind direction at 6000 and 34000 ft
// data[i].WindSpeed) the wind speed at 6000 and 34000 ft
// data[i].Temperature) the temperature at 6000 and 34000 ft
}
}
else
LogMessage(TEXT("ExternalFailed"));
delete[] data; |
Partager