1- """Item crud client."""
2- import json
1+ """Core client."""
32import logging
43import re
54from datetime import datetime as datetime_type
1615from pygeofilter .backends .cql2_json import to_cql2
1716from pygeofilter .parsers .cql2_text import parse as parse_cql2_text
1817from stac_pydantic .links import Relations
19- from stac_pydantic .shared import MimeTypes
18+ from stac_pydantic .shared import BBox , MimeTypes
2019from stac_pydantic .version import STAC_VERSION
2120
2221from stac_fastapi .core .base_database_logic import BaseDatabaseLogic
@@ -246,8 +245,8 @@ async def get_collection(self, collection_id: str, **kwargs) -> Collection:
246245 async def item_collection (
247246 self ,
248247 collection_id : str ,
249- bbox : Optional [List [ NumType ] ] = None ,
250- datetime : Union [ str , datetime_type , None ] = None ,
248+ bbox : Optional [BBox ] = None ,
249+ datetime : Optional [ DateTimeType ] = None ,
251250 limit : int = 10 ,
252251 token : str = None ,
253252 ** kwargs ,
@@ -256,8 +255,8 @@ async def item_collection(
256255
257256 Args:
258257 collection_id (str): The identifier of the collection to read items from.
259- bbox (Optional[List[NumType] ]): The bounding box to filter items by.
260- datetime (Union[str, datetime_type, None ]): The datetime range to filter items by.
258+ bbox (OOptional[BBox ]): The bounding box to filter items by.
259+ datetime (Optional[DateTimeType ]): The datetime range to filter items by.
261260 limit (int): The maximum number of items to return. The default value is 10.
262261 token (str): A token used for pagination.
263262 request (Request): The incoming request.
@@ -413,8 +412,8 @@ async def get_search(
413412 request : Request ,
414413 collections : Optional [List [str ]] = None ,
415414 ids : Optional [List [str ]] = None ,
416- bbox : Optional [List [ NumType ] ] = None ,
417- datetime : Optional [Union [ str , datetime_type ] ] = None ,
415+ bbox : Optional [BBox ] = None ,
416+ datetime : Optional [DateTimeType ] = None ,
418417 limit : Optional [int ] = 10 ,
419418 query : Optional [str ] = None ,
420419 token : Optional [str ] = None ,
@@ -430,8 +429,8 @@ async def get_search(
430429 Args:
431430 collections (Optional[List[str]]): List of collection IDs to search in.
432431 ids (Optional[List[str]]): List of item IDs to search for.
433- bbox (Optional[List[NumType] ]): Bounding box to search in.
434- datetime (Optional[Union[str, datetime_type] ]): Filter items based on the datetime field.
432+ bbox (Optional[BBox ]): Bounding box to search in.
433+ datetime (Optional[DateTimeType ]): Filter items based on the datetime field.
435434 limit (Optional[int]): Maximum number of results to return.
436435 query (Optional[str]): Query string to filter the results.
437436 token (Optional[str]): Access token to use when searching the catalog.
@@ -466,27 +465,8 @@ async def get_search(
466465 if datetime :
467466 base_args ["datetime" ] = datetime
468467
469- # As of stac-fastapi 2.5.x, the intersects GET request parameter is being sent as a list
470468 if intersects :
471- intersects_dict = {"type" : None , "coordinates" : None }
472-
473- combined_json_string = intersects [0 ]
474-
475- # Iterate over the remaining fragments and add each with a preceding comma
476- for fragment in intersects [1 :]:
477- combined_json_string += "," + fragment
478-
479- combined_json_string = combined_json_string .replace ("'" , "" )
480- combined_json_string = "" .join (
481- char for char in combined_json_string if char .isprintable ()
482- )
483-
484- try :
485- intersects_dict = json .loads (combined_json_string )
486- except json .JSONDecodeError as error :
487- print ("Failed to parse JSON:" , error )
488-
489- base_args ["intersects" ] = intersects_dict
469+ base_args ["intersects" ] = orjson .loads (unquote_plus (intersects ))
490470
491471 if sortby :
492472 sort_param = []
0 commit comments