private String extractWindDirection()

in extensions/weather-update/core/src/main/java/org/apache/unomi/weatherupdate/actions/WeatherUpdateAction.java [223:256]


    private String extractWindDirection(JsonNode currentWeatherData) {
        JsonNode windInfoDirection;
        String direction = "";
        if (currentWeatherData.has(WIND)) {
            if (currentWeatherData.get(WIND).has(WIND_DIRECTION_INFO)) {
                windInfoDirection = currentWeatherData.get(WIND).get(WIND_DIRECTION_INFO);
                if (windInfoDirection != null) {

                    float deg = Float.parseFloat(windInfoDirection.toString());
                    if (340 < deg && deg < 360 || 0 < deg && deg < 20) {
                        direction = ("N");
                    } else if (20 < deg && deg < 70) {
                        direction = ("NE");
                    } else if (70 < deg && deg < 110) {
                        direction = ("E");
                    } else if (110 < deg && deg < 160) {
                        direction = ("SE");
                    } else if (160 < deg && deg < 200) {
                        direction = ("S");
                    } else if (200 < deg && deg < 245) {
                        direction = ("SW");
                    } else if (245 < deg && deg < 290) {
                        direction = ("W");
                    } else if (290 < deg && deg < 340) {
                        direction = ("NW");
                    }
                    LOGGER.debug("Wind direction: {} ", direction);
                    return direction;
                }
            }
        }
        LOGGER.warn("API Response doesn't contains the wind direction");
        return null;
    }