def test_geospatial_positive_query_with_point_outside_aerocircle(self): """ Perform a positive geospatial query for a point in aerocircle """ if TestGeospatial.skip_old_server is True: pytest.skip( "Server does not support apply on AeroCircle for GeoJSON") records = [] query = self.as_connection.query("test", "demo") geo_object2 = aerospike.GeoJSON({ "type": "Point", "coordinates": [-122.000000, 450.200] }) query.where( p.geo_contains_geojson_point("loc_circle", geo_object2.dumps())) def callback(input_tuple): _, _, record = input_tuple records.append(record) query.foreach(callback) assert len(records) == 0
def test_geospatial_positive_query_with_point(self): """ Perform a positive geospatial query for a point """ records = [] query = self.as_connection.query("test", "demo") geo_object2 = aerospike.GeoJSON({ "type": "Point", "coordinates": [-121.700000, 37.200000] }) query.where( p.geo_contains_geojson_point("loc_polygon", geo_object2.dumps())) def callback(input_tuple): _, _, record = input_tuple records.append(record) query.foreach(callback) assert len(records) == 1 expected = [{ 'coordinates': [[[-122.500000, 37.000000], [-121.000000, 37.000000], [-121.000000, 38.080000], [-122.500000, 38.080000], [-122.500000, 37.000000]]], 'type': 'Polygon' }] for r in records: assert r['loc_polygon'].unwrap() in expected
def test_geospatial_positive_query_with_point_in_aerocircle_int(self): """ Perform a positive geospatial query for a point in aerocircle """ if TestGeospatial.skip_old_server is True: pytest.skip( "Server does not support apply on AeroCircle for GeoJSON") records = [] query = self.as_connection.query("test", "demo") geo_object2 = aerospike.GeoJSON({ "type": "Point", "coordinates": [-122, 37] }) query.where( p.geo_contains_geojson_point("loc_circle", geo_object2.dumps())) def callback(input_tuple): _, _, record = input_tuple records.append(record) query.foreach(callback) assert len(records) == 1 expected = [{ 'coordinates': [[-122.0, 37.0], 250.2], 'type': 'AeroCircle' }] for r in records: assert r['loc_circle'].unwrap() in expected
def test_geospatial_positive_query_with_point_in_aerocircle_int(self): """ Perform a positive geospatial query for a point in aerocircle """ if TestGeospatial.skip_old_server is True: pytest.skip( "Server does not support apply on AeroCircle for GeoJSON") records = [] query = self.as_connection.query("test", "demo") geo_object2 = aerospike.GeoJSON({"type": "Point", "coordinates": [-122, 37]}) query.where( p.geo_contains_geojson_point("loc_circle", geo_object2.dumps())) def callback(input_tuple): _, _, record = input_tuple records.append(record) query.foreach(callback) assert len(records) == 1 expected = [ {'coordinates': [[-122.0, 37.0], 250.2], 'type': 'AeroCircle'}] for r in records: assert r['loc_circle'].unwrap() in expected
def test_geospatial_positive_query_with_point(self): """ Perform a positive geospatial query for a point """ records = [] query = self.as_connection.query("test", "demo") geo_object2 = aerospike.GeoJSON({"type": "Point", "coordinates": [-121.700000, 37.200000]}) query.where( p.geo_contains_geojson_point("loc_polygon", geo_object2.dumps())) def callback(input_tuple): _, _, record = input_tuple records.append(record) query.foreach(callback) assert len(records) == 1 expected = [{'coordinates': [[[-122.500000, 37.000000], [-121.000000, 37.000000], [-121.000000, 38.080000], [-122.500000, 38.080000], [-122.500000, 37.000000]]], 'type': 'Polygon'}] for r in records: assert r['loc_polygon'].unwrap() in expected
def test_geospatial_positive_query_with_point_outside_polygon(self): """ Perform a positive geospatial query for a point outside polygon """ records = [] query = TestGeospatial.client.query("test", "demo") geo_object2 = aerospike.GeoJSON({"type": "Point", "coordinates": [-123.700000, 37.200000]}) query.where(p.geo_contains_geojson_point("loc_polygon", geo_object2.dumps())) def callback((key, metadata, record)): records.append(record) query.foreach(callback) assert len(records) == 0
def test_geospatial_contains_json_point_pred(self, bin_name, idx_type): records = [] query = self.as_connection.query("test", "demo") lat = -122.45 lon = 37.5 point_list = [lat, lon] point = aerospike.GeoJSON({'type': "Point", 'coordinates': point_list}) predicate = p.geo_contains_geojson_point(bin_name, point.dumps(), idx_type) def callback(input_tuple): _, _, record = input_tuple records.append(record) query.where(predicate) query.foreach(callback) assert len(records) == 1
def test_geospatial_positive_query_with_point_outside_aerocircle(self): """ Perform a positive geospatial query for a point in aerocircle """ if TestGeospatial.skip_old_server == True: pytest.skip("Server does not support apply on AeroCircle for GeoJSON") records = [] query = TestGeospatial.client.query("test", "demo") geo_object2 = aerospike.GeoJSON({"type": "Point", "coordinates": [-122.000000, 450.200]}) query.where(p.geo_contains_geojson_point("loc_circle", geo_object2.dumps())) def callback((key, metadata, record)): records.append(record) query.foreach(callback) assert len(records) == 0
def test_geospatial_contains_json_point_pred(self, bin_name, idx_type): records = [] query = self.as_connection.query("test", "demo") lat = -122.45 lon = 37.5 point_list = [lat, lon] point = aerospike.GeoJSON({'type': "Point", 'coordinates': point_list}) predicate = p.geo_contains_geojson_point( bin_name, point.dumps(), idx_type) def callback(input_tuple): _, _, record = input_tuple records.append(record) query.where(predicate) query.foreach(callback) assert len(records) == 1