79
81
final double n = Math.PI - ((2.0 * Math.PI * y) / Math.pow(2.0, aZoom));
80
82
return 180.0 / Math.PI * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n)));
86
* Checks to see if this is a valid speed.
88
* @param updateTime The time at the current reading
89
* @param speed The current speed
90
* @param lastLocationTime The time at the last location
91
* @param lastLocationSpeed Speed at the last location
92
* @param speedBuffer A buffer of recent readings
93
* @return True if this is likely a valid speed
95
public static boolean isValidSpeed(long updateTime, double speed,
96
long lastLocationTime, double lastLocationSpeed
99
// We don't want to count 0 towards the speed.
104
// We are now sure the user is moving.
105
long timeDifference = updateTime - lastLocationTime;
107
// There are a lot of noisy speed readings.
108
// Do the cheapest checks first, most expensive last.
109
// The following code will ignore unlikely to be real readings.
110
// - 128 m/s seems to be an internal android error code.
111
if (Math.abs(speed - 128) < 1) {
115
// Another check for a spurious reading. See if the path seems physically
116
// likely. Ignore any speeds that imply accelaration greater than 2g's
117
// Really who can accelerate faster?
118
double speedDifference = Math.abs(lastLocationSpeed - speed);
119
if (speedDifference > OpenSatNavConstants.MAX_ACCELERATION * timeDifference) {
83
126
// ===========================================================
84
127
// Inner and Anonymous Classes