Skip to content

Releases: Banovvv/SimpleWeather

SimpleWeather v2.5.0

15 Apr 09:57
fbe3c2d
Compare
Choose a tag to compare

SimpleWeather v2.5.0

NuGet Badge

SimpleWeather v2.5.0 release

  • Added functionality where you can get the WindDirection data as a string (this can be WindDirectionShort or WindDirectionLong
  • Updated MoonPhase proberty from double to string
  • Added missing parameters in the CurrentWeather class
  • Fixed inaccuracies with PrecipitationProbability parameter

Methods

There are two asynchronous methods which return an Object containing all the weather data for a given city:
Current weather data:

GetCurrentWeather(string city, string units)

Weather forecast data:

GetWeatherForecast(string city, string units)
GetWeatherForecast(double lat, double lon, string units)

Prerequisites

In order for the library to work you need to have an appsettings.json file containing your OpenWeatherMap's API KEY in your project's output directory with the following parameter:

{
  "openWeatherApiKey": "YourKeyGoesHere"
}

Example usage

using SimpleWeather;

var weatherController = new WeatherController();
var currentWeather = await weatherController.GetCurrentWeather("Lovech", "metric");
var weatherForecast = await weatherController.GetWeatherForecast("Lovech");

Console.WriteLine($"The current weather in {currentWeather.City} is {Math.Round(currentWeather.Main.Temperature)}°C degrees with {currentWeather.Weather.Description}.\n");

Console.WriteLine("The weather forecast for the next 7 days is:\n");

foreach (var day in weatherForecast.Daily)
{
    Console.WriteLine($"The weather for: {day.DT.ToString("dd.MM.yyyy")}");
    Console.WriteLine($"Min temperature: {Math.Round(day.Temperature.Min)}°C");
    Console.WriteLine($"Max temperature: {Math.Round(day.Temperature.Max)}°C");
    Console.WriteLine($"Wind speed will be: {day.WindSpeed} m/s");
    Console.WriteLine($"Wind direction will be: {day.WindDirectionLong} ({day.WindDirectionShort})");
    Console.WriteLine($"The weather conditions will be: {day.Weather.Description}");
    Console.WriteLine($"Probability for precipitation: {day.PrecipitationProbability}%");
    Console.WriteLine($"The moon phase will be: {day.MoonPhase}\n");
}

This will produce the following result:

The current weather in Lovech is 17°C degrees with clear sky.

The weather forecast for the next 7 days is:

The weather for: 15.04.2022
Min temperature: 9°C
Max temperature: 22°C
Wind speed will be: 2.2 m/s
Wind direction will be: South-southwest (SSW)
The weather conditions will be: clear sky
Probability for precipitation: 0%
The moon phase will be: Full Moon
.
.
.
The weather for: 21.04.2022
Min temperature: 5°C
Max temperature: 17°C
Wind speed will be: 7.63 m/s
Wind direction will be: West (W)
The weather conditions will be: few clouds
Probability for precipitation: 0%
The moon phase will be: Waning Gibbous

Installation

DISCLAIMER: Plese note that this package is still under development and bugs may be present. If you spot a bug, please open a new Issue

You can install the NuGet library into your project using:

Package Manager:

Install-Package SimpleWeather -Version 2.5.0

.NET CLI:

dotnet add package SimpleWeather --version 2.5.0

License

Copyright © 2022 Ivan Gechev.

This package has MIT license. Refer to the LICENSE for detailed information.

Questions, comments or additions

If you have a feature request or bug report, open a new Issue or send a Pull request.

Support

If you like this project, give it a ⭐ and share it with friends!

What's Changed

Full Changelog: v2.0.0...v2.5.0

SimpleWeather v2.0.0

31 Mar 11:45
bd446a9
Compare
Choose a tag to compare

SimpleWeather v2.0.0

NuGet Badge

SimpleWeather v2.0.0 release

  • Added functionality where you can get the WeatherForecast data
  • Added Sunrise and Sunset times for CurrentWeather
  • Fixed minor time zone issuefor CurrentWeather
  • Minor bug fix where WindGust was throwing an error

Methods

There are two asynchronous methods which return an Object containing all the weather data for a given city:
Current weather data:

GetCurrentWeather(string city, string units)

Weather forecast data:

GetWeatherForecast(string city, string units)
GetWeatherForecast(double lat, double lon, string units)

Prerequisites

In order for the library to work you need to have an appsettings.json file containing your OpenWeatherMap's API KEY in your project's output directory with the following parameter:

{
  "openWeatherApiKey": "YourKeyGoesHere"
}

Example usage

using SimpleWeather;

var weatherController = new WeatherController();
var currentWeather = await weatherController.GetCurrentWeather("Lovech", "metric");
var weatherForecast = await weatherController.GetWeatherForecast(43.1333, 24.7167);

Console.WriteLine($"The current weather in {currentWeather.City} is {currentWeather.Main.Temperature} degrees with {currentWeather.Weather.Description}.");

Console.WriteLine("The weather forecast for Lovech for the next 7 days is:");

foreach (var day in weatherForecast.Daily)
{
    Console.WriteLine($"The weather for: {day.DT.ToString("d")}");
    Console.WriteLine($"Min temperature: {day.Temperature.Min}");
    Console.WriteLine($"Max temperature: {day.Temperature.Max}");
    Console.WriteLine($"The weather conditions will be: {day.Weather.Description}");
    Console.WriteLine($"Probability for precipitation: {day.PrecipitationProbability}%");
}

This will produce the following result:

The current weather in Lovech is 11.43 degrees with overcast clouds.

The weather forecast for the next 7 days is:

The weather for: 02.04.2022
Min temperature: 7.03
Max temperature: 20.52
The weather conditions will be: heavy intensity rain
Probability for precipitation: 100%
.
.
.
The weather for: 07.04.2022
Min temperature: 9.34
Max temperature: 17.91
The weather conditions will be: moderate rain
Probability for precipitation: 95%

Installation

DISCLAIMER: Plese note that this package is still under development and bugs may be present. If you spot a bug, please open a new Issue

You can install the NuGet library into your project using:

Package Manager:

Install-Package SimpleWeather -Version 2.0.0

.NET CLI:

dotnet add package SimpleWeather --version 2.0.0

License

Copyright © 2022 Ivan Gechev.

This package has MIT license. Refer to the LICENSE for detailed information.

Questions, comments or additions

If you have a feature request or bug report, open a new Issue or send a Pull request.

What's Changed

  • Added logic to extract sunset/sunrise time in separate property by @Banovvv in #5
  • Added functionality to get weather forecast by @Banovvv in #7
  • Updated README, added parameter descriptions by @Banovvv in #8
  • Overload added, minor bug fixed for WindGust by @Banovvv in #10

Full Changelog: v1.0.0...v2.0.0

SimpleWeather v1.0.0

29 Mar 12:08
Compare
Choose a tag to compare

SimpleWeather v1.0.0

NuGet Badge

SimpleWeather v1.0.0 release

This is the initial release of the SimpleWeather package. At this point there is only one asynchronous method which returns and Object containing all the data for the current weather in a given city:

GetCurrentWeatherResponse(string city, string units)

Prerequisites

In order for the library to work you need to have a appsettings.json file (containing your OpenWeatherMap's API KEY) in your project's output directory containing the following:

{
  "openWeatherApiKey": "YourKeyGoesHere"
}

Example usage

using SimpleWeather;

var weatherController = new WeatherController();
var currentWeather = await weatherController.GetCurrentWeatherResponse("Lovech", "metric");

Console.WriteLine($"The current temperature in {currentWeather.City} is {currentWeather.Main.Temperature} degrees.");

Installation

DISCLAIMER: Please note that this package is still under development and bugs may be present. If you spot a bug, please open a new Issue

You can install the NuGet library into your project using:

Package Manager:

Install-Package SimpleWeather -Version 1.0.0

.NET CLI:

dotnet add package SimpleWeather --version 1.0.0

License

Copyright © 2022 Ivan Gechev.