Ejemplo n.º 1
0
 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
Ejemplo n.º 2
0
 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
Ejemplo n.º 3
0
 def test_error_size_calculation(self):
     self.assertEqual(geohash_length_for_error(2.0), 5)
Ejemplo n.º 4
0
 def test_error_size_calculation(self):
     self.assertEqual(geohash_length_for_error(2.0), 5)