@classmethod
  def query(self, time, dow, lat, lon, max_results, min_params):
    """Queries for Muni stops repeatedly until max results or scope is reached.
    Args:
      system: The transit system to query.
      lat, lon: Coordinates of the agent querying.
      max_results: Maximum number of stops to find.
      min_params: Tuple (resolution, slice) of the minimum resolution to allow.

    Returns:
      List of (distance, MuniStop) tuples, ordered by minimum distance first.
      There will be no duplicates in these results. Distance is in meters.
    """
    # Maps stop_ids to MuniStop instances.
    found_stores = {}

    # Do concentric queries until the max number of results is reached.
    dow_query_string = _DAY_DICTIONARY[dow] + ' ='
    for params in GEOBOX_CONFIGS:
      if len(found_stores) >= max_results:
        break
      if params < min_params:
        break

      resolution, slice, unused = params
      box = geobox.compute(lat, lon, resolution, slice)
      logging.info("Searching for box=%s at resolution=%s, slice=%s",
                    box, resolution, slice)
      query = self.all().filter("geoboxes =", box).filter(dow_query_string, time)
      results = query.fetch(50)
      logging.info("Found %d results", len(results))

      # De-dupe results.
      for result in results:
        if result.name not in found_stores:
          found_stores[result.name] = result

    # Now compute distances and sort by distance.
    stores_by_distance = []
    for store in found_stores.itervalues():
      distance = _earth_distance(lat, lon, store.location.lat, store.location.lon)
      stores_by_distance.append((distance, store))
    stores_by_distance.sort()

    return stores_by_distance
dataset/ETHPy150Open googlearchive/appengine-24hrsinsf-python/models.py/Store.query/original