1
- """Item crud client."""
2
- import json
1
+ """Core client."""
3
2
import logging
4
3
import re
5
4
from datetime import datetime as datetime_type
16
15
from pygeofilter .backends .cql2_json import to_cql2
17
16
from pygeofilter .parsers .cql2_text import parse as parse_cql2_text
18
17
from stac_pydantic .links import Relations
19
- from stac_pydantic .shared import MimeTypes
18
+ from stac_pydantic .shared import BBox , MimeTypes
20
19
from stac_pydantic .version import STAC_VERSION
21
20
22
21
from stac_fastapi .core .base_database_logic import BaseDatabaseLogic
@@ -246,8 +245,8 @@ async def get_collection(self, collection_id: str, **kwargs) -> Collection:
246
245
async def item_collection (
247
246
self ,
248
247
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 ,
251
250
limit : int = 10 ,
252
251
token : str = None ,
253
252
** kwargs ,
@@ -256,8 +255,8 @@ async def item_collection(
256
255
257
256
Args:
258
257
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.
261
260
limit (int): The maximum number of items to return. The default value is 10.
262
261
token (str): A token used for pagination.
263
262
request (Request): The incoming request.
@@ -413,8 +412,8 @@ async def get_search(
413
412
request : Request ,
414
413
collections : Optional [List [str ]] = None ,
415
414
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 ,
418
417
limit : Optional [int ] = 10 ,
419
418
query : Optional [str ] = None ,
420
419
token : Optional [str ] = None ,
@@ -430,8 +429,8 @@ async def get_search(
430
429
Args:
431
430
collections (Optional[List[str]]): List of collection IDs to search in.
432
431
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.
435
434
limit (Optional[int]): Maximum number of results to return.
436
435
query (Optional[str]): Query string to filter the results.
437
436
token (Optional[str]): Access token to use when searching the catalog.
@@ -466,27 +465,8 @@ async def get_search(
466
465
if datetime :
467
466
base_args ["datetime" ] = datetime
468
467
469
- # As of stac-fastapi 2.5.x, the intersects GET request parameter is being sent as a list
470
468
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 ))
490
470
491
471
if sortby :
492
472
sort_param = []
0 commit comments