Module stac_fastapi.pgstac.utils¶
stac-fastapi utility methods.
Functions¶
dict_deep_update¶
def dict_deep_update(
merge_to: Dict[str, Any],
merge_from: Dict[str, Any]
) -> None
Perform a deep update of two dicts.
merge_to is updated in-place with the values from merge_from. merge_from values take precedence over existing values in merge_to.
filter_fields¶
def filter_fields(
item: Union[stac_fastapi.types.stac.Item, Dict[str, Any]],
include: Optional[Set[str]] = None,
exclude: Optional[Set[str]] = None
) -> stac_fastapi.types.stac.Item
Preserve and remove fields as indicated by the fields extension include/exclude sets.
Returns a shallow copy of the Item with the fields filtered.
This will not perform a deep copy; values of the original item will be referenced in the return item.
format_datetime_range¶
def format_datetime_range(
dt_range: Union[datetime.datetime, Tuple[datetime.datetime, datetime.datetime], Tuple[datetime.datetime, NoneType], Tuple[NoneType, datetime.datetime], str]
) -> str
Convert a datetime object or a tuple of datetime objects to a formatted string for datetime ranges.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dt_range | DateTimeType | The date interval, which might be a single datetime or a tuple with one or two datetimes. |
None |
Returns:
Type | Description |
---|---|
str | A formatted string like 'YYYY-MM-DDTHH:MM:SSZ/..', 'YYYY-MM-DDTHH:MM:SSZ', or the original string input. |