def fetch(x_beg, x_end, y_beg, y_end, time_bin): global Point_RDD global coordinate_cache global DEFAULT_CACHE_SIZE filtered = filter(lambda pr: x_end > pr[0] > x_beg and y_end > pr[1] > y_beg, coordinate_cache) visible_area = area(x_beg, x_end, y_beg, y_end) s_area = sample_area(filtered) if s_area < visible_area/20: print "zooming out" print len(filtered) if len(filtered) < SAMPLE_SIZE or s_area <= visible_area/20: filtered_RDD = Point_RDD.filter(lambda pr: x_end > pr[0] > x_beg and y_end > pr[1] > y_beg) coordinate_cache = filtered_RDD.takeSample(False, DEFAULT_CACHE_SIZE) if len(coordinate_cache) < DEFAULT_CACHE_SIZE: flag_limit_reached = True filtered = filter(lambda pr: x_end > pr[0] > x_beg and y_end > pr[1] > y_beg, coordinate_cache) print len(filtered) return Sampling.sample_unzip(filtered, SAMPLE_SIZE)
def get_current(): sample_array = Sampling.sample_unzip(coordinate_cache, SAMPLE_SIZE) return sample_array