Skip to content

Commit e06eec8

Browse files
authored
fix: handle missing location in item search (#7)
1 parent 0738364 commit e06eec8

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

stac_search/agents/items_search.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -370,15 +370,19 @@ async def item_search(ctx: Context) -> ItemSearchResult:
370370
f"Params formulation time: {params_formulation_time - query_formulation_time} seconds"
371371
)
372372

373-
polygon = await get_polygon_from_geodini(results.location)
374-
if polygon:
375-
logger.info(f"Found polygon for {results.location}")
376-
params["intersects"] = polygon
373+
if results.location:
374+
polygon = await get_polygon_from_geodini(results.location)
375+
if polygon:
376+
logger.info(f"Found polygon for {results.location}")
377+
params["intersects"] = polygon
378+
else:
379+
explanation += f"\n\n No polygon found for {results.location}. "
380+
return ItemSearchResult(
381+
items=None, search_params=params, aoi=None, explanation=explanation
382+
)
377383
else:
378-
explanation += f"\n\n No polygon found for {results.location}. "
379-
return ItemSearchResult(
380-
items=None, search_params=params, aoi=None, explanation=explanation
381-
)
384+
polygon = None
385+
explanation += "\n\n No specific location provided in the query."
382386
geocoding_time = time.time()
383387
logger.info(f"Geocoding time: {geocoding_time - params_formulation_time} seconds")
384388

0 commit comments

Comments
 (0)