Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 403287ad authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update GeomagneticField coefficients to WMM-2020"

parents 93fc5270 bf2f69f4
Loading
Loading
Loading
Loading
+70 −68
Original line number Diff line number Diff line
@@ -16,7 +16,8 @@

package android.hardware;

import java.util.GregorianCalendar;
import java.util.Calendar;
import java.util.TimeZone;

/**
 * Estimates magnetic field at a given point on
@@ -49,6 +50,7 @@ public class GeomagneticField {

    // These coefficients and the formulae used below are from:
    // NOAA Technical Report: The US/UK World Magnetic Model for 2020-2025

    static private final float[][] G_COEFF = new float[][]{
            {0.0f},
            {-29404.5f, -1450.7f},
@@ -64,7 +66,6 @@ public class GeomagneticField {
            {3.0f, -1.4f, -2.5f, 2.4f, -0.9f, 0.3f, -0.7f, -0.1f, 1.4f, -0.6f, 0.2f, 3.1f},
            {-2.0f, -0.1f, 0.5f, 1.3f, -1.2f, 0.7f, 0.3f, 0.5f, -0.2f, -0.5f, 0.1f, -1.1f, -0.3f}};


    static private final float[][] H_COEFF = new float[][]{
            {0.0f},
            {0.0f, 4652.9f},
@@ -80,7 +81,6 @@ public class GeomagneticField {
            {0.0f, 0.0f, 2.6f, -0.5f, -0.4f, 0.6f, -0.2f, -1.7f, -1.6f, -3.0f, -2.0f, -2.6f},
            {0.0f, -1.2f, 0.5f, 1.3f, -1.8f, 0.1f, 0.7f, -0.1f, 0.6f, 0.2f, -0.9f, 0.0f, 0.5f}};


    static private final float[][] DELTA_G = new float[][]{
            {0.0f},
            {6.7f, 7.7f},
@@ -96,7 +96,6 @@ public class GeomagneticField {
            {0.0f, -0.1f, 0.0f, 0.0f, 0.0f, -0.1f, 0.0f, 0.0f, -0.1f, -0.1f, -0.1f, -0.1f},
            {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, -0.1f}};


    static private final float[][] DELTA_H = new float[][]{
            {0.0f},
            {0.0f, -25.1f},
@@ -112,8 +111,11 @@ public class GeomagneticField {
            {0.0f, 0.0f, 0.1f, 0.0f, 0.2f, 0.0f, 0.0f, 0.1f, 0.0f, -0.1f, 0.0f, 0.0f},
            {0.0f, 0.0f, 0.0f, -0.1f, 0.1f, 0.0f, 0.0f, 0.0f, 0.1f, 0.0f, 0.0f, 0.0f, -0.1f}};

    static private final long BASE_TIME =
            new GregorianCalendar(2020, 1, 1).getTimeInMillis();
    static private final long BASE_TIME = new Calendar.Builder()
            .setTimeZone(TimeZone.getTimeZone("UTC"))
            .setDate(2020, Calendar.JANUARY, 1)
            .build()
            .getTimeInMillis();

    // The ratio between the Gauss-normalized associated Legendre functions and
    // the Schmid quasi-normalized ones. Compute these once staticly since they
@@ -193,7 +195,7 @@ public class GeomagneticField {
        // We now compute the magnetic field strength given the geocentric
        // location. The magnetic field is the derivative of the potential
        // function defined by the model. See NOAA Technical Report: The US/UK
        // World Magnetic Model for 2015-2020 for the derivation.
        // World Magnetic Model for 2020-2025 for the derivation.
        float gcX = 0.0f;  // Geocentric northwards component.
        float gcY = 0.0f;  // Geocentric eastwards component.
        float gcZ = 0.0f;  // Geocentric downwards component.
@@ -206,7 +208,7 @@ public class GeomagneticField {

                // Negative derivative with respect to latitude, divided by
                // radius.  This looks like the negation of the version in the
                // NOAA Techincal report because that report used
                // NOAA Technical report because that report used
                // P_n^m(sin(theta)) and we use P_n^m(cos(90 - theta)), so the
                // derivative with respect to theta is negated.
                gcX += relativeRadiusPower[n+2]