public static double computeLength ( List < IGeoPoint > path ) { if ( path . size ( ) < 2 ) { return 0 ; } double length = 0 ; IGeoPoint prev = path . get ( 0 ) ; double prevLat = toRadians ( prev . getLatitude ( ) ) ; double prevLng = toRadians ( prev . getLongitude ( ) ) ; for ( IGeoPoint point : path ) { double lat = toRadians ( point . getLatitude ( ) ) ; double lng = toRadians ( point . getLongitude ( ) ) ; length += distanceRadians ( prevLat , prevLng , lat , lng ) ; prevLat = lat ; prevLng = lng ; } return length * EARTH_RADIUS ; }
Returns the length of the given path in meters on Earth .