66
77import click
88from cligj import compact_opt , indent_opt , quiet_opt , verbose_opt
9- from shapely .geometry .linestring import LineString
10- from shapely .geometry .multilinestring import MultiLineString
11- from shapely .geometry .multipoint import MultiPoint
12- from shapely .geometry .multipolygon import MultiPolygon
13- from shapely .geometry .point import Point
14- from shapely .geometry .polygon import Polygon
159
1610import bcdata
1711from bcdata .database import Database
@@ -27,6 +21,7 @@ def configure_logging(verbosity):
2721def complete_dataset_names (ctx , param , incomplete ):
2822 return [k for k in bcdata .list_tables () if k .startswith (incomplete )]
2923
24+
3025# bounds handling direct from rasterio
3126# https://github.com/mapbox/rasterio/blob/master/rasterio/rio/options.py
3227# https://github.com/mapbox/rasterio/blob/master/rasterio/rio/clip.py
@@ -202,6 +197,13 @@ def dem(
202197 help = "A valid CQL or ECQL query" ,
203198)
204199@click .option ("--out_file" , "-o" , help = "Output file" )
200+ @click .option (
201+ "--count" ,
202+ "-c" ,
203+ default = None ,
204+ type = int ,
205+ help = "Number of features to request and dump" ,
206+ )
205207@bounds_opt
206208@click .option (
207209 "--bounds-crs" ,
@@ -219,7 +221,7 @@ def dem(
219221@lowercase_opt
220222@verbose_opt
221223@quiet_opt
222- def dump (dataset , query , out_file , bounds , bounds_crs , no_clean , lowercase , verbose , quiet ):
224+ def dump (dataset , query , out_file , count , bounds , bounds_crs , no_clean , lowercase , verbose , quiet ):
223225 """Write DataBC features to stdout as GeoJSON feature collection.
224226
225227 \b
@@ -240,7 +242,13 @@ def dump(dataset, query, out_file, bounds, bounds_crs, no_clean, lowercase, verb
240242 else :
241243 clean = True
242244 data = bcdata .get_data (
243- table , query = query , bounds = bounds , bounds_crs = bounds_crs , lowercase = lowercase , clean = clean
245+ table ,
246+ query = query ,
247+ count = count ,
248+ bounds = bounds ,
249+ bounds_crs = bounds_crs ,
250+ lowercase = lowercase ,
251+ clean = clean ,
244252 )
245253 if out_file :
246254 with open (out_file , "w" ) as sink :
0 commit comments