Skip to content

Commit

Permalink
Version 0.2.0 (#18)
Browse files Browse the repository at this point in the history
* feat: sync methods for async counterparts

* test: add unit test for sync methods

* Test: refactoring

* remove deprecated private methods

* allways include debug symbols when building

* remove deprecated private methods

* refactoring

* _parameter is initialized in constructor

* remove deprecated private methods

* update readme

* property Generationtime_ms => GenerationTime

* fix: typo CountyId -> CountryId

* fix: typo and documentation for LocationData

* fix: remove obsolete data

* fix: remove obsolete data

* fix: remove obsolete data

* docs: typo

* fix: remove obsolete data

* edit README.md

* WeatherModelOptions class added for Weather models

* Weather Models implemented
  • Loading branch information
AlienDwarf authored Feb 4, 2023
1 parent b8b49fc commit e5f9673
Show file tree
Hide file tree
Showing 15 changed files with 4,691 additions and 538 deletions.
2 changes: 1 addition & 1 deletion OpenMeteo/AirQuality.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class AirQuality
public HourlyValues? Hourly { get; set; }

/// <summary>
/// For each selected variable in <see cref="AirQuality.Hourly"/>, the unit
/// The unit for each selected variable in <see cref="AirQuality.Hourly"/>
/// </summary>
[JsonPropertyName("hourly_units")]
public HourlyUnits? Hourly_Units { get; set; }
Expand Down
85 changes: 1 addition & 84 deletions OpenMeteo/DailyOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,6 @@ public class DailyOptions : IEnumerable, ICollection<DailyOptionsParameter>
/// <returns></returns>
public static DailyOptions All { get { return new DailyOptions((DailyOptionsParameter[])Enum.GetValues(typeof(DailyOptionsParameter))); } }

[Obsolete]
private static readonly string[] _allDailyParams = new string[]
{
"temperature_2m_max",
"temperature_2m_min",
"apparent_temperature_max",
"apparent_temperature_min",
"precipitation_sum",
"precipitation_hours",
"weathercode",
"sunrise",
"sunset",
"windspeed_10m_max",
"windgusts_10m_max",
"winddirection_10m_dominant",
"shortwave_radiation_sum"
};

/// <summary>
/// Gets a copy of elements contained in the List.
/// </summary>
Expand All @@ -42,24 +24,6 @@ public class DailyOptions : IEnumerable, ICollection<DailyOptionsParameter>
public bool IsReadOnly => false;

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

/*public DailyOptions(string[] parameter)
{
foreach (string s in parameter)
{
if (!IsValidParameter(s.ToLower()))
throw new ArgumentException(s + " is not a valid parameter");
this._parameter.Add(s);
}
}
public DailyOptions(string parameter)
{
string s = parameter.ToLower();
if (!IsValidParameter(s))
throw new ArgumentException(s + " is not a valid parameter");
this._parameter.Add(s);
}*/

public DailyOptions()
{
Expand Down Expand Up @@ -90,23 +54,10 @@ public DailyOptionsParameter this[int index]
}
}

/// <summary>
/// Add parameter
/// </summary>
/// <param name="param"></param>
/// <returns>True if successfully added else false</returns>
public void Add(DailyOptionsParameter param)
{
// Each enum variable represents an integer starting with 0.
// So we can use our static string[] to get the string representation

// Make sure we aren't our of array
//if ((int)param < 0 || (int)param >= _allDailyParams.Length) return;

//string paramToAdd = _allDailyParams[(int)param];

// Check that the parameter isn't already added
if (this._parameter.Contains(param)) return;
if (_parameter.Contains(param)) return;

_parameter.Add(param);
}
Expand All @@ -119,40 +70,6 @@ public void Add(DailyOptionsParameter[] param)
}
}

[Obsolete]
private bool IsValidParameter(string s)
{
bool found = false;
foreach (string str in _allDailyParams)
{
if (found) break;
if (s == str)
found = true;
}
return found;
}

[Obsolete]
private DailyOptionsParameter? DailyOptionsStringToEnum(string option)
{
if (!IsValidParameter(option)) return null;

DailyOptionsParameter? toFind = null;

// Get array index of valid parameter == (int)enum
int index = Array.IndexOf(_allDailyParams, option);

// Again check that we found an index
// (double check bc option we checked that option is a valid param already)
if (index == -1) return null;

// Check that index is defined in enum
if (!Enum.IsDefined(typeof(DailyOptionsParameter), index)) return null;

// Return enum to
return toFind;
}

public void Clear()
{
_parameter.Clear();
Expand Down
5 changes: 3 additions & 2 deletions OpenMeteo/GeocodingApiResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ public class GeocodingApiResponse
public LocationData[]? Locations { get; set; }

/// <summary>
/// Generation time of the weather forecast in milliseconds.
/// Generation time of the response in milliseconds.
/// </summary>
public float Generationtime_ms { get; set; }
[JsonPropertyName("generationtime_ms")]
public float GenerationTime { get; set; }
}
}
Loading

0 comments on commit e5f9673

Please sign in to comment.