Example usage for android.location Location removeBearing

List of usage examples for android.location Location removeBearing

Introduction

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

Prototype

@Deprecated
public void removeBearing() 

Source Link

Document

Remove the bearing from this location.

Usage

From source file:eu.basicairdata.graziano.gpslogger.GPSApplication.java

@Override
public void onLocationChanged(Location loc) {
    //if ((loc != null) && (loc.getProvider().equals(LocationManager.GPS_PROVIDER)) {
    if (loc != null) { // Location data is valid
        //Log.w("myApp", "[#] GPSApplication.java - onLocationChanged: provider=" + loc.getProvider());
        if (loc.hasSpeed() && (loc.getSpeed() == 0))
            loc.removeBearing(); // Removes bearing if the speed is zero
        LocationExtended eloc = new LocationExtended(loc);
        eloc.setNumberOfSatellites(getNumberOfSatellites());
        eloc.setNumberOfSatellitesUsedInFix(getNumberOfSatellitesUsedInFix());
        boolean ForceRecord = false;

        gpsunavailablehandler.removeCallbacks(unavailr); // Cancel the previous unavail countdown handler
        gpsunavailablehandler.postDelayed(unavailr, GPSUNAVAILABLEHANDLERTIMER); // starts the unavailability timeout (in 7 sec.)

        if (GPSStatus != GPS_OK) {
            if (GPSStatus != GPS_STABILIZING) {
                GPSStatus = GPS_STABILIZING;
                _Stabilizer = StabilizingSamples;
                EventBus.getDefault().post(EventBusMSG.UPDATE_FIX);
            } else
                _Stabilizer--;/*from  w ww . j  a v  a  2 s  .  c o m*/
            if (_Stabilizer == 0)
                GPSStatus = GPS_OK;
            PrevFix = eloc;
            PrevRecordedFix = eloc;
            isPrevFixRecorded = true;
        }

        // Save fix in case this is a STOP or a START (the speed is "old>0 and new=0" or "old=0 and new>0")
        if ((PrevFix != null) && (PrevFix.getLocation().hasSpeed()) && (eloc.getLocation().hasSpeed())
                && (GPSStatus == GPS_OK) && (Recording)
                && (((eloc.getLocation().getSpeed() == 0) && (PrevFix.getLocation().getSpeed() != 0))
                        || ((eloc.getLocation().getSpeed() != 0) && (PrevFix.getLocation().getSpeed() == 0)))) {
            if (!isPrevFixRecorded) { // Record the old sample if not already recorded
                AsyncTODO ast = new AsyncTODO();
                ast.TaskType = "TASK_ADDLOCATION";
                ast.location = PrevFix;
                AsyncTODOQueue.add(ast);
                PrevRecordedFix = PrevFix;
                isPrevFixRecorded = true;
            }

            ForceRecord = true; // + Force to record the new
        }

        if (GPSStatus == GPS_OK) {
            AsyncTODO ast = new AsyncTODO();
            if ((Recording) && ((prefGPSdistance == 0) || (PrevRecordedFix == null) || (ForceRecord)
                    || (loc.distanceTo(PrevRecordedFix.getLocation()) >= prefGPSdistance))) {
                PrevRecordedFix = eloc;
                ast.TaskType = "TASK_ADDLOCATION";
                ast.location = eloc;
                AsyncTODOQueue.add(ast);
                isPrevFixRecorded = true;
            } else {
                ast.TaskType = "TASK_UPDATEFIX";
                ast.location = eloc;
                AsyncTODOQueue.add(ast);
                isPrevFixRecorded = false;
            }

            if (PlacemarkRequest) {
                _currentPlacemark = new LocationExtended(loc);
                _currentPlacemark.setNumberOfSatellites(getNumberOfSatellites());
                _currentPlacemark.setNumberOfSatellitesUsedInFix(getNumberOfSatellitesUsedInFix());
                PlacemarkRequest = false;
                EventBus.getDefault().post(EventBusMSG.UPDATE_TRACK);
                EventBus.getDefault().post(EventBusMSG.REQUEST_ADD_PLACEMARK);
            }
            PrevFix = eloc;
        }
    }
}