weather_forecast

Get weather forecast with the D programming language. It first gets your longitude and latitude using http://ipinfo.io. Then uses them to look up your weather using http://forecast.weather.gov.

Version

2.0.0

License

Boost Software License - Version 1.0

Examples

  1. import std.stdio : stdout, stderr; import weather_forecast : getForecast, WeatherData; getForecast(delegate(WeatherData weather_data, Exception err) { if (err) { stderr.writefln("%s", err); } else { stdout.writefln("latitude: %s", weather_data.latitude); stdout.writefln("longitude: %s", weather_data.longitude); stdout.writefln("city: %s", weather_data.city); stdout.writefln("region: %s", weather_data.region); stdout.writefln("country: %s", weather_data.country); stdout.writefln("postal: %s", weather_data.postal); stdout.writefln("temperature: %s", weather_data.temperature); stdout.writefln("summary: %s", weather_data.summary); } });

  • Declaration

    struct WeatherData;

    Data gathered in WeatherData:

    1. struct WeatherData { string latitude; string longitude; string city; string region; string country; string postal; string temperature; string summary; }

  • Declaration

    void getForecast(void delegate(WeatherData weather_data, Exception err) cb);

    Returns the weather forecast using a callback.

    Parameters

    void delegate(WeatherData weather_data, Exception err) cb

    The callback to fire when weather info has been downloaded. The callback sends the WeatherData data and an Exception if there was any problem.