Ptolemaic metric spaces and the characterization of geodesics by vanishing metric curvature