distances function

Computes distance between pairs of locations