Skip to content

allow for geojson to be piped through the cli to specify AOI #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions planet/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,8 @@ def _get(self, path, params=None, stream=False):
def list_all_scene_types(self):
return self._get('scenes').content

def get_scenes_list(self, scene_type=None, order_by=None, count=None,
def get_scenes_list(self, scene_type='ortho', order_by=None, count=None,
intersects=None, **filters):
scene_type = scene_type or 'ortho'
params = {}
push_params(params, order_by=order_by, count=count)
push_params(params, intersects=intersects)
Expand Down
29 changes: 21 additions & 8 deletions planet/scripts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
client = api.Client()

pretty = click.option('-pp', '--pretty', default=False, is_flag=True)
scene_type = click.option('-s', '--scene-type')
scene_type = click.option('-s', '--scene-type', default='ortho')


def check(func, *args, **kw):
Expand Down Expand Up @@ -49,12 +49,16 @@ def fetch_scene_geotiff(id, scene_type, product_type):


@scene_type
@click.argument('id', nargs=-1)
@click.argument("scene-ids", nargs=-1)
@click.option('--product-type', default=None)
@cli.command()
def fetch_scene_thumbnail(id, scene_type, product_type):
@cli.command('thumbnails')
def fetch_scene_thumbnail(scene_ids, scene_type, product_type):
'''Fetch scene thumbnail(s)'''
for i in id:

if len(scene_ids) == 0:
scene_ids = map(lambda s: s.strip(), click.open_file('-').readlines())

for i in scene_ids:
img = check(client.fetch_scene_thumbnail, i, scene_type, product_type)
click.echo('fetching %s' % img.name)
img.write()
Expand All @@ -74,10 +78,19 @@ def fetch_scene_info(id, scene_type, pretty):

@pretty
@scene_type
@cli.command()
def get_scenes_list(scene_type, pretty):
@cli.command('get-scenes-list')
@click.argument("aoi", default="-", required=False)
def get_scenes_list(scene_type, pretty, aoi):
'''Get a list of scenes'''
res = check(client.get_scenes_list, scene_type)

if aoi == "-":
src = click.open_file('-')
if not src.isatty():
lines = src.readlines()
aoi = ''.join([ line.strip() for line in lines ])


res = client.get_scenes_list(scene_type=scene_type, intersects=aoi)
if pretty:
res = json.dumps(json.loads(res), indent=2)
click.echo(res)