Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
AlienDwarf committed Oct 21, 2023
2 parents 2a53bb1 + d496e32 commit 8017eaf
Show file tree
Hide file tree
Showing 14 changed files with 486 additions and 35 deletions.
2 changes: 1 addition & 1 deletion LICENSE.txt → LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 AlienDwarf
Copyright (c) 2022-present AlienDwarf

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
27 changes: 22 additions & 5 deletions OpenMeteo/CurrentWeather.cs → OpenMeteo/Current.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,47 @@ namespace OpenMeteo
/// <summary>
/// Api response containing information about current weather conditions
/// </summary>
public class CurrentWeather
public class Current
{
public string? Time { get; set; }

public int? Interval { get; set; }

/// <summary>
/// Temperature in <see cref="WeatherForecastOptions.Temperature_Unit"/>
/// </summary>
public float Temperature { get; set; }
public float? Temperature { get { return Temperature_2m; } private set { } }

public float? Temperature_2m { get; set; }

/// <summary>
/// WMO Weather interpretation code.
/// To get an actual string representation use <see cref="OpenMeteo.OpenMeteoClient.WeathercodeToString(int)"/>
/// </summary>
public float Weathercode { get; set; }
public int? Weathercode { get; set; }

/// <summary>
/// Windspeed. Unit defined in <see cref="WeatherForecastOptions.Windspeed_Unit"/>
/// </summary>
/// <value></value>
public float Windspeed { get; set; }
public float? Windspeed_10m { get; set; }

/// <summary>
/// Wind direction in degrees
/// </summary>
public float WindDirection { get; set; }
public int? Winddirection_10m { get; set; }
public float? Windgusts_10m { get; set; }


public int? Relativehumidity_2m { get; set; }
public float? Apparent_temperature { get; set; }
public int? Is_day { get; set; }
public float? Precipitation { get; set; }
public float? Rain { get; set; }
public float? Showers { get; set; }
public float? Snowfall { get; set; }
public int? Cloudcover { get; set; }
public float? Pressure_msl { get; set; }
public float? Surface_pressure { get; set; }
}
}
122 changes: 122 additions & 0 deletions OpenMeteo/CurrentOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace OpenMeteo
{
public class CurrentOptions : IEnumerable, ICollection<CurrentOptionsParameter>
{
/// <summary>
/// Gets a new object containing every parameter
/// </summary>
/// <returns></returns>
public static CurrentOptions All { get { return new CurrentOptions((CurrentOptionsParameter[])Enum.GetValues(typeof(CurrentOptionsParameter))); } }

/// <summary>
/// Gets a copy of elements contained in the List.
/// </summary>
/// <typeparam name="CurrentOptionsParameter"></typeparam>
/// <returns>A copy of elements contained in the List</returns>
public List<CurrentOptionsParameter> Parameter { get { return new List<CurrentOptionsParameter>(_parameter); } }

public int Count => _parameter.Count;

public bool IsReadOnly => false;

private readonly List<CurrentOptionsParameter> _parameter = new List<CurrentOptionsParameter>();

public CurrentOptions()
{

}

public CurrentOptions(CurrentOptionsParameter parameter)
{
Add(parameter);
}

public CurrentOptions(CurrentOptionsParameter[] parameter)
{
Add(parameter);
}

/// <summary>
/// Index the collection
/// </summary>
/// <param name="index"></param>
/// <returns><see cref="string"/> CurrentOptionsType as string representation at index</returns>
public CurrentOptionsParameter this[int index]
{
get { return _parameter[index]; }
set
{
_parameter[index] = value;
}
}

public void Add(CurrentOptionsParameter param)
{
// Check that the parameter isn't already added
if (_parameter.Contains(param)) return;

_parameter.Add(param);
}

public void Add(CurrentOptionsParameter[] param)
{
foreach (CurrentOptionsParameter paramToAdd in param)
{
Add(paramToAdd);
}
}

public void Clear()
{
_parameter.Clear();
}

public bool Contains(CurrentOptionsParameter item)
{
return _parameter.Contains(item);
}

public bool Remove(CurrentOptionsParameter item)
{
return _parameter.Remove(item);
}

public void CopyTo(CurrentOptionsParameter[] array, int arrayIndex)
{
_parameter.CopyTo(array, arrayIndex);
}

public IEnumerator<CurrentOptionsParameter> GetEnumerator()
{
return _parameter.GetEnumerator();
}

IEnumerator IEnumerable.GetEnumerator()
{
return this.GetEnumerator();
}
}

public enum CurrentOptionsParameter
{
temperature_2m,
relativehumidity_2m,
apparent_temperature,
is_day, precipitation,
rain,
showers,
snowfall,
weathercode,
cloudcover,
pressure_msl,
surface_pressure,
windspeed_10m,
winddirection_10m,
windgusts_10m
}
}
29 changes: 29 additions & 0 deletions OpenMeteo/CurrentUnits.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json.Serialization;

