code: def get_stops(records, group_dist):
      
      def traverse(start, next):
          position_prev = records[next - 1].position.location
          position_next = records[next].position.location
          dist = 1000 * great_circle_distance(position_prev, position_next)
          return dist <= group_dist
  
      groups = _groupwhile(records, traverse)
  
      def median(x):
          return sorted(x)[len(x) // 2]
  
      stops = []
      for g in groups:
          _lat = median([gv.position.location[0] for gv in g])
          _lon = median([gv.position.location[1] for gv in g])
          stops.append({
              'location': (_lat, _lon),
              'records': g,
          })
  
      return stops
docs: Group records arounds stop locations and returns a list of
      dict(location, records) for each stop.
  
      Parameters
      ----------
      records : list
          A list of Record objects ordered by non-decreasing datetime
      group_dist : float
          Minimum distance (in meters) to switch to a new stop.