Skip to content

Commit

Permalink
Merge pull request #95 from planetlabs/aoi-query
Browse files Browse the repository at this point in the history
Enable querying by saved aoi.
  • Loading branch information
jacobstr committed Feb 18, 2016
2 parents c5f113f + f58ca67 commit 9766119
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 4 additions & 1 deletion planet/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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()
Expand Down
5 changes: 4 additions & 1 deletion planet/scripts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
6 changes: 6 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 9766119

Please sign in to comment.