Stable matchings in metric spaces