Android Distance Calculate computeSpeed(int distance, long duration)

Here you can find the source of computeSpeed(int distance, long duration)

Description

Computes the average speed in km/h.

Parameter

Parameter Description
distance distance in meters
duration duration in milliseconds

Return

speed in km/h

Declaration

public static double computeSpeed(int distance, long duration) 

Method Source Code

//package com.java2s;

import org.joda.time.DateTimeConstants;

public class Main {
    /**/*w  w  w.ja  v  a2  s .  c  om*/
     * Computes the average speed in km/h.
     * 
     * @param distance distance in meters
     * @param duration duration in milliseconds
     * @return speed in km/h
     */
    public static double computeSpeed(int distance, long duration) {
        return ((double) distance / 1000)
                / ((double) duration / DateTimeConstants.MILLIS_PER_HOUR);
    }
}

Related

  1. hammingDistance(String sourceHashCode, String hashCode)
  2. getMessageForDistance(long distance)
  3. calculateEte(boolean useBearing, double distance, double speed, double bearing, double heading)
  4. fetchRawEte(boolean useBearing, double distance, double speed, double bearing, double heading)
  5. distance(double lat1, double lon1, double lat2, double lon2, char unit)
  6. getClosestStore(ArrayList storeIds, SparseArray distanceMap)
  7. toDistanceSearchUri(Uri contentUri, Location location, double distance)
  8. getDisplay(Activity activity)