def test_geospatial_loads_positive_with_query(self):
        """
            Perform a positive loads on geoJSON raw string followed by a query
        """
        geo_object_loads = aerospike.GeoJSON({"type": "Polygon", "coordinates": [[[-124.500000,
    37.000000],[-125.000000, 37.000000], [-121.000000, 38.080000],[-122.500000,
        38.080000], [-124.500000, 37.000000]]]})

        geo_object_loads.loads('{"type": "Polygon", "coordinates": [[[-122.500000, 37.000000], [-121.000000, 37.000000], [-121.000000, 38.080000],[-122.500000, 38.080000], [-122.500000, 37.000000]]]}')

        assert geo_object_loads.unwrap() == {'coordinates': [[[-122.5, 37.0], [-121.0, 37.0], [-121.0, 38.08],
            [-122.5, 38.08], [-122.5, 37.0]]], 'type': 'Polygon'}

	records = []
        query = TestGeospatial.client.query("test", "demo")
        query.where(p.within("loc", geo_object_loads.dumps()))

        def callback((key, metadata, record)):
            records.append(record)

        query.foreach(callback)

        assert len(records) == 3
        assert records == [{'loc': {'coordinates': [-122.0, 37.5], 'type': 'Point'}}, {'loc': {'coordinates': [-121.8, 37.7], 'type':
                'Point'}}, {'loc': {'coordinates': [-121.6, 37.9], 'type': 'Point'}}]
    def test_geospatial_positive_query_without_set(self):
        """
            Perform a positive geospatial query for a polygon without a set
        """
        keys = []
        for i in xrange(1, 10):
            key = ('test', None, i)
            lng = -122 + (0.2 * i)
            lat = 37.5 + (0.2 * i)
            geo_object = aerospike.GeoJSON({"type": "Point", "coordinates": [lng, lat] })
    
            TestGeospatial.client.put(key, {"loc": geo_object})
            keys.append(key)

        TestGeospatial.client.index_geo2dsphere_create("test", None, "loc", "loc_index_no_set")
        records = []
        query = TestGeospatial.client.query("test", None)

        geo_object2 = aerospike.GeoJSON({"type": "Polygon", "coordinates": [[[-122.500000,
    37.000000],[-121.000000, 37.000000], [-121.000000, 38.080000],[-122.500000,
        38.080000], [-122.500000, 37.000000]]]})

        query.where(p.within("loc", geo_object2.dumps()))

        def callback((key, metadata, record)):
            records.append(record)

        query.foreach(callback)

        TestGeospatial.client.index_remove('test', 'loc_index_no_set')
        for key in keys:
            TestGeospatial.client.remove(key)

        assert len(records) == 2
        assert records == [{'loc': {'coordinates': [-121.8, 37.7], 'type': 'Point'}}, {'loc': {'coordinates': [-121.6, 37.9], 'type': 'Point'}}]
    def test_geospatial_positive_query_for_circle(self):
        """
            Perform a positive geospatial query for a circle
        """
        records = []
        query = TestGeospatial.client.query("test", "demo")

        geo_object2 = aerospike.GeoJSON({"type": "Circle", "coordinates": [[-122.0, 37.5], 250.2]})

        query.where(p.within("loc", geo_object2.dumps()))

        def callback((key, metadata, record)):
            records.append(record)

        query.foreach(callback)

        assert len(records) == 1
        assert records == [{'loc': {'coordinates': [-122.0, 37.5], 'type': 'Point'}}]
    def test_geospatial_positive_query_outside_shape(self):
        """
            Perform a positive geospatial query for polygon where all points are
            outside polygon
        """
        records = []
        query = TestGeospatial.client.query("test", "demo")

        geo_object2 = aerospike.GeoJSON({"type": "Polygon", "coordinates": [[[-126.500000,
    37.000000],[-124.000000, 37.000000], [-124.000000, 38.080000],[-126.500000,
        38.080000], [-126.500000, 37.000000]]]})

        query.where(p.within("loc", geo_object2.dumps()))

        def callback((key, metadata, record)):
            records.append(record)

        query.foreach(callback)

        assert len(records) == 0
    def test_geospatial_positive_query(self):
        """
            Perform a positive geospatial query for a polygon
        """
        records = []
        query = TestGeospatial.client.query("test", "demo")

        geo_object2 = aerospike.GeoJSON({"type": "Polygon", "coordinates": [[[-122.500000,
    37.000000],[-121.000000, 37.000000], [-121.000000, 38.080000],[-122.500000,
        38.080000], [-122.500000, 37.000000]]]})

        query.where(p.within("loc", geo_object2.dumps()))

        def callback((key, metadata, record)):
            records.append(record)

        query.foreach(callback)

        assert len(records) == 3
        assert records == [{'loc': {'coordinates': [-122.0, 37.5], 'type': 'Point'}}, {'loc': {'coordinates': [-121.8, 37.7], 'type':
                'Point'}}, {'loc': {'coordinates': [-121.6, 37.9], 'type': 'Point'}}]