1 |
cdf3c217
|
A-Konig
|
//
|
2 |
|
|
// Author: A. Konig
|
3 |
|
|
//
|
4 |
|
|
|
5 |
|
|
namespace ServerApp.Parser.OutputInfo
|
6 |
|
|
{
|
7 |
|
|
/// <summary>
|
8 |
|
|
/// Transfers various values to weather conditions and vice versa
|
9 |
|
|
/// </summary>
|
10 |
|
|
/// <author>A. Konig</author>
|
11 |
|
|
public static class ValueToConditions
|
12 |
|
|
{
|
13 |
|
|
/// <summary>
|
14 |
|
|
/// Lux to weather conditions
|
15 |
|
|
/// </summary>
|
16 |
|
|
/// <param name="lux">Lux value</param>
|
17 |
|
|
/// <returns>Weather conditions</returns>
|
18 |
|
|
public static WeatherConditions TransferLuxToConditions(double lux)
|
19 |
|
|
{
|
20 |
|
|
if (lux > 40_000)
|
21 |
|
|
return WeatherConditions.Sunny;
|
22 |
|
|
|
23 |
|
|
if (lux > 20_000)
|
24 |
|
|
return WeatherConditions.Cloudy;
|
25 |
|
|
|
26 |
|
|
// TODO tohle bylo 10_000, jak mi to má vycházet, zkusit na hourly data
|
27 |
|
|
if (lux != 0)
|
28 |
|
|
return WeatherConditions.Overcast;
|
29 |
|
|
|
30 |
|
|
return WeatherConditions.Dark;
|
31 |
|
|
}
|
32 |
|
|
|
33 |
|
|
/// <summary>
|
34 |
|
|
/// Weather conditions to average lux
|
35 |
|
|
/// </summary>
|
36 |
|
|
/// <param name="condition">Weather conditions</param>
|
37 |
|
|
/// <returns>Lux value</returns>
|
38 |
a53b1de8
|
A-Konig
|
public static double TransferConditionsToLux(WeatherConditions condition)
|
39 |
cdf3c217
|
A-Konig
|
{
|
40 |
|
|
if (condition == WeatherConditions.Sunny)
|
41 |
|
|
return 60_000;
|
42 |
|
|
|
43 |
|
|
if (condition == WeatherConditions.Cloudy)
|
44 |
|
|
return 30_000;
|
45 |
|
|
|
46 |
|
|
if (condition == WeatherConditions.Overcast)
|
47 |
|
|
return 10_000;
|
48 |
|
|
|
49 |
|
|
if (condition == WeatherConditions.Dark)
|
50 |
|
|
return 0;
|
51 |
|
|
|
52 |
|
|
return -1;
|
53 |
|
|
}
|
54 |
|
|
|
55 |
|
|
/// <summary>
|
56 |
|
|
/// Cloud cover value in percentage to weather conditions
|
57 |
|
|
/// </summary>
|
58 |
|
|
/// <param name="cloudCover">Value expected between 0-100</param>
|
59 |
|
|
/// <returns>WeatherConditions</returns>
|
60 |
|
|
internal static WeatherConditions CloudCoverToConditions(int cloudCover)
|
61 |
|
|
{
|
62 |
|
|
if (cloudCover >= 66)
|
63 |
|
|
return WeatherConditions.Overcast;
|
64 |
|
|
|
65 |
|
|
if (cloudCover >= 33)
|
66 |
|
|
return WeatherConditions.Cloudy;
|
67 |
|
|
|
68 |
|
|
if (cloudCover >= 0)
|
69 |
|
|
return WeatherConditions.Sunny;
|
70 |
|
|
|
71 |
|
|
return WeatherConditions.Dark;
|
72 |
|
|
}
|
73 |
|
|
}
|
74 |
|
|
}
|