![]() |
VOOZH | about |
dotnet add package Xcalibur.Weather.Helpers --version 1.0.7
NuGet\Install-Package Xcalibur.Weather.Helpers -Version 1.0.7
<PackageReference Include="Xcalibur.Weather.Helpers" Version="1.0.7" />
<PackageVersion Include="Xcalibur.Weather.Helpers" Version="1.0.7" />Directory.Packages.props
<PackageReference Include="Xcalibur.Weather.Helpers" />Project file
paket add Xcalibur.Weather.Helpers --version 1.0.7
#r "nuget: Xcalibur.Weather.Helpers, 1.0.7"
#:package Xcalibur.Weather.Helpers@1.0.7
#addin nuget:?package=Xcalibur.Weather.Helpers&version=1.0.7Install as a Cake Addin
#tool nuget:?package=Xcalibur.Weather.Helpers&version=1.0.7Install as a Cake Tool
A comprehensive .NET helper library providing utility functions for weather-related operations. Includes conversion helpers for temperature, wind speed, length, and pressure, along with specialized helpers for Open-Meteo, Geocodio, IpGeolocation.io, Atmospore, SunriseSunset.io, OpenStreetMap, and combined weather alert operations (Meteoalarm, NWS, GDACS, Environment Canada, BOM, EMSC, DWD).
Created by: Joshua Arzt | Company: Xcalibur Systems, LLC.
Install-Package Xcalibur.Weather.Helpers
dotnet add package Xcalibur.Weather.Helpers
<PackageReference Include="Xcalibur.Weather.Helpers" Version="1.0.3" />
using Xcalibur.Weather.Helpers;
using Xcalibur.Weather.Models;
// Convert Celsius to Fahrenheit
double celsius = 25.0;
double fahrenheit = celsius.CelsiusToFahrenheit(); // 77.0
// Convert Fahrenheit to Celsius
double temp = 77.0;
double celsiusValue = temp.FahrenheitToCelsius(); // 25.0
// Format temperature with unit
string formatted = celsius.FormatTemperature(TemperatureUnits.Fahrenheit, includeUnit: true);
// Output: "77°F"
using Xcalibur.Weather.Helpers;
using Xcalibur.Weather.Models;
// Convert wind speed from km/h to various units
double windSpeed = 100.0; // km/h
double mph = windSpeed.ConvertWindSpeed(WindSpeedUnits.Mph); // 62.14
double mps = windSpeed.ConvertWindSpeed(WindSpeedUnits.MSec); // 27.78
double knots = windSpeed.ConvertWindSpeed(WindSpeedUnits.Knots); // 53.99
double fps = windSpeed.ConvertWindSpeed(WindSpeedUnits.FtSec); // 91.13
using Xcalibur.Weather.Helpers;
using Xcalibur.Weather.Models;
// Format precipitation in different units
double? precipitation = 25.4; // millimeters
string metric = precipitation.FormatLength(DistanceUnits.Metric, includeUnit: true);
// Output: "25.40 mm"
string imperial = precipitation.FormatLength(DistanceUnits.Imperial, includeUnit: true);
// Output: "1.00 in"
using Xcalibur.Weather.Helpers;
using Xcalibur.Weather.Models;
// Format atmospheric pressure in different units
double? pressure = 1013.25; // hectopascals
string hPa = pressure.FormatPressure(BarometerUnits.HPa, includeUnit: true);
// Output: "1013.25 hPa"
string inHg = pressure.FormatPressure(BarometerUnits.InHg, includeUnit: true);
// Output: "29.92 inHg"
string mmHg = pressure.FormatPressure(BarometerUnits.MmHg, includeUnit: true);
// Output: "760.00 mmHg"
using Xcalibur.Weather.Helpers.Services;
using Microsoft.Extensions.Logging;
// Build air quality data point
var airQuality = await OpenMeteoHelper.BuildAirQualityPointAsync(
latitude: "40.7128",
longitude: "-74.0060",
logger: logger,
cancellationToken: CancellationToken.None
);
// Build current weather forecast
var currentForecast = await OpenMeteoHelper.BuildCurrentForecastAsync(
latitude: "40.7128",
longitude: "-74.0060",
canAssessDayNight: true,
sunrise: new TimeOnly(6, 30),
sunset: new TimeOnly(18, 30),
logger: logger,
cancellationToken: CancellationToken.None
);
// Build hourly forecast
var hourlyForecast = await OpenMeteoHelper.BuildHourlyForecastAsync(
latitude: "40.7128",
longitude: "-74.0060",
canAssessDayNight: true,
sunrise: new TimeOnly(6, 30),
sunset: new TimeOnly(18, 30),
logger: logger,
cancellationToken: CancellationToken.None
);
// Build daily forecast
var dailyForecast = await OpenMeteoHelper.BuildDailyForecastAsync(
latitude: "40.7128",
longitude: "-74.0060",
forecastDays: 7,
logger: logger,
cancellationToken: CancellationToken.None
);
// Build yesterday's hourly forecast
var yesterdayHourlyForecast = await OpenMeteoHelper.BuildYesterdayHourlyForecastAsync(
latitude: "40.7128",
longitude: "-74.0060",
canAssessDayNight: true,
sunrise: new TimeOnly(6, 30),
sunset: new TimeOnly(18, 30),
logger: logger,
cancellationToken: CancellationToken.None
);
// Build yesterday's daily forecast
var yesterdayDailyForecast = await OpenMeteoHelper.BuildYesterdayDailyForecastAsync(
latitude: "40.7128",
longitude: "-74.0060",
logger: logger,
cancellationToken: CancellationToken.None
);
using Xcalibur.Weather.Helpers.Services;
using Microsoft.Extensions.Logging;
// Test Geocodio API key
bool isValid = await GeocodioHelper.TestApiKeyAsync(
apiKey: "your-api-key",
logger: logger
);
// Build address locations from query
var locations = await GeocodioHelper.BuildAddressLocationsAsync(
apiKey: "your-api-key",
query: "1600 Pennsylvania Avenue NW, Washington, DC",
country: "US",
logger: logger
);
using Xcalibur.Weather.Helpers.Services;
using Microsoft.Extensions.Logging;
// Test IpGeolocation API key
bool isValid = await IpGeoHelper.TestApiKeyAsync(
apiKey: "your-api-key",
logger: logger
);
// Build sun/moon astronomical data
var sunMoonData = await IpGeoHelper.BuildSunMoonPointAsync(
ipGeoApiKey: "your-api-key",
latitude: "40.7128",
longitude: "-74.0060",
logger: logger
);
using Xcalibur.Weather.Helpers.Services;
using Microsoft.Extensions.Logging;
// Test Atmospore API key
bool isValid = await AtmosporeHelper.TestApiKeyAsync(
apiKey: "your-api-key",
logger: logger
);
// Build pollen forecast
var pollenForecast = await AtmosporeHelper.BuildPollenForecastAsync(
apiKey: "your-api-key",
latitude: "39.43",
longitude: "-77.80",
date: "2024-05-27", // Optional, defaults to today
forecastDays: 1,
logger: logger
);
if (pollenForecast is not null)
{
Console.WriteLine($"Date: {pollenForecast.ForecastDate}");
foreach (var entry in pollenForecast.Entries)
{
Console.WriteLine($"{entry.DisplayName}: {entry.RiskLevel}");
}
}
using Xcalibur.Weather.Helpers.Services;
using Microsoft.Extensions.Logging;
// Build sun/moon data — no API key required
var sunMoonData = await SunriseSunsetHelper.BuildSunMoonPointAsync(
latitude: "40.7128",
longitude: "-74.0060",
logger: logger
);
using Xcalibur.Weather.Helpers.Services;
using Microsoft.Extensions.Logging;
// Geocode an address — no API key required
var locations = await OpenStreetMapHelper.BuildAddressLocationsAsync(
query: "1600 Pennsylvania Avenue NW, Washington, DC",
country: "US",
logger: logger
);
using Xcalibur.Weather.Helpers.Services;
using Microsoft.Extensions.Logging;
// Build combined weather alerts from multiple sources
// (Meteoalarm, NWS, GDACS, Environment Canada, BOM, EMSC, DWD)
var alerts = await WeatherAlertHelper.BuildCombinedAlertsAsync(
latitude: 52.52,
longitude: 13.41,
countryCode: "DE",
logger: logger
);
if (alerts is not null && alerts.Alerts.Any())
{
Console.WriteLine($"Active Alerts: {alerts.TotalAlerts}");
foreach (var alert in alerts.Alerts)
{
Console.WriteLine($"[{alert.Severity}] {alert.Event}");
Console.WriteLine($" Source: {alert.Source}");
Console.WriteLine($" Effective: {alert.Effective}");
Console.WriteLine($" Expires: {alert.Expires}");
}
}
using Xcalibur.Weather.Helpers.Services;
// Determine geographic region
var region = WeatherRegionHelper.DetermineRegion(
latitude: 52.52,
longitude: 13.41,
countryCode: "DE"
);
Console.WriteLine($"Region: {region}"); // Output: Europe
// Check if coordinates are in Germany
bool isGermany = WeatherRegionHelper.IsInGermany(
latitude: 52.52,
longitude: 13.41
);
// Determine Canadian province
var province = WeatherRegionHelper.DetermineCanadianProvince(
latitude: 43.65,
longitude: -79.38
);
Console.WriteLine($"Province: {province}"); // Output: ON
// Determine Australian state
var state = WeatherRegionHelper.DetermineAustralianState(
latitude: -33.87,
longitude: 151.21
);
Console.WriteLine($"State: {state}"); // Output: NSW
| Method | Description |
|---|---|
CelsiusToFahrenheit(double) |
Converts temperature from Celsius to Fahrenheit |
CelsiusToFahrenheit(double?, double) |
Converts nullable Celsius to Fahrenheit; returns defaultValue when null |
FahrenheitToCelsius(double) |
Converts temperature from Fahrenheit to Celsius |
FahrenheitToCelsius(double?, double) |
Converts nullable Fahrenheit to Celsius; returns defaultValue when null |
ConvertWindSpeed(double, WindSpeedUnits?) |
Converts wind speed from km/h to specified unit |
ConvertWindSpeed(double?, WindSpeedUnits?) |
Converts nullable wind speed; returns 0 when null |
FormatTemperature(double, TemperatureUnits?, bool) |
Formats temperature with optional unit symbol |
FormatTemperature(double?, TemperatureUnits?, bool) |
Formats nullable temperature; returns empty string when null |
FormatLength(double?, DistanceUnits, bool) |
Formats length/precipitation with optional unit symbol |
FormatPressure(double?, BarometerUnits, bool) |
Formats pressure with optional unit symbol |
| Method | Description |
|---|---|
BuildAirQualityPointAsync(string, string, ILogger, CancellationToken) |
Retrieves and builds air quality data for coordinates |
BuildCurrentForecastAsync(...) |
Retrieves and builds current weather forecast point |
BuildHourlyForecastAsync(...) |
Retrieves and builds hourly forecast points |
BuildDailyForecastAsync(string, string, int, ILogger, CancellationToken) |
Retrieves and builds daily forecast points |
BuildYesterdayHourlyForecastAsync(...) |
Retrieves and builds yesterday's hourly forecast |
BuildYesterdayDailyForecastAsync(string, string, ILogger, CancellationToken) |
Retrieves and builds yesterday's daily forecast |
| Method | Description |
|---|---|
TestApiKeyAsync(string, ILogger) |
Tests the validity of a Geocodio API key |
BuildAddressLocationsAsync(...) |
Geocodes an address query and builds location models |
| Method | Description |
|---|---|
TestApiKeyAsync(string, ILogger) |
Tests the validity of an IpGeolocation API key |
BuildSunMoonPointAsync(string, string, string, ILogger) |
Retrieves and builds sun/moon astronomical data |
| Method | Description |
|---|---|
TestApiKeyAsync(string, ILogger) |
Tests the validity of an Atmospore API key |
BuildPollenForecastAsync(string, string, string, string?, int, ILogger?) |
Retrieves and maps Atmospore pollen forecast data to a PollenInformation model |
| Method | Description |
|---|---|
BuildSunMoonPointAsync(string, string, ILogger?) |
Fetches sunrise/sunset data from SunriseSunset.io and maps it to a SunMoonPoint — no API key required |
| Method | Description |
|---|---|
BuildAddressLocationsAsync(string, string, ILogger?) |
Geocodes an address query via OpenStreetMap Nominatim and returns location models — no API key required |
| Method | Description |
|---|---|
BuildCombinedAlertsAsync(double, double, string?, ILogger?, CancellationToken) |
Aggregates weather alerts from multiple global sources (Meteoalarm, NWS, GDACS, Environment Canada, BOM, EMSC, DWD) into a unified WeatherAlertInformation model |
BuildMeteoalarmAlertsAsync(...) |
Retrieves alerts from Meteoalarm (Europe) |
BuildNwsAlertsAsync(...) |
Retrieves alerts from the US National Weather Service |
BuildGdacsAlertsAsync(...) |
Retrieves global disaster alerts from GDACS |
BuildEnvironmentCanadaAlertsAsync(...) |
Retrieves alerts from Environment Canada |
BuildBomAlertsAsync(...) |
Retrieves alerts from the Australian Bureau of Meteorology |
BuildEmscAlertsAsync(...) |
Retrieves earthquake/seismic alerts from EMSC |
BuildDwdAlertsAsync(...) |
Retrieves alerts from the German weather service (DWD) |
| Method | Description |
|---|---|
DetermineRegion(double, double, string?) |
Determines the geographic region (US, Canada, Europe, Australia, Other) based on coordinates and optional country code |
IsInGermany(double, double) |
Checks if coordinates fall within German geographic bounds |
DetermineCanadianProvince(double, double) |
Returns the two-letter Canadian province code for the given coordinates |
DetermineAustralianState(double, double) |
Returns the Australian state code for the given coordinates |
The library ships with a comprehensive xUnit test suite covering all helpers and conversion utilities.
| Area | Tests | Coverage |
|---|---|---|
ConversionHelper |
Temperature, wind speed, length, and pressure conversions and formatting — including nullable overloads, null-unit guards, near-zero normalisation, and invalid-unit exceptions | Full public API |
OpenMeteoHelper |
Air quality, current, hourly, daily, and yesterday forecasts — including absent/empty response blocks and day/night assessment | Full public API |
GeocodioHelper |
Address location mapping (single and multiple results), null/empty/invalid-JSON responses, API key validation | Full public API |
IpGeoHelper |
Sun/moon point mapping, null/whitespace key guards, deserialization, and HTTP error responses | Full public API |
SunriseSunsetHelper |
Sun/moon point mapping, successful deserialization, HTTP error and invalid-JSON responses | Full public API |
OpenStreetMapHelper |
Address location mapping, town fallback, empty/null/invalid-JSON/HTTP error responses |
Full public API |
AtmosporeHelper |
Pollen forecast deserialization, API key validation, null/whitespace guards, HTTP error and invalid-JSON responses | Full public API |
WeatherAlertHelper |
Combined alert aggregation, individual source helpers (Meteoalarm, NWS, GDACS, Environment Canada, BOM, EMSC, DWD), cancellation behavior | Full public API |
WeatherRegionHelper |
Region determination (US, Canada, Europe, Australia), Germany bounds check, Canadian province detection, Australian state detection | Full public API |
dotnet test
Or via the .NET CLI targeting the test project directly:
dotnet test Xcalibur.Weather.Helpers.Tests/Xcalibur.Weather.Helpers.Tests.csproj
All conversion methods include overloads that handle nullable values:
double? temperature = null;
double result = temperature.CelsiusToFahrenheit(defaultValue: 0); // Returns 0
All service helpers accept an ILogger parameter for diagnostics and troubleshooting:
using Microsoft.Extensions.Logging;
ILogger logger = loggerFactory.CreateLogger<YourClass>();
var forecast = await OpenMeteoHelper.BuildCurrentForecast(
latitude, longitude, true, sunrise, sunset, logger
);
Service helpers manage HttpClient usage internally, so callers can use the helper APIs directly without constructing provider service instances.
This library depends on:
This project is licensed under the Apache License 2.0. See the file for details.
Copyright © 2006 - 2026, Xcalibur Systems, LLC - All Rights Reserved
Part of the Xcalibur Weather ecosystem for comprehensive weather data integration.
Joshua Arzt
Xcalibur Systems, LLC
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
Xcalibur.Weather.Models update for JSON deserialization.