From f58ca670c6f6e2fc1034292c4eb06bb7dbf3149d Mon Sep 17 00:00:00 2001 From: jacobstr Date: Thu, 11 Feb 2016 22:34:14 -0800 Subject: [PATCH] Enable querying by saved aoi. --- planet/api/client.py | 5 ++++- planet/scripts/__init__.py | 5 ++++- tests/test_cli.py | 6 ++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/planet/api/client.py b/planet/api/client.py index ff5bc43da..1174a8b91 100644 --- a/planet/api/client.py +++ b/planet/api/client.py @@ -97,7 +97,8 @@ def login(self, identity, credentials): return json.loads(payload.decode('utf-8')) def get_scenes_list(self, scene_type='ortho', order_by=None, count=None, - intersects=None, workspace=None, **filters): + intersects=None, workspace=None, aoi_id=None, + **filters): '''Get scenes matching the specified parameters and filters. :param str scene_type: The type of scene, defaults to 'ortho' @@ -117,6 +118,8 @@ def get_scenes_list(self, scene_type='ortho', order_by=None, count=None, } if workspace: params['workspace'] = workspace + if aoi_id: + params['aoi'] = aoi_id params.update(**filters) return self._get('scenes/%s/' % scene_type, models.Scenes, params=params).get_body() diff --git a/planet/scripts/__init__.py b/planet/scripts/__init__.py index 8989cee61..a17170473 100644 --- a/planet/scripts/__init__.py +++ b/planet/scripts/__init__.py @@ -259,11 +259,14 @@ def init(email, password): help=('Provide additional search criteria. See ' 'https://www.planet.com/docs/v0/scenes/#metadata for ' 'search metadata fields.')) -def get_scenes_list(scene_type, pretty, aoi, limit, where, workspace): +@click.option('--aoi_id', help=( + 'Provider the identifier of an uploaded geometry')) +def get_scenes_list(scene_type, pretty, aoi, limit, where, workspace, aoi_id): '''Get a list of scenes.''' aoi = read_aoi(aoi) conditions = {'workspace': workspace} + conditions = {'aoi_id': aoi_id} if where: conditions.update([ diff --git a/tests/test_cli.py b/tests/test_cli.py index 508ce0683..d346dc356 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -176,6 +176,12 @@ def test_search(): assert_success(result, expected) +def test_aoi_id_flag(): + run_cli(['search', '--aoi_id', 'dangbat']) + client.get_scenes_list.assert_called_with( + aoi_id='dangbat', count=1000, intersects=None, scene_type='ortho') + + def test_search_by_aoi(): aoi = read_fixture('search-by-aoi.geojson')