Android GeomagneticField - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android GeomagneticField class.

This code example shows how to use the following methods:getDeclination
	 *  
	 * @param location 
	 * @return Declination in degrees 
	 */ 
	public static float getDeclinationAt(float latitude, float longitude, float altitude) {
		GeomagneticField gf = new GeomagneticField(latitude, longitude, altitude, System.currentTimeMillis());
		return gf.getDeclination();
	} 
} 
6
CodeRank
This code example shows how to use the following methods:getDeclination
        // 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;
    } 
 
5
CodeRank
This code example shows how to use the following methods:getDeclination
This code example shows how to use the following methods:getDeclination
		if (timestamp == 0) {
			// Hack for Samsung phones which don't populate the time field 
			timestamp = System.currentTimeMillis();
		} 
 
		GeomagneticField field = new GeomagneticField(
				(float) location.getLatitude(),
				(float) location.getLongitude(),
				(float) location.getAltitude(), timestamp);
		variation = field.getDeclination();
		 
//		Log.d("MyLocationService", "Variation reset to " + variation + " degrees."); 
	} 
 
	@Override 
	public void onAccuracyChanged(Sensor sensor, int accuracy) {
		// do nothing 
	} 
 
	@Override 
4
CodeRank
This code example shows how to use the following methods:getDeclination
    } 
    // Update magnetic declination once every minute 
    // -- diff between "true north" and magnetic north in degrees 
    if (declinationTime + 60000 < now) {
      declinationTime = now;
      GeomagneticField magneticField = new GeomagneticField(
          (float) location.getLatitude(), (float) location.getLongitude(),
          location.hasAltitude() ? (float) location.getAltitude() : 100f, // use 100m if not known
          declinationTime);
      compassDeclination = new Float(magneticField.getDeclination());
    } 
    // If there is no bearing (lack of motion or network location), use latest compass heading 
    if (!location.hasBearing() || !location.hasSpeed() || location.getSpeed() < 0.3f) {
      location.setBearing(compassHeading);
    } 
 
    // Update current location 
    if (currentLocation != null) {
      currentLocation.set(location);
    } else { 
4
CodeRank
This code example shows how to use the following methods:getDeclination
        if (timestamp == 0) {
          // Hack for Samsung phones which don't populate the time field 
          timestamp = System.currentTimeMillis();
        } 
 
        GeomagneticField field = new GeomagneticField(
            (float) location.getLatitude(),
            (float) location.getLongitude(),
            (float) location.getAltitude(),
            timestamp);
        variation = field.getDeclination();
      } 
 
     
    public void onLocationChanged(Location location) {
		super.onLocationChanged(location);
/* 
        GeoPoint point = new GeoPoint( 
                (int) ((double) location.getLatitude() * E6), 
                (int) ((double) location.getLongitude() * E6)); 
4
CodeRank
This code example shows how to use the following methods:getDeclination
        if (timestamp == 0) {
          // Hack for Samsung phones which don't populate the time field 
          timestamp = System.currentTimeMillis();
        } 
 
        GeomagneticField field = new GeomagneticField(
            (float) location.getLatitude(),
            (float) location.getLongitude(),
            (float) location.getAltitude(),
            timestamp);
        variation = field.getDeclination();
      } 
 
     
    public void onLocationChanged(Location location) {
		super.onLocationChanged(location);
/* 
        GeoPoint point = new GeoPoint( 
                (int) ((double) location.getLatitude() * E6), 
                (int) ((double) location.getLongitude() * E6)); 
4
CodeRank
This code example shows how to use the following methods:getDeclination
        if (timestamp == 0) {
          // Hack for Samsung phones which don't populate the time field 
          timestamp = System.currentTimeMillis();
        } 
 
        GeomagneticField field = new GeomagneticField(
            (float) location.getLatitude(),
            (float) location.getLongitude(),
            (float) location.getAltitude(),
            timestamp);
        variation = field.getDeclination();
      } 
 
     
    public void onLocationChanged(Location location) {
		super.onLocationChanged(location);
/* 
        GeoPoint point = new GeoPoint( 
                (int) ((double) location.getLatitude() * E6), 
                (int) ((double) location.getLongitude() * E6)); 
4
CodeRank
This code example shows how to use the following methods:getDeclination
        if (timestamp == 0) {
          // Hack for Samsung phones which don't populate the time field 
          timestamp = System.currentTimeMillis();
        } 
 
        GeomagneticField field = new GeomagneticField(
            (float) location.getLatitude(),
            (float) location.getLongitude(),
            (float) location.getAltitude(),
            timestamp);
        variation = field.getDeclination();
      } 
 
     
    public void onLocationChanged(Location location) {
		super.onLocationChanged(location);
/* 
        GeoPoint point = new GeoPoint( 
                (int) ((double) location.getLatitude() * E6), 
                (int) ((double) location.getLongitude() * E6)); 
4
CodeRank
This code example shows how to use the following methods:getDeclination
        if (timestamp == 0) {
          // Hack for Samsung phones which don't populate the time field 
          timestamp = System.currentTimeMillis();
        } 
 
        GeomagneticField field = new GeomagneticField(
            (float) location.getLatitude(),
            (float) location.getLongitude(),
            (float) location.getAltitude(),
            timestamp);
        variation = field.getDeclination();
      } 
 
     
    public void onLocationChanged(Location location) {
		super.onLocationChanged(location);
/* 
        GeoPoint point = new GeoPoint( 
                (int) ((double) location.getLatitude() * E6), 
                (int) ((double) location.getLongitude() * E6)); 
4
CodeRank

Related Android GeomagneticField Questions & Answers:

See Code Examples for Android GeomagneticField Methods: