Projekt

Obecné

Profil

Stáhnout (1.71 KB) Statistiky
| Větev: | Tag: | Revize:
1
namespace ServerApp.Parser.OutputInfo
2
{
3
    /// <summary>
4
    /// Weather conditions in regards to sun level
5
    /// </summary>
6
    /// <author>Alex Konig</author>
7
    public enum WeatherConditions
8
    {
9
        Sunny, Cloudy, Overcast, Dark
10
    }
11

    
12
    /// <summary>
13
    /// Transfers lux values to weather conditions and vice versa
14
    /// </summary>
15
    /// <author>Alex Konig</author>
16
    public static class LuxToConditions
17
    {
18
        /// <summary>
19
        /// Lux to weather conditions
20
        /// </summary>
21
        /// <param name="lux">Lux value</param>
22
        /// <returns>Weather conditions</returns>
23
        public static WeatherConditions TransferLuxToConditions(double lux)
24
        {
25
            if (lux > 40_000)
26
                return WeatherConditions.Sunny;
27

    
28
            if (lux > 20_000)
29
                return WeatherConditions.Overcast;
30

    
31
            // TODO tohle bylo 10_000, jak mi to má vycházet, zkusit na hourly data
32
            if (lux != 0)
33
                return WeatherConditions.Cloudy;
34

    
35
            return WeatherConditions.Dark;
36
        }
37

    
38
        /// <summary>
39
        /// Weather conditions to average lux
40
        /// </summary>
41
        /// <param name="condition">Weather conditions</param>
42
        /// <returns>Lux value</returns>
43
        internal static double TransferConditionsToLux(WeatherConditions condition)
44
        {
45
            if (condition == WeatherConditions.Sunny)
46
                return 50_000;
47

    
48
            if (condition == WeatherConditions.Cloudy)
49
                return 30_000;
50

    
51
            if (condition == WeatherConditions.Overcast)
52
                return 15_000;
53

    
54
            if (condition == WeatherConditions.Dark)
55
                return 5_000;
56

    
57
            return -1;
58
        }
59
    }
60
}
(7-7/9)