def test_cql_filter(): data = bcdata.get_data( AIRPORTS_TABLE, query="AIRPORT_NAME='Terrace (Northwest Regional) Airport'") assert len(data["features"]) == 1 assert (data["features"][0]["properties"]["AIRPORT_NAME"] == "Terrace (Northwest Regional) Airport")
def test_cql_filter(): data = bcdata.get_data( AIRPORTS_KEY, query="AIRPORT_NAME='Terrace (Northwest Regional) Airport'") assert len(data['features']) == 1 assert data['features'][0]['properties'][ 'AIRPORT_NAME'] == 'Terrace (Northwest Regional) Airport'
def dump(dataset, query, out_file, bounds, bounds_crs, verbose, quiet): """Write DataBC features to stdout as GeoJSON feature collection. \b $ bcdata dump bc-airports $ bcdata dump bc-airports --query "AIRPORT_NAME='Victoria Harbour (Shoal Point) Heliport'" $ bcdata dump bc-airports --bounds xmin ymin xmax ymax It can also be combined to read bounds of a feature dataset using Fiona: \b $ bcdata dump bc-airports --bounds $(fio info aoi.shp --bounds) """ verbosity = verbose - quiet configure_logging(verbosity) table = bcdata.validate_name(dataset) data = bcdata.get_data(table, query=query, bounds=bounds, bounds_crs=bounds_crs) if out_file: with open(out_file, "w") as sink: sink.write(json.dumps(data)) else: sink = click.get_text_stream("stdout") sink.write(json.dumps(data))
def test_cql_bounds_filter(): data = bcdata.get_data( AIRPORTS_TABLE, query="AIRPORT_NAME='Victoria International Airport'", bounds=[1167680.0, 367958.0, 1205720.0, 432374.0], bounds_crs="EPSG:3005", ) assert len(data["features"]) == 1 assert (data["features"][0]["properties"]["AIRPORT_NAME"] == "Victoria International Airport")
def dump(dataset, query, out_file, bounds): """Write DataBC features to stdout as GeoJSON feature collection. \b $ bcdata dump bc-airports $ bcdata dump bc-airports --query "AIRPORT_NAME='Victoria Harbour (Shoal Point) Heliport'" $ bcdata dump bc-airports --bounds xmin ymin xmax ymax The values of --bounds must be in BC Albers. It can also be combined to read bounds of a feature dataset using Fiona: \b $ bcdata dump bc-airports --bounds $(fio info aoi.shp --bounds) """ table = bcdata.validate_name(dataset) data = bcdata.get_data(table, query=query, bounds=bounds) if out_file: with open(out_file, "w") as f: json.dump(data.json(), f) else: sink = click.get_text_stream("stdout") sink.write(json.dumps(data))
def test_bounds_filter(): data = bcdata.get_data(AIRPORTS_TABLE, bounds=[1188000, 377051, 1207437, 390361]) assert len(data["features"]) == 8
def test_get_data_paged(): data = bcdata.get_data(AIRPORTS_TABLE, pagesize=250) assert len(data["features"]) == 455
def test_get_data_crs(): data = bcdata.get_data(AIRPORTS_TABLE, crs="EPSG:3005") assert data[ "crs"] == '''{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG::3005"}}'''
def test_get_data_small(): data = bcdata.get_data(AIRPORTS_TABLE) assert data["type"] == "FeatureCollection"
def test_get_data_asgdf(): gdf = bcdata.get_data(UTMZONES_KEY, query="UTM_ZONE=10", as_gdf=True) assert type(gdf) == GeoDataFrame
def test_get_data_paged(): data = bcdata.get_data(AIRPORTS_KEY, pagesize=250) assert len(data['features']) == 455
def test_get_data_small(): data = bcdata.get_data(AIRPORTS_KEY) assert data['type'] == 'FeatureCollection'