Skip to content

Commit 9119caa

Browse files
committed
Updated to WMM2010
Change-Id: I5937eed4a8775eae044500552ec81030b93acb18
1 parent 2ecce34 commit 9119caa

File tree

1 file changed

+60
-61
lines changed

1 file changed

+60
-61
lines changed

core/java/android/hardware/GeomagneticField.java

Lines changed: 60 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@
2626
* <p>This uses the World Magnetic Model produced by the United States National
2727
* Geospatial-Intelligence Agency. More details about the model can be found at
2828
* <a href="http://www.ngdc.noaa.gov/geomag/WMM/DoDWMM.shtml">http://www.ngdc.noaa.gov/geomag/WMM/DoDWMM.shtml</a>.
29-
* This class currently uses WMM-2005 which is valid until 2010, but should
30-
* produce acceptable results for several years after that.
29+
* This class currently uses WMM-2010 which is valid until 2015, but should
30+
* produce acceptable results for several years after that. Future versions of
31+
* Android may use a newer version of the model.
3132
*/
3233
public class GeomagneticField {
3334
// The magnetic field at a given point, in nonoteslas in geodetic
@@ -43,75 +44,73 @@ public class GeomagneticField {
4344

4445
// Constants from WGS84 (the coordinate system used by GPS)
4546
static private final float EARTH_SEMI_MAJOR_AXIS_KM = 6378.137f;
46-
static private final float EARTH_SEMI_MINOR_AXIS_KM = 6356.7523f;
47+
static private final float EARTH_SEMI_MINOR_AXIS_KM = 6356.7523142f;
4748
static private final float EARTH_REFERENCE_RADIUS_KM = 6371.2f;
4849

4950
// These coefficients and the formulae used below are from:
50-
// NOAA Technical Report: The US/UK World Magnetic Model for 2005-2010
51+
// NOAA Technical Report: The US/UK World Magnetic Model for 2010-2015
5152
static private final float[][] G_COEFF = new float[][] {
52-
{ 0f },
53-
{ -29556.8f, -1671.7f },
54-
{ -2340.6f, 3046.9f, 1657.0f },
55-
{ 1335.4f, -2305.1f, 1246.7f, 674.0f },
56-
{ 919.8f, 798.1f, 211.3f, -379.4f, 100.0f },
57-
{ -227.4f, 354.6f, 208.7f, -136.5f, -168.3f, -14.1f },
58-
{ 73.2f, 69.7f, 76.7f, -151.2f, -14.9f, 14.6f, -86.3f },
59-
{ 80.1f, -74.5f, -1.4f, 38.5f, 12.4f, 9.5f, 5.7f, 1.8f },
60-
{ 24.9f, 7.7f, -11.6f, -6.9f, -18.2f, 10.0f, 9.2f, -11.6f, -5.2f },
61-
{ 5.6f, 9.9f, 3.5f, -7.0f, 5.1f, -10.8f, -1.3f, 8.8f, -6.7f, -9.1f },
62-
{ -2.3f, -6.3f, 1.6f, -2.6f, 0.0f, 3.1f, 0.4f, 2.1f, 3.9f, -0.1f, -2.3f },
63-
{ 2.8f, -1.6f, -1.7f, 1.7f, -0.1f, 0.1f, -0.7f, 0.7f, 1.8f, 0.0f, 1.1f, 4.1f },
64-
{ -2.4f, -0.4f, 0.2f, 0.8f, -0.3f, 1.1f, -0.5f, 0.4f, -0.3f, -0.3f, -0.1f,
65-
-0.3f, -0.1f } };
53+
{ 0.0f },
54+
{ -29496.6f, -1586.3f },
55+
{ -2396.6f, 3026.1f, 1668.6f },
56+
{ 1340.1f, -2326.2f, 1231.9f, 634.0f },
57+
{ 912.6f, 808.9f, 166.7f, -357.1f, 89.4f },
58+
{ -230.9f, 357.2f, 200.3f, -141.1f, -163.0f, -7.8f },
59+
{ 72.8f, 68.6f, 76.0f, -141.4f, -22.8f, 13.2f, -77.9f },
60+
{ 80.5f, -75.1f, -4.7f, 45.3f, 13.9f, 10.4f, 1.7f, 4.9f },
61+
{ 24.4f, 8.1f, -14.5f, -5.6f, -19.3f, 11.5f, 10.9f, -14.1f, -3.7f },
62+
{ 5.4f, 9.4f, 3.4f, -5.2f, 3.1f, -12.4f, -0.7f, 8.4f, -8.5f, -10.1f },
63+
{ -2.0f, -6.3f, 0.9f, -1.1f, -0.2f, 2.5f, -0.3f, 2.2f, 3.1f, -1.0f, -2.8f },
64+
{ 3.0f, -1.5f, -2.1f, 1.7f, -0.5f, 0.5f, -0.8f, 0.4f, 1.8f, 0.1f, 0.7f, 3.8f },
65+
{ -2.2f, -0.2f, 0.3f, 1.0f, -0.6f, 0.9f, -0.1f, 0.5f, -0.4f, -0.4f, 0.2f, -0.8f, 0.0f } };
6666

6767
static private final float[][] H_COEFF = new float[][] {
68-
{ 0f },
69-
{ 0.0f, 5079.8f },
70-
{ 0.0f, -2594.7f, -516.7f },
71-
{ 0.0f, -199.9f, 269.3f, -524.2f },
72-
{ 0.0f, 281.5f, -226.0f, 145.8f, -304.7f },
73-
{ 0.0f, 42.4f, 179.8f, -123.0f, -19.5f, 103.6f },
74-
{ 0.0f, -20.3f, 54.7f, 63.6f, -63.4f, -0.1f, 50.4f },
75-
{ 0.0f, -61.5f, -22.4f, 7.2f, 25.4f, 11.0f, -26.4f, -5.1f },
76-
{ 0.0f, 11.2f, -21.0f, 9.6f, -19.8f, 16.1f, 7.7f, -12.9f, -0.2f },
77-
{ 0.0f, -20.1f, 12.9f, 12.6f, -6.7f, -8.1f, 8.0f, 2.9f, -7.9f, 6.0f },
78-
{ 0.0f, 2.4f, 0.2f, 4.4f, 4.8f, -6.5f, -1.1f, -3.4f, -0.8f, -2.3f, -7.9f },
79-
{ 0.0f, 0.3f, 1.2f, -0.8f, -2.5f, 0.9f, -0.6f, -2.7f, -0.9f, -1.3f, -2.0f, -1.2f },
80-
{ 0.0f, -0.4f, 0.3f, 2.4f, -2.6f, 0.6f, 0.3f, 0.0f, 0.0f, 0.3f, -0.9f, -0.4f,
81-
0.8f } };
68+
{ 0.0f },
69+
{ 0.0f, 4944.4f },
70+
{ 0.0f, -2707.7f, -576.1f },
71+
{ 0.0f, -160.2f, 251.9f, -536.6f },
72+
{ 0.0f, 286.4f, -211.2f, 164.3f, -309.1f },
73+
{ 0.0f, 44.6f, 188.9f, -118.2f, 0.0f, 100.9f },
74+
{ 0.0f, -20.8f, 44.1f, 61.5f, -66.3f, 3.1f, 55.0f },
75+
{ 0.0f, -57.9f, -21.1f, 6.5f, 24.9f, 7.0f, -27.7f, -3.3f },
76+
{ 0.0f, 11.0f, -20.0f, 11.9f, -17.4f, 16.7f, 7.0f, -10.8f, 1.7f },
77+
{ 0.0f, -20.5f, 11.5f, 12.8f, -7.2f, -7.4f, 8.0f, 2.1f, -6.1f, 7.0f },
78+
{ 0.0f, 2.8f, -0.1f, 4.7f, 4.4f, -7.2f, -1.0f, -3.9f, -2.0f, -2.0f, -8.3f },
79+
{ 0.0f, 0.2f, 1.7f, -0.6f, -1.8f, 0.9f, -0.4f, -2.5f, -1.3f, -2.1f, -1.9f, -1.8f },
80+
{ 0.0f, -0.9f, 0.3f, 2.1f, -2.5f, 0.5f, 0.6f, 0.0f, 0.1f, 0.3f, -0.9f, -0.2f, 0.9f } };
8281

