Example usage for android.location Location removeAltitude

List of usage examples for android.location Location removeAltitude

Introduction

In this page you can find the example usage for android.location Location removeAltitude.

Prototype

@Deprecated
public void removeAltitude() 

Source Link

Document

Remove the altitude from this location.

Usage

From source file:com.crearo.gpslogger.GpsLoggingService.java

private void adjustAltitude(Location loc) {

    if (!loc.hasAltitude()) {
        return;/*from  ww w . j av a  2s .  c om*/
    }

    if (preferenceHelper.shouldAdjustAltitudeFromGeoIdHeight() && loc.getExtras() != null) {
        String geoidheight = loc.getExtras().getString("GEOIDHEIGHT");
        if (!Strings.isNullOrEmpty(geoidheight)) {
            loc.setAltitude((float) loc.getAltitude() - Float.valueOf(geoidheight));
        } else {
            //If geoid height not present for adjustment, don't record an elevation at all.
            loc.removeAltitude();
        }
    }

    if (loc.hasAltitude()) {
        loc.setAltitude(loc.getAltitude() - preferenceHelper.getSubtractAltitudeOffset());
    }
}

From source file:com.mjhram.geodata.GpsLoggingService.java

private void AdjustAltitude(Location loc) {

    if (!loc.hasAltitude()) {
        return;/*from   w w  w.j  ava 2  s  .  c om*/
    }

    if (AppSettings.shouldAdjustAltitudeFromGeoIdHeight() && loc.getExtras() != null) {
        String geoidheight = loc.getExtras().getString("GEOIDHEIGHT");
        if (!Utilities.IsNullOrEmpty(geoidheight)) {
            loc.setAltitude((float) loc.getAltitude() - Float.valueOf(geoidheight));
        } else {
            //If geoid height not present for adjustment, don't record an elevation at all.
            loc.removeAltitude();
        }
    }

    if (loc.hasAltitude()) {
        loc.setAltitude(loc.getAltitude() - AppSettings.getSubtractAltitudeOffset());
    }
}

From source file:org.spontaneous.trackservice.RemoteService.java

/**
 * Some GPS waypoints received are of to low a quality for tracking use. Here we filter those out.
 *
 * @param proposedLocation//  w  ww  .  j a v  a  2  s.c  om
 * @return either the (cleaned) original or null when unacceptable
 */
// TODO: Diese Methode auslagern und auch in StartFragment verwenden
public Location locationFilter(Location proposedLocation) {

    // Do no include log wrong 0.0 lat 0.0 long, skip to next value in while-loop
    if (proposedLocation != null
            && (proposedLocation.getLatitude() == 0.0d || proposedLocation.getLongitude() == 0.0d)) {
        Log.w(TAG, "A wrong location was received, 0.0 latitude and 0.0 longitude... ");
        proposedLocation = null;
    }

    // Do not log a waypoint which is more inaccurate then is configured to be acceptable
    if (proposedLocation != null && proposedLocation.getAccuracy() > this.mMaxAcceptableAccuracy) {
        Log.w(TAG, String.format("A weak location was received, lots of inaccuracy... (%f is more then max %f)",
                proposedLocation.getAccuracy(), this.mMaxAcceptableAccuracy));
        proposedLocation = addBadLocation(proposedLocation);
    }

    // Do not log a waypoint which might be on any side of the previous waypoint
    if (proposedLocation != null && this.mPreviousLocation != null
            && proposedLocation.getAccuracy() > this.mPreviousLocation.distanceTo(proposedLocation)) {
        Log.w(TAG, String.format(
                "A weak location was received, not quite clear from the previous waypoint... (%f more then max %f)",
                proposedLocation.getAccuracy(), this.mPreviousLocation.distanceTo(proposedLocation)));
        proposedLocation = addBadLocation(proposedLocation);
    }

    // Speed checks, check if the proposed location could be reached from the previous one in sane speed
    // Common to jump on network logging and sometimes jumps on Samsung Galaxy S type of devices
    if (this.mSpeedSanityCheck && proposedLocation != null && this.mPreviousLocation != null) {
        // To avoid near instant teleportation on network location or glitches cause continent hopping
        float meters = proposedLocation.distanceTo(this.mPreviousLocation);
        long seconds = (proposedLocation.getTime() - this.mPreviousLocation.getTime()) / 1000L;
        float speed = meters / seconds;
        if (speed > MAX_REASONABLE_SPEED) {
            Log.w(TAG,
                    "A strange location was received, a really high speed of " + speed + " m/s, prob wrong...");
            proposedLocation = addBadLocation(proposedLocation);
            // Might be a messed up Samsung Galaxy S GPS, reset the logging
            if (speed > 2 * MAX_REASONABLE_SPEED
                    && this.mPrecision != TrackingServiceConstants.LOGGING_GLOBAL) {
                Log.w(TAG, "A strange location was received on GPS, reset the GPS listeners");
                stopListening();
                // mLocationManager.removeGpsStatusListener(mStatusListener);
                this.mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
                // sendRequestStatusUpdateMessage();
                // sendRequestLocationUpdatesMessage();
            }
        }
    }

    // Remove speed if not sane
    if (this.mSpeedSanityCheck && proposedLocation != null
            && proposedLocation.getSpeed() > MAX_REASONABLE_SPEED) {
        Log.w(TAG, "A strange speed, a really high speed, prob wrong...");
        proposedLocation.removeSpeed();
    }

    // Remove altitude if not sane
    if (this.mSpeedSanityCheck && proposedLocation != null && proposedLocation.hasAltitude()) {
        if (!addSaneAltitude(proposedLocation.getAltitude())) {
            Log.w(TAG, "A strange altitude, a really big difference, prob wrong...");
            proposedLocation.removeAltitude();
        }
    }
    // Older bad locations will not be needed
    if (proposedLocation != null) {
        this.mWeakLocations.clear();
    }
    return proposedLocation;
}