Up |
METAR is a format for reporting weather information. It is highly standardized through International Civil Aviation Organization (ICAO). It usually comes from airports (civils or militaries, smalls or bigs) or permanent weather observation stations from around the world.
No dependencies is used in this API.
typeof Weather = ObjScienceWeatherMetar;; // scol METAR object
/* Build a string to the current weather */
fun buildWeather (l)=
if l == nil then
""
else
strcat (sprintf "%s %d" hd l) buildWeather tl l;;
fun main ()=
_showconsole;
/* Create a new Scol METAR object and test if it is created or not */
set Weather = _scienceWeatherMetarNew _channel;
if Weather == nil then // no created
(
_fooS "Unable to create the Scol object !";
1
)
else // created
// get the METAR from the NOAA server to the Marseille (LFML) airport (France)
let _scienceWeatherMetarDatasSetFromUrl Weather "LFML" FROM_NOAA -> w in
if w == nil then // an error occurs during the connection
(
_fooS "Unable to get the datas from internet !";
2
)
else
// Differents weather parameters are displayed in the console
let _scienceWeatherMetarTemperature Weather -> [curTemperature curDewpoint] in
let _scienceWeatherMetarWeather Weather -> [weathers nebulosity] in
(
_fooS "In direct live from Marseille, France !";
_fooS sprintf "The %dth, %d:%d" _scienceWeatherMetarDate Weather;
_fooS sprintf "The current weather is %s and" [buildWeather weathers];
_fooS sprintf "the temperature is %d °C and the humidity is %d %."[curTemperature _scienceWeatherMetarHumidity Weather];
_fooS sprintf "With this temperature, the windchill is %f." [_scienceWeatherMetarWindchill Weather];
_fooS sprintf "With the nebulosity at %s at low level, %s at medium level and %s at high level," nebulosity;
_fooS sprintf "the visibility is %d meters." [_scienceWeatherMetarVisibility Weather];
0
);;
The console can display something like that :
In direct live from Marseille, France !
The 19th, at 18:30
The current weather is NICE and
the temperature is 8 °C and the humidity is 61 %.
With this temperature, the windchill is 3.3.
With the nebulosity at CLEAR at low level, CLEAR at medium level and CLEAR at high level,
the visibility is 9999 meters.
The NOAA (National Oceanic and Atmospheric Administration, an US department)
provides METARs on its ftp server :
ftp://tgftp.nws.noaa.gov/data/observations/metar/stations/ but you can use an other source. In this last case, don't use the flag FROM_NOAA.
To search an ICAO code (airports, stations, ...) you could go to http://weather.rap.ucar.edu/surface/stations.txt or use your favorite search web engine.