]> git.basschouten.com Git - openhab-addons.git/blob
b40d3134a4a221b7f93c41c998d64e679030b8c5
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.synopanalyzer.internal.synop;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16
17 /**
18  * The {@link WindDirections} enum possible wind directions
19  *
20  * @author GaĆ«l L'hopital - Initial contribution
21  */
22 @NonNullByDefault
23 public enum WindDirections {
24     N,
25     NNE,
26     NE,
27     ENE,
28     E,
29     ESE,
30     SE,
31     SSE,
32     S,
33     SSW,
34     SW,
35     WSW,
36     W,
37     WNW,
38     NW,
39     NNW;
40
41     private static final double STEP = 360.0 / values().length;
42
43     /**
44      * Returns the wind direction based on degree.
45      */
46     public static WindDirections getWindDirection(int degree) {
47
48         double b = Math.floor((degree + (STEP / 2.0)) / STEP);
49         return values()[(int) (b % values().length)];
50     }
51 }