Up

_scienceWeatherMetarDatasSetFromUrl

Download a METAR from internet. This function is asynchronous.

Prototype :

fun [ObjScienceWeatherMetar S I fun [ObjScienceWeatherMetar u0 S I] u1 u0] ObjScienceWeatherMetar

Return : ObjScienceWeatherMetar the same object or nil if given arguments are bads.

See also :

_scienceWeatherMetarUrlSet

_scienceWeatherMetarDatasSet

Example :

Download a METAR from NOAA server to Marseille (France) and display in the console the sea level atmospheric presure (if the downlad is ok).

typeof Weather = ObjScienceWeatherMetar;;

fun cbMetarReceived (obj, user_parameter, metar, state)=
	_fooS metar;
	_fooId state;
	if state == 0 then
	(
		_fooS "Datas received !";
		// metar is set to our Weather object
		_scienceWeatherMetarDatasSet Weather metar;
		// Tthe presure is displayed in the console
		_fooId _scienceWeatherMetarPressure Weather;
		0
	)
	else
	(
		_fooS " an error occurs. Code number : " itoa state;
		1
	);;
	
fun main (icao_code)=	// icao_code = "LFML" by example (Marseille, France) 
	_showconsole;
	
	set Weather = _scienceWeatherMetarNew _channel;
	if Weather == nil then
	(
		_fooS "Unable to create the Scol object !";
		1
	)
	else
		// Asynchronous function
		let _scienceWeatherMetarDatasSetFromUrl Weather icao_code FROM_NOAA @cbMetarReceived 0 -> w in
		if w == nil then
		(
			_fooS "Given argument is bad !";
			2
		)
		else
		(
			_fooS "Downloading, please wait ... !";
			0
		);;

Note :

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 search in http://weather.rap.ucar.edu/surface/stations.txt or use your favorite search web engine.