From e592e04ba9973015f70d9a11bdfff4fe4d134088 Mon Sep 17 00:00:00 2001 From: Vincent Sarago Date: Thu, 11 Feb 2021 22:59:42 -0500 Subject: [PATCH] add `rio_tiler.io.MultiBandReader` bands dependencies (#226) --- CHANGES.md | 1 + titiler/dependencies.py | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 371ddeaa6..10c9b58f5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,6 +10,7 @@ * deleted `titiler.models.mosaics` because the models are not used anymore (https://github.com/developmentseed/titiler/pull/221) * update rio-tiler and cogeo-mosaic minimal versions (https://github.com/developmentseed/titiler/pull/220, https://github.com/developmentseed/titiler/pull/213) * move STAC related dependencies to `titiler.dependencies (https://github.com/developmentseed/titiler/pull/225) +* add `rio_tiler.io.MultiBandReader` bands dependencies (https://github.com/developmentseed/titiler/pull/226) ## 0.1.0a14 (2021-01-05) diff --git a/titiler/dependencies.py b/titiler/dependencies.py index 13b648a65..b8f5aa7d3 100644 --- a/titiler/dependencies.py +++ b/titiler/dependencies.py @@ -176,6 +176,41 @@ def __post_init__(self): ) +# Dependencies for MultiBandReader +@dataclass +class BandsParams(DefaultDependency): + """Band names parameters.""" + + bands: str = Query( + ..., title="bands names", description="comma (',') delimited bands names.", + ) + + def __post_init__(self): + """Post Init.""" + self.kwargs["bands"] = self.bands.split(",") + + +@dataclass +class BandsExprParams(DefaultDependency): + """Band names and Expression parameters.""" + + bands: Optional[str] = Query( + None, title="bands names", description="comma (',') delimited bands names.", + ) + expression: Optional[str] = Query( + None, + title="Band Math expression", + description="rio-tiler's band math expression.", + ) + + def __post_init__(self): + """Post Init.""" + if self.bands is not None: + self.kwargs["bands"] = self.bands.split(",") + if self.expression is not None: + self.kwargs["expression"] = self.expression + + @dataclass class MetadataParams(DefaultDependency): """Common Metadada parameters."""