function snap_to_road(gps_point, road_segments):

   return argmin(road_segments, key=lambda segment: distance(gps_point, segment))
 # raw GPS is noisy; map matching finds the most plausible road the device is actual
 ly on
