Code example for GeomagneticField

Methods: getDeclination

0
        // Just to satisfy the compiler 
        return "???"; 
    } 
 
    public static float getMagneticDeclination( Location location ) {
        GeomagneticField geoField = new GeomagneticField(
                (float)location.getLatitude(), (float)location.getLongitude(),
                (float)location.getAltitude(), System.currentTimeMillis() );
        // West declination is reported in negative values 
        return -1*geoField.getDeclination();
    } 
 
    public static double applyDeclination( double windDir, double magVar ) {
        return ( windDir+magVar+360 )%360;
    } 
 
    public static long applyDeclination( long heading, float declination ) {
        return Math.round( heading+declination+360 )%360;
    } 
 
Stop searching for code, let great code find you!  Add Codota to your java IDE