Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Unique asset names#341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
rhysrevans3 wants to merge3 commits intostac-utils:main
base:main
Choose a base branch
Loading
fromrhysrevans3:unique_asset_names
Draft
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletionsstac_fastapi/core/stac_fastapi/core/core.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -377,7 +377,7 @@ async def get_item(

@staticmethod
def _return_date(
interval: Optional[Union[DateTimeType, str]]
interval: Optional[Union[DateTimeType, str]],
) -> Dict[str, Optional[str]]:
"""
Convert a date interval.
Expand DownExpand Up@@ -724,15 +724,14 @@ async def update_item(

"""
item = item.model_dump(mode="json")
base_url = str(kwargs["request"].base_url)
now = datetime_type.now(timezone.utc).isoformat().replace("+00:00", "Z")
item["properties"]["updated"] = now

await self.database.check_collection_exists(collection_id)
await self.delete_item(item_id=item_id, collection_id=collection_id)
await self.create_item(collection_id=collection_id, item=Item(**item), **kwargs)

return ItemSerializer.db_to_stac(item, base_url)
returnawait self.create_item(
collection_id=collection_id, item=Item(**item), **kwargs
)

@overrides
async def delete_item(
Expand Down
14 changes: 13 additions & 1 deletionstac_fastapi/core/stac_fastapi/core/serializers.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
"""Serializers."""

import abc
from copy import deepcopy
from typing import Any, List, Optional
Expand DownExpand Up@@ -65,6 +66,10 @@ def stac_to_db(cls, stac_data: stac_types.Item, base_url: str) -> stac_types.Ite
item_links = resolve_links(stac_data.get("links", []), base_url)
stac_data["links"] = item_links

stac_data["assets"] = [
{"es_key": k, **v} for k, v in stac_data.get("assets", {}).items()
]

now = now_to_rfc3339_str()
if "created" not in stac_data["properties"]:
stac_data["properties"]["created"] = now
Expand DownExpand Up@@ -102,7 +107,7 @@ def db_to_stac(cls, item: dict, base_url: str) -> stac_types.Item:
bbox=item.get("bbox", []),
properties=item.get("properties", {}),
links=item_links,
assets=item.get("assets",{}),
assets={a.pop("es_key"): a for a initem.get("assets",[])},
)


Expand All@@ -127,6 +132,9 @@ def stac_to_db(
collection["links"] = resolve_links(
collection.get("links", []), str(request.base_url)
)
collection["assets"] = [
{"es_key": k, **v} for k, v in collection.get("assets", {}).items()
]
return collection

@classmethod
Expand DownExpand Up@@ -173,5 +181,9 @@ def db_to_stac(
collection_links += resolve_links(original_links, str(request.base_url))
collection["links"] = collection_links

collection["assets"] = {
a.pop("es_key"): a for a in collection.get("assets", [])
}

# Return the stac_types.Collection object
return stac_types.Collection(**collection)

[8]ページ先頭

©2009-2025 Movatter.jp