8382
static private final float[][] DELTA_G = new float[][] {
84-
{ 0f },
85-
{ 8.0f, 10.6f },
86-
{ -15.1f, -7.8f, -0.8f },
87-
{ 0.4f, -2.6f, -1.2f, -6.5f },
88-
{ -2.5f, 2.8f, -7.0f, 6.2f, -3.8f },
89-
{ -2.8f, 0.7f, -3.2f, -1.1f, 0.1f, -0.8f },
90-
{ -0.7f, 0.4f, -0.3f, 2.3f, -2.1f, -0.6f, 1.4f },
91-
{ 0.2f, -0.1f, -0.3f, 1.1f, 0.6f, 0.5f, -0.4f, 0.6f },
92-
{ 0.1f, 0.3f, -0.4f, 0.3f, -0.3f, 0.2f, 0.4f, -0.7f, 0.4f },
93-
{ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
94-
{ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
95-
{ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
96-
{ 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.0f } };
83+
{ 0.0f },
84+
{ 11.6f, 16.5f },
85+
{ -12.1f, -4.4f, 1.9f },
86+
{ 0.4f, -4.1f, -2.9f, -7.7f },
87+
{ -1.8f, 2.3f, -8.7f, 4.6f, -2.1f },
88+
{ -1.0f, 0.6f, -1.8f, -1.0f, 0.9f, 1.0f },
89+
{ -0.2f, -0.2f, -0.1f, 2.0f, -1.7f, -0.3f, 1.7f },
90+
{ 0.1f, -0.1f, -0.6f, 1.3f, 0.4f, 0.3f, -0.7f, 0.6f },
91+
{ -0.1f, 0.1f, -0.6f, 0.2f, -0.2f, 0.3f, 0.3f, -0.6f, 0.2f },
92+
{ 0.0f, -0.1f, 0.0f, 0.3f, -0.4f, -0.3f, 0.1f, -0.1f, -0.4f, -0.2f },
93+
{ 0.0f, 0.0f, -0.1f, 0.2f, 0.0f, -0.1f, -0.2f, 0.0f, -0.1f, -0.2f, -0.2f },
94+
{ 0.0f, 0.0f, 0.0f, 0.1f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, -0.1f, 0.0f },
95+
{ 0.0f, 0.0f, 0.1f, 0.1f, -0.1f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, -0.1f, 0.1f } };
9796

9897
static private final float[][] DELTA_H = new float[][] {
99-
{ 0f },
100-
{ 0.0f, -20.9f },
101-
{ 0.0f, -23.2f, -14.6f },
102-
{ 0.0f, 5.0f, -7.0f, -0.6f },
103-
{ 0.0f, 2.2f, 1.6f, 5.8f, 0.1f },
104-
{ 0.0f, 0.0f, 1.7f, 2.1f, 4.8f, -1.1f },
105-
{ 0.0f, -0.6f, -1.9f, -0.4f, -0.5f, -0.3f, 0.7f },
106-
{ 0.0f, 0.6f, 0.4f, 0.2f, 0.3f, -0.8f, -0.2f, 0.1f },
107-
{ 0.0f, -0.2f, 0.1f, 0.3f, 0.4f, 0.1f, -0.2f, 0.4f, 0.4f },
108-
{ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
109-
{ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
110-
{ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
111-
{ 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.0f } };
98+
{ 0.0f },
99+
{ 0.0f, -25.9f },
100+
{ 0.0f, -22.5f, -11.8f },
101+
{ 0.0f, 7.3f, -3.9f, -2.6f },
102+
{ 0.0f, 1.1f, 2.7f, 3.9f, -0.8f },
103+
{ 0.0f, 0.4f, 1.8f, 1.2f, 4.0f, -0.6f },
104+
{ 0.0f, -0.2f, -2.1f, -0.4f, -0.6f, 0.5f, 0.9f },
105+
{ 0.0f, 0.7f, 0.3f, -0.1f, -0.1f, -0.8f, -0.3f, 0.3f },
106+
{ 0.0f, -0.1f, 0.2f, 0.4f, 0.4f, 0.1f, -0.1f, 0.4f, 0.3f },
107+
{ 0.0f, 0.0f, -0.2f, 0.0f, -0.1f, 0.1f, 0.0f, -0.2f, 0.3f, 0.2f },
108+
{ 0.0f, 0.1f, -0.1f, 0.0f, -0.1f, -0.1f, 0.0f, -0.1f, -0.2f, 0.0f, -0.1f },
109+
{ 0.0f, 0.0f, 0.1f, 0.0f, 0.1f, 0.0f, 0.1f, 0.0f, -0.1f, -0.1f, 0.0f, -0.1f },
110+
{ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.1f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f } };
112111

113112
static private final long BASE_TIME =
114-
new GregorianCalendar(2005, 1, 1).getTimeInMillis();
113+
new GregorianCalendar(2010, 1, 1).getTimeInMillis();
115114

116115
// The ratio between the Gauss-normalized associated Legendre functions and
117116
// the Schmid quasi-normalized ones. Compute these once staticly since they
@@ -191,7 +190,7 @@ public GeomagneticField(float gdLatitudeDeg,
191190
// We now compute the magnetic field strength given the geocentric
192191
// location. The magnetic field is the derivative of the potential
193192
// function defined by the model. See NOAA Technical Report: The US/UK
194-
// World Magnetic Model for 2005-2010 for the derivation.
193+
// World Magnetic Model for 2010-2015 for the derivation.
195194
float gcX = 0.0f; // Geocentric northwards component.
196195
float gcY = 0.0f; // Geocentric eastwards component.
197196
float gcZ = 0.0f; // Geocentric downwards component.
@@ -406,4 +405,4 @@ private static float[][] computeSchmidtQuasiNormFactors(int maxN) {
406405
}
407406
return schmidtQuasiNorm;
408407
}
409-
}
408+
}

0 commit comments

Comments
 (0)