List of usage examples for android.location Location removeSpeed
@Deprecated public void removeSpeed()
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/* www .ja v a 2s.c o m*/ * @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; }