Macdonald formula for spherical functions on affine buildings