# Print output for @column tags ?> GeomagneticField - Android SDK | Android Developers

Most visited

Recently visited

GeomagneticField

public class GeomagneticField
extends Object

java.lang.Object
   ↳ android.hardware.GeomagneticField


Estimates magnetic field at a given point on Earth, and in particular, to compute the magnetic declination from true north.

This uses the World Magnetic Model produced by the United States National Geospatial-Intelligence Agency. More details about the model can be found at http://www.ngdc.noaa.gov/geomag/WMM/DoDWMM.shtml. This class currently uses WMM-2015 which is valid until 2020, but should produce acceptable results for several years after that. Future versions of Android may use a newer version of the model.

Summary

Public constructors

GeomagneticField(float gdLatitudeDeg, float gdLongitudeDeg, float altitudeMeters, long timeMillis)

Estimate the magnetic field at a given point and time.

Public methods

float getDeclination()
float getFieldStrength()
float getHorizontalStrength()
float getInclination()
float getX()
float getY()
float getZ()

Inherited methods

Public constructors

GeomagneticField

public GeomagneticField (float gdLatitudeDeg, 
                float gdLongitudeDeg, 
                float altitudeMeters, 
                long timeMillis)

Estimate the magnetic field at a given point and time.

Parameters
gdLatitudeDeg float: Latitude in WGS84 geodetic coordinates -- positive is east.

gdLongitudeDeg float: Longitude in WGS84 geodetic coordinates -- positive is north.

altitudeMeters float: Altitude in WGS84 geodetic coordinates, in meters.

timeMillis long: Time at which to evaluate the declination, in milliseconds since January 1, 1970. (approximate is fine -- the declination changes very slowly).

Public methods

getDeclination

public float getDeclination ()

Returns
float The declination of the horizontal component of the magnetic field from true north, in degrees (i.e. positive means the magnetic field is rotated east that much from true north).

getFieldStrength

public float getFieldStrength ()

Returns
float Total field strength in nanoteslas.

getHorizontalStrength

public float getHorizontalStrength ()

Returns
float Horizontal component of the field strength in nanoteslas.

getInclination

public float getInclination ()

Returns
float The inclination of the magnetic field in degrees -- positive means the magnetic field is rotated downwards.

getX

public float getX ()

Returns
float The X (northward) component of the magnetic field in nanoteslas.

getY

public float getY ()

Returns
float The Y (eastward) component of the magnetic field in nanoteslas.

getZ

public float getZ ()

Returns
float The Z (downward) component of the magnetic field in nanoteslas.