Skip to content

Commit

Permalink
Merge pull request #166 from raphaelrpl/latest
Browse files Browse the repository at this point in the history
📚 Improve documentation deploy and add compatibility table
  • Loading branch information
raphaelrpl authored Sep 12, 2022
2 parents 0841fb9 + a60ca54 commit 41ae0e7
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 19 deletions.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Changes
=======


Version 1.0.0a1 (2022-09-06)
Version 1.0.0a1 (2022-09-12)
----------------------------

- Implementation of STAC v1.0-rc.1 with the following extensions:
Expand Down
18 changes: 15 additions & 3 deletions DEPLOY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,17 @@ Requirements


Besides Docker, you will need an instance of a PostgreSQL DBMS with a database prepared using `Brazil Data Cube Catalog Module <https://github.com/brazil-data-cube/bdc-catalog>`_.
Before prepare database instance, just take a look in support mapping of BDC-STAC:
Before prepare database instance, just take a look in support compatibility table:

- STAC ``v0.9.0`` -> ``BDC-Catalog 0.8.x``
- STAC ``v1.0.0+`` -> ``BDC-Catalog 1.0+``
+---------------------------+-----------+-------------+
| STAC API Spec | BDC-STAC | BDC-Catalog |
+===========================+===========+=============+
| 0.8.x | 0.8.x | 0.4.x |
+---------------------------+-----------+-------------+
| 0.9.0 - 1.0.0-rc.1 | 0.9.x | 0.8.x |
+---------------------------+-----------+-------------+
| 1.0.0-beta.1 - 1.0.0-rc.1 | 1.0.x | 1.0.x |
+---------------------------+-----------+-------------+


Building the Docker Image
Expand Down Expand Up @@ -188,6 +195,11 @@ The output should be a JSON document similar to:
}
.. note::

Be aware that collections ``S2_L1C-1``, ``MYD13Q1-6`` and ``MOD13Q1-6`` described above are examples.
You should create a definition of Collection following `BDC-Catalog <https://github.com/brazil-data-cube/bdc-catalog>`_ module.

.. rubric:: Footnotes

.. [#f1] See the `Brazil Data Cube Catalog Module <https://github.com/brazil-data-cube/bdc-catalog>`_.
18 changes: 17 additions & 1 deletion INSTALL.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
..
This file is part of Brazil Data Cube STAC Service.
Copyright (C) 2019-2020 INPE.
Copyright (C) 2019-2022 INPE.
Brazil Data Cube STAC Service is free software; you can redistribute it and/or modify it
under the terms of the MIT License; see LICENSE file for more details.
Expand Down Expand Up @@ -29,6 +29,22 @@ The Brazil Data Cube STAC implementation depends essentially on:
- `Flask-Redoc <https://pypi.org/project/flask-redoc/>`_: a Flask extension for displaying OpenAPI/Swagger documentation using Redocs.


STAC Versions
+++++++++++++

Before installing the ``BDC-STAC`` server, please, take a look into compatibility table:

+---------------------------+-----------+-------------+
| STAC API Spec | BDC-STAC | BDC-Catalog |
+===========================+===========+=============+
| 0.8.x | 0.8.x | 0.4.x |
+---------------------------+-----------+-------------+
| 0.9.0 - 1.0.0-rc.1 | 0.9.x | 0.8.x |
+---------------------------+-----------+-------------+
| 1.0.0-beta.1 - 1.0.0-rc.1 | 1.0.x | 1.0.x |
+---------------------------+-----------+-------------+


Clone the software repository
+++++++++++++++++++++++++++++

Expand Down
23 changes: 9 additions & 14 deletions bdc_stac/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import warnings
from datetime import datetime as dt
from functools import lru_cache
from typing import Optional
from typing import List, Optional

import shapely.geometry
from bdc_catalog.models import (
Expand Down Expand Up @@ -264,27 +264,22 @@ def get_collection_crs(collection: Collection) -> str:
return collection.grs.crs if collection.grs is not None else None


def get_collection_timeline(collection_id):
"""Retrieve a list of dates for a given collection.
def format_timeline(timeline: Optional[List[Timeline]] = None):
"""Format the collection timeline values with Dateformat
:param collection_id: collection identifier
:type collection_id: str
:param timeline: The collection timeline instance
:type timeline: Optional[List[Timeline]]
:return: list of dates for the collection
:rtype: list
"""
timeline = (
session.query(Timeline.time_inst)
.filter(Timeline.collection_id == collection_id)
.order_by(Timeline.time_inst.asc())
.all()
)

if timeline is None:
return []
return [dt.fromisoformat(str(t.time_inst)).strftime("%Y-%m-%d") for t in timeline]


@lru_cache()
def get_collection_quicklook(collection_id):
"""Retrieve a list of bands used to create the quicklooks for a given collection.
"""Retrieve a list of bands used to create the quicklook for a given collection.
:param collection_id: collection identifier
:type collection_id: str
Expand Down Expand Up @@ -425,7 +420,7 @@ def get_collections(collection_id=None, roles=None, assets_kwargs=None):
datacube = {
"x": dict(type="spatial", axis="x", extent=[bbox[0], bbox[2]], reference_system=proj4text),
"y": dict(type="spatial", axis="y", extent=[bbox[1], bbox[3]], reference_system=proj4text),
"temporal": dict(type="temporal", extent=[start, end], values=get_collection_timeline(r.Collection.id)),
"temporal": dict(type="temporal", extent=[start, end], values=format_timeline(r.Collection.timeline)),
}
if category == "eo":
datacube["bands"] = dict(type="bands", values=[band["name"] for band in collection_eo["eo:bands"]])
Expand Down

0 comments on commit 41ae0e7

Please sign in to comment.