public LocationAssert hasSpeed(float speed) { isNotNull(); float actualSpeed = actual.getSpeed(); assertThat(actualSpeed) // .overridingErrorMessage("Expected speed <%s> but was <%s>.", speed, actualSpeed) // .isEqualTo(speed); return this; }
coordinates.put(PARAM_SPEED, location.getSpeed());
private Location copyOf(Location location) { if (location == null) return null; Location copy = new Location(location); copy.setAccuracy(location.getAccuracy()); copy.setAltitude(location.getAltitude()); copy.setBearing(location.getBearing()); copy.setExtras(location.getExtras()); copy.setLatitude(location.getLatitude()); copy.setLongitude(location.getLongitude()); copy.setProvider(location.getProvider()); copy.setSpeed(location.getSpeed()); copy.setTime(location.getTime()); return copy; }
public class LocationListener implements LocationListener { @Override public void onLocationChanged(Location location) { float speed = location.getSpeed(); } }
int updateCount=0; float totalSpeedSum=0.0f; float avgSpeed=0.0f; public void onLocationChanged(Location location) { Location lastLocation = getLastLocation(); // speed in m/sec float curSpeed=location.getSpeed(); updateCount++; totalSpeedSum=totalSpeedSum+curSpeed; avgSpeed=totalSpeedSum/updateCount; }
/** * Returns the current speed * * @return the current speed (if detected) or `0` */ public float getSpeed() { if (mPosition == null) { return 0.0f; } else { return mPosition.getSpeed(); } }
/** * Returns the current speed * * @return the current speed (if detected) or `0` */ public float getSpeed() { if (mPosition == null) { return 0.0f; } else { return mPosition.getSpeed(); } }
public Double getSpeed() { if (location == null) return null; return (double) this.location.getSpeed(); }
public void onLocationChanged(Location location) { double speed=location.getSpeed(); // update code for getting location (la & ln ) }
private Float nMaxSpeed = 0F; @Override public void onLocationChanged(Location location) { TextView tv = (TextView) findViewById(R.id.textView1); if (location == null) { // do something } else { nCurrentSpeed = location.getSpeed(); if(nMaxSpeed < nCurrentSpeed) { nMaxSpeed = nCurrentSpeed; } } tv.setText(nMaxSpeed.toString()); }
private void updateTripStats( final Location newLocation) { final float spdConvert = 2.2369f; // Stats should only be updated if accuracy is decent if (newLocation.getAccuracy() > 20) return; // Speed data is sometimes awful, too: curSpeedMph_ = newLocation.getSpeed() * spdConvert; }
/** * Formats the speed in knots from the #Location into a string. * If the speed is unknown, it returns an empty string. */ public static String formatSpeedKt(Location location) { String s = ""; if (location.hasSpeed()) // http://www.google.com/search?q=m%2Fs+to+kt s += (location.getSpeed() * 1.94384449); return s; }
public void onLocationChanged(Location location) { if(location.getAccuracy() < 100.0 && location.getSpeed() < 6.95){ //Do something } else{ //Continue listening for a more accurate location } }
public void onLocationChanged(Location location) { if(location.getAccuracy() < 100.0 && location.getSpeed() < 6.95){ //Do something } else{ //Continue listening for a more accurate location }
private String speed() { final Location location = lastLocation(); if (location == null) return "0.0"; return formatter_.speed(location.getSpeed()); }
public void calcTimeSaved() { if (prevLimitTime == 0 //Limit data not available yet || prevLocation == null //Less than 2 speed data points have been captured || limit == null || limit == 0) return; //Avoiding divide by zero double currentDiff = ((location.getElapsedRealtimeNanos() - prevLocation.getElapsedRealtimeNanos()) * (location.getSpeed() - limit)) / limit; if (currentDiff > 0) timeSaved += currentDiff; } }
public boolean isUsable(Location location) { return location!=null && location.hasAccuracy() && location.getAccuracy() < 800 && location.getSpeed() > 0; }
public LocationAssert hasSpeed(float speed) { isNotNull(); float actualSpeed = actual.getSpeed(); assertThat(actualSpeed) // .overridingErrorMessage("Expected speed <%s> but was <%s>.", speed, actualSpeed) // .isEqualTo(speed); return this; }
@Override public void onLocationChanged(final Location location) { double systemTimestamp = System.currentTimeMillis() / 1e3d - mStartTime; if (mListener == null) { return; } mListener.onNewValues(systemTimestamp, location.getTime() / 1e3d - mStartTime, new Object[]{location.getLatitude(), location.getLongitude(), location.getAltitude(), location.getBearing(), location.getAccuracy(), location.getSpeed()}); }
@Override public void onLocationChanged(Location location) { altitude = location.getAltitude(); heading = location.getBearing(); speed = location.getSpeed(); handleMessage(new SimpleVehicleMessage("phone_altitude", altitude)); handleMessage(new SimpleVehicleMessage("phone_heading", heading)); handleMessage(new SimpleVehicleMessage("phone_speed", speed)); } }