File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
src/SearchAPI/application Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 1+ from typing import Optional
12from copy import copy
23import json
34
@@ -226,6 +227,26 @@ async def file_to_wkt(files: list[UploadFile]):
226227 headers = constants .DEFAULT_HEADERS
227228 )
228229
230+ @router .get ('/services/utils/kml_footprint' )
231+ async def kml_to_footprint (request : Request , granule : str , maturity : str = 'prod' ):
232+ config = load_config_maturity (maturity = maturity )
233+
234+ query_opts = asf .ASFSearchOptions (granule_list = [granule ])
235+ if (auth := request .headers .get ('authorization' )) is not None :
236+ session = SearchAPISession ()
237+ session .headers .update ({'Authorization' : auth })
238+ query_opts .session = session
239+
240+
241+ query_opts .host = config ['cmr_base' ]
242+
243+ results = asf .search (opts = query_opts , dataset = asf .DATASET .NISAR )
244+
245+ kml_file = results .find_urls (extension = '.kml' )[0 ]
246+
247+ kml_response = query_opts .session .get (kml_file )
248+ return kml_response .text
249+
229250# example: https://api.daac.asf.alaska.edu/services/redirect/NISAR_L2_STATIC/{granule_id}.h5
230251# @router.get('/services/redirect/{short_name}/{granule_id}')
231252# async def nisar_static_layer(short_name: str, granule_id: str):
You can’t perform that action at this time.
0 commit comments