Added support for $maxDistance (#179)

This commit is contained in:
Ross Lawley
2013-01-22 13:31:53 +00:00
parent 0b177ec4c1
commit 2c7b12c022
4 changed files with 17 additions and 1 deletions

View File

@@ -2238,6 +2238,12 @@ class QuerySetTest(unittest.TestCase):
self.assertEqual(events.count(), 3)
self.assertEqual(list(events), [event3, event1, event2])
# find events within 10 degrees of san francisco
point = [37.7566023, -122.415579]
events = Event.objects(location__near=point, location__max_distance=10)
self.assertEqual(events.count(), 1)
self.assertEqual(events[0], event2)
# find events within 10 degrees of san francisco
point_and_distance = [[37.7566023, -122.415579], 10]
events = Event.objects(location__within_distance=point_and_distance)
@@ -2317,6 +2323,10 @@ class QuerySetTest(unittest.TestCase):
);
self.assertEqual(points.count(), 2)
points = Point.objects(location__near_sphere=[-122, 37.5],
location__max_distance=60 / earth_radius);
self.assertEqual(points.count(), 2)
# Finds both points, but orders the north point first because it's
# closer to the reference point to the north.
points = Point.objects(location__near_sphere=[-122, 38.5])