Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump Stac support to 1.0.0 #307

Merged
merged 12 commits into from
Aug 31, 2021
2 changes: 1 addition & 1 deletion cubedash/_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import rapidjson
from dateutil import tz
from flask import Blueprint
from jinja2 import Markup, escape
from markupsafe import Markup, escape
from shapely.geometry import MultiPolygon
from urllib.parse import quote_plus
from datacube.index.fields import Field
Expand Down
17 changes: 11 additions & 6 deletions cubedash/_stac.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from werkzeug.exceptions import HTTPException, BadRequest

from cubedash.summary._stores import DatasetItem
from datacube.model import Range
from datacube.model import Range, Dataset
from datacube.utils import DocReader, parse_time
from eodatasets3 import serialise
from eodatasets3 import stac as eo3stac
Expand All @@ -39,7 +39,7 @@
"STAC_DEFAULT_FULL_ITEM_INFORMATION", True
)

STAC_VERSION = "1.0.0-beta.2"
STAC_VERSION = "1.0.0"


def url_for(*args, **kwargs):
Expand Down Expand Up @@ -349,7 +349,6 @@ def search_stac_items(
paging_properties["context"]["matched"] = count_matching

result = dict(
stac_extensions=["context"],
type="FeatureCollection",
features=[as_stac_item(f) for f in returned],
links=[],
Expand Down Expand Up @@ -465,6 +464,7 @@ def _stac_collection(collection: str):
stac_collection = dict(
id=summary.name,
title=summary.name,
type="Collection",
license=_utils.product_license(dataset_type),
description=dataset_type.definition.get("description"),
properties=dict(_build_properties(dataset_type.metadata)),
Expand Down Expand Up @@ -594,7 +594,7 @@ def _unparse_time_range(time: Tuple[datetime, datetime]) -> str:
return f"{start_time.isoformat()}/{end_time.isoformat()}"


def _band_to_measurement(band: Dict) -> MeasurementDoc:
def _band_to_measurement(band: Dict, dataset_location: str) -> MeasurementDoc:
"""Create EO3 measurement from an EO1 band dict"""
return MeasurementDoc(
path=band.get("path"),
Expand All @@ -609,7 +609,7 @@ def as_stac_item(dataset: DatasetItem):
"""
Get a dict corresponding to a stac item
"""
ds = dataset.odc_dataset
ds: Dataset = dataset.odc_dataset

if ds is not None and is_doc_eo3(ds.metadata_doc):
dataset_doc = serialise.from_doc(ds.metadata_doc, skip_validation=True)
Expand Down Expand Up @@ -637,6 +637,7 @@ def as_stac_item(dataset: DatasetItem):

else:
# eo1 to eo3

dataset_doc = DatasetDoc(
id=dataset.dataset_id,
# Filled-in below.
Expand All @@ -655,7 +656,11 @@ def as_stac_item(dataset: DatasetItem):
}
),
measurements={
name: _band_to_measurement(b) for name, b in ds.measurements.items()
name: _band_to_measurement(
b,
dataset_location=ds.uris[0] if ds is not None and ds.uris else None,
)
for name, b in ds.measurements.items()
}
if ds is not None
else {},
Expand Down
4 changes: 2 additions & 2 deletions cubedash/static/base.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cubedash/static/base.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cubedash/static/base.sass
Original file line number Diff line number Diff line change
Expand Up @@ -622,8 +622,8 @@ label
.property, .array, .array-item
padding-left: 15px

& > .key
font-weight: bold
& > .value
color: $muted_text

summary
font-style: italic
Expand Down
Loading