class Convert {

    @NonNull
    public static String bearing2(double degrees) {
        if (Double.isNaN(degrees)) {
            return "";
        } else {
            degrees %= 360;
            if (degrees < 0) degrees += 360;
            final String bearingStr = ((int) degrees) + "°";
            if (337.5 <= degrees || degrees < 22.5)
                return bearingStr + " (N)";
            else if (degrees < 67.5)
                return bearingStr + " (NE)";
            else if (degrees < 112.5)
                return bearingStr + " (E)";
            else if (degrees < 157.5)
                return bearingStr + " (SE)";
            else if (degrees < 202.5)
                return bearingStr + " (S)";
            else if (degrees < 247.5)
                return bearingStr + " (SW)";
            else if (degrees < 292.5)
                return bearingStr + " (W)";
            else
                return bearingStr + " (NW)";
        }
    }

}