Latent distance estimation for random geometric graphs