namespace OpenMeteo
{
public class CurrentUnits
{
public string? Time { get; set; }
public string? Interval { get; set; }
public string? Temperature_2m { get; set; }
public string? Temperature { get { return Temperature_2m; } private set { } }
public string? Relativehumidity_2m { get; set; }
public string? Apparent_temperature { get; set; }
public string? Is_day { get; set; }
public string? Precipitation { get; set; }
public string? Rain { get; set; }
public string? Showers { get; set; }
public string? Snowfall { get; set; }
public string? Weathercode { get; set; }
public string? Cloudcover { get; set; }
public string? Pressure_msl { get; set; }
public string? Surface_pressure { get; set; }
public string? Windspeed_10m { get; set; }
public string? Winddirection_10m { get; set; }
public string? Windgusts_10m { get; set; }
}
}
2 changes: 1 addition & 1 deletion OpenMeteo/DailyUnits.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace OpenMeteo
{
public class Daily_Units
public class DailyUnits
{
public string? Time { get; set; }
public string? Weathercode { get; set; }
Expand Down
39 changes: 39 additions & 0 deletions OpenMeteo/Minutely15.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace OpenMeteo
{
public class Minutely15
{
public string[]? time { get; set; }
public float[]? temperature_2m { get; set; }
public int[]? relativehumidity_2m { get; set; }
public float[]? dewpoint_2m { get; set; }
public float[]? apparent_temperature { get; set; }
public float[]? precipitation { get; set; }
public float[]? rain { get; set; }
public float[]? snowfall { get; set; }
public float?[]? snowfall_height { get; set; }
public float[]? freezinglevel_height { get; set; }
public int[]? weathercode { get; set; }
public float[]? windspeed_10m { get; set; }
public float[]? windspeed_80m { get; set; }
public int[]? winddirection_10m { get; set; }
public int[]? winddirection_80m { get; set; }
public float[]? windgusts_10m { get; set; }
public float[]? visibility { get; set; }
public float[]? cape { get; set; }
public float?[]? lightning_potential { get; set; }
public float[]? shortwave_radiation { get; set; }
public float[]? direct_radiation { get; set; }
public float[]? diffuse_radiation { get; set; }
public float[]? direct_normal_irradiance { get; set; }
public float[]? terrestrial_radiation { get; set; }
public float[]? shortwave_radiation_instant { get; set; }
public float[]? direct_radiation_instant { get; set; }
public float[]? diffuse_radiation_instant { get; set; }
public float[]? direct_normal_irradiance_instant { get; set; }
public float[]? terrestrial_radiation_instant { get; set; }
}
}
136 changes: 136 additions & 0 deletions OpenMeteo/Minutely15Options.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace OpenMeteo
{
public class Minutely15Options : IEnumerable, ICollection<Minutely15OptionsParameter>
{
/// <summary>
/// Gets a new object containing every parameter
/// </summary>
/// <returns></returns>
public static Minutely15Options All { get { return new Minutely15Options((Minutely15OptionsParameter[])Enum.GetValues(typeof(Minutely15OptionsParameter))); } }

/// <summary>
/// Gets a copy of elements contained in the List.
/// </summary>
/// <typeparam name="Minutely15OptionsParameter"></typeparam>
/// <returns>A copy of elements contained in the List</returns>
public List<Minutely15OptionsParameter> Parameter { get { return new List<Minutely15OptionsParameter>(_parameter); } }

public int Count => _parameter.Count;

public bool IsReadOnly => false;

private readonly List<Minutely15OptionsParameter> _parameter = new List<Minutely15OptionsParameter>();

public Minutely15Options()
{

}

public Minutely15Options(Minutely15OptionsParameter parameter)
{
Add(parameter);
}

public Minutely15Options(Minutely15OptionsParameter[] parameter)
{
Add(parameter);
}

/// <summary>
/// Index the collection
/// </summary>
/// <param name="index"></param>
/// <returns><see cref="string"/> Minutely15OptionsParameter as string representation at index</returns>
public Minutely15OptionsParameter this[int index]
{
get { return _parameter[index]; }
set
{
_parameter[index] = value;
}
}

public void Add(Minutely15OptionsParameter param)
{
// Check that the parameter isn't already added
if (_parameter.Contains(param)) return;

_parameter.Add(param);
}

public void Add(Minutely15OptionsParameter[] param)
{
foreach (Minutely15OptionsParameter paramToAdd in param)
{
Add(paramToAdd);
}
}

public void Clear()
{
_parameter.Clear();
}

public bool Contains(Minutely15OptionsParameter item)
{
return _parameter.Contains(item);
}

public bool Remove(Minutely15OptionsParameter item)
{
return _parameter.Remove(item);
}

public void CopyTo(Minutely15OptionsParameter[] array, int arrayIndex)
{
_parameter.CopyTo(array, arrayIndex);
}

public IEnumerator<Minutely15OptionsParameter> GetEnumerator()
{
return _parameter.GetEnumerator();
}

IEnumerator IEnumerable.GetEnumerator()
{
return this.GetEnumerator();
}
}

public enum Minutely15OptionsParameter
{
temperature_2m,
relativehumidity_2m,
dewpoint_2m,
apparent_temperature,
precipitation,
rain,
snowfall,
snowfall_height,
freezinglevel_height,
weathercode,
windspeed_10m,
windspeed_80m,
winddirection_10m,
winddirection_80m,
windgusts_10m,
visibility,
cape,
lightning_potential,
shortwave_radiation,
direct_radiation,
diffuse_radiation,
direct_normal_irradiance,
terrestrial_radiation,
shortwave_radiation_instant,
direct_radiation_instant,
diffuse_radiation_instant,
direct_normal_irradiance_instant,
terrestrial_radiation_instant
}
}
Loading

0 comments on commit 8017eaf

Please sign in to comment.