]> git.basschouten.com Git - openhab-addons.git/blob
6be4e3f162dd13f369749e1a3876b2ace05cdd56
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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 /**
16  * The {@link WindDirections} enum possible wind directions
17  *
18  * @author GaĆ«l L'hopital - Initial contribution
19  */
20 public enum WindDirections {
21     N,
22     NNE,
23     NE,
24     ENE,
25     E,
26     ESE,
27     SE,
28     SSE,
29     S,
30     SSW,
31     SW,
32     WSW,
33     W,
34     WNW,
35     NW,
36     NNW;
37
38     /**
39      * Returns the wind direction based on degree.
40      */
41     public static WindDirections getWindDirection(int degree) {
42         double step = 360.0 / WindDirections.values().length;
43         double b = Math.floor((degree + (step / 2.0)) / step);
44         return WindDirections.values()[(int) (b % WindDirections.values().length)];
45     }
46 }