def test_spherical_geospatial_operators(self):
        # Needs MongoDB > 2.6.4 https://jira.mongodb.org/browse/SERVER-14039
        connection = get_connection()
        info = connection.test.command('buildInfo')
        mongodb_version = tuple([int(i) for i in info['version'].split('.')])
        if mongodb_version < (2, 6, 4):
            raise SkipTest("Need MongoDB version 2.6.4+")

        class Point(Document):
            location = GeoPointField()

        Point.drop_collection()

        # These points are one degree apart, which (according to Google Maps)
        # is about 110 km apart at this place on the Earth.
        north_point = Point(location=[-122, 38]).save()  # Near Concord, CA
        south_point = Point(location=[-122, 37]).save()  # Near Santa Cruz, CA

        earth_radius = 6378.009  # in km (needs to be a float for dividing by)

        # Finds both points because they are within 60 km of the reference
        # point equidistant between them.
        points = Point.objects(location__near_sphere=[-122, 37.5])
        self.assertEqual(points.count(), 2)

        # Same behavior for _within_spherical_distance
        points = Point.objects(
            location__within_spherical_distance=[[-122, 37.5], 60 / earth_radius]
        )
        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)

        # Test query works with max_distance, being farer from one point
        points = Point.objects(location__near_sphere=[-122, 37.8],
                               location__max_distance=60 / earth_radius)
        close_point = points.first()
        self.assertEqual(points.count(), 1)

        # Test query works with min_distance, being farer from one point
        points = Point.objects(location__near_sphere=[-122, 37.8],
                               location__min_distance=60 / earth_radius)
        # The following real test passes on MongoDB 3 but minDistance seems
        # buggy on older MongoDB versions
        if get_connection().server_info()['versionArray'][0] > 2:
            self.assertEqual(points.count(), 1)
            far_point = points.first()
            self.assertNotEqual(close_point, far_point)
        else:
            self.assertTrue(points.count() >= 1)

        # 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])
        self.assertEqual(points.count(), 2)
        self.assertEqual(points[0].id, north_point.id)
        self.assertEqual(points[1].id, south_point.id)

        # Finds both points, but orders the south point first because it's
        # closer to the reference point to the south.
        points = Point.objects(location__near_sphere=[-122, 36.5])
        self.assertEqual(points.count(), 2)
        self.assertEqual(points[0].id, south_point.id)
        self.assertEqual(points[1].id, north_point.id)

        # Finds only one point because only the first point is within 60km of
        # the reference point to the south.
        points = Point.objects(
            location__within_spherical_distance=[[-122, 36.5], 60/earth_radius])
        self.assertEqual(points.count(), 1)
        self.assertEqual(points[0].id, south_point.id)
Get inband tag
dataset/ETHPy150Open MongoEngine/mongoengine/tests/queryset/geo.py/GeoQueriesTest.test_spherical_geospatial_operators--crossover with--dataset/ETHPy150Open sysdream/pysqli/pysqli/core/context.py/Context.get_inband_tag