def _create_approx_distance_filter(self, field_name, location, radius): geohash_length = geohash_length_for_error(radius.kilometers) geohash = convert_to_point(location).geohash.trim(geohash_length) expanded = geohash.expand() filters = models.Q() for item in expanded: filters.add(models.Q(**{"%s__startswith" % field_name: item}), models.Q.OR) return filters
def test_error_size_calculation(self): self.assertEqual(geohash_length_for_error(2.0), 5)