From 3590af351edbed5f1554f784c7cf5d205e6ecdf2 Mon Sep 17 00:00:00 2001 From: vincentsarago Date: Tue, 7 Sep 2021 17:08:19 +0200 Subject: [PATCH 1/3] update fastapi max version --- src/titiler/core/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/titiler/core/setup.py b/src/titiler/core/setup.py index 21519a6a1..263cb4dc7 100644 --- a/src/titiler/core/setup.py +++ b/src/titiler/core/setup.py @@ -6,7 +6,7 @@ long_description = f.read() inst_reqs = [ - "fastapi>=0.65,<0.66", + "fastapi>=0.65,<0.68", "geojson-pydantic", "jinja2>=2.11.2,<3.0.0", "morecantile", From d73d66b413e148e062c82b82026c9b31a3daa00b Mon Sep 17 00:00:00 2001 From: vincentsarago Date: Tue, 7 Sep 2021 17:09:21 +0200 Subject: [PATCH 2/3] add asset_expression in depdencies --- CHANGES.md | 7 +++++++ src/titiler/core/tests/test_factories.py | 9 +++++++++ src/titiler/core/titiler/core/dependencies.py | 18 ++++++++++++++++-- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 5a6479d82..33a5fe48f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,12 @@ # Release Notes +## 0.3.9 (2021-09-07) + +### titiler.core + +- update FastAPI requirements to `>=0.65,<0.68` (ref: https://github.com/developmentseed/titiler/issues/366) +- surface `asset_expression` and `band_expression` in Multi*TilerFactory (ref: https://github.com/developmentseed/titiler/issues/367) + ## 0.3.8 (2021-09-02) ### titiler.core diff --git a/src/titiler/core/tests/test_factories.py b/src/titiler/core/tests/test_factories.py index eb55d5af5..02a481e03 100644 --- a/src/titiler/core/tests/test_factories.py +++ b/src/titiler/core/tests/test_factories.py @@ -545,6 +545,15 @@ def test_MultiBaseTilerFactory(rio): assert meta["dtype"] == "int32" assert meta["count"] == 3 + response = client.get( + f"/preview.tif?url={DATA_DIR}/item.json&assets=B01&asset_expression=b1,b1,b1&return_mask=false" + ) + assert response.status_code == 200 + assert response.headers["content-type"] == "image/tiff; application=geotiff" + meta = parse_img(response.content) + assert meta["dtype"] == "int32" + assert meta["count"] == 3 + # GET - statistics response = client.get(f"/statistics?url={DATA_DIR}/item.json&assets=B01,B09") assert response.status_code == 200 diff --git a/src/titiler/core/titiler/core/dependencies.py b/src/titiler/core/titiler/core/dependencies.py index 47cd4e8cc..f9f9d73cc 100644 --- a/src/titiler/core/titiler/core/dependencies.py +++ b/src/titiler/core/titiler/core/dependencies.py @@ -157,11 +157,16 @@ class AssetsBidxExprParams(DefaultDependency): expression: Optional[str] = Query( None, title="Band Math expression", - description="rio-tiler's band math expression (e.g B1/B2)", + description="rio-tiler's band math expression between assets (e.g asset1/asset2)", ) bidx: Optional[str] = Query( None, title="Band indexes", description="comma (',') delimited band indexes", ) + asset_expression: Optional[str] = Query( + None, + title="Band Math expression to apply to each asset", + description="rio-tiler's band math expression (e.g b1/b2)", + ) def __post_init__(self): """Post Init.""" @@ -174,6 +179,8 @@ def __post_init__(self): self.kwargs["assets"] = self.assets.split(",") if self.expression is not None: self.kwargs["expression"] = self.expression + if self.asset_expression is not None: + self.kwargs["asset_expression"] = self.asset_expression if self.bidx is not None: self.kwargs["indexes"] = tuple( int(s) for s in re.findall(r"\d+", self.bidx) @@ -204,7 +211,12 @@ class BandsExprParams(DefaultDependency): expression: Optional[str] = Query( None, title="Band Math expression", - description="rio-tiler's band math expression.", + description="rio-tiler's band math expression between Band asset.", + ) + band_expression: Optional[str] = Query( + None, + title="Band Math expression", + description="rio-tiler's band math expression to apply to each band file.", ) def __post_init__(self): @@ -218,6 +230,8 @@ def __post_init__(self): self.kwargs["bands"] = self.bands.split(",") if self.expression is not None: self.kwargs["expression"] = self.expression + if self.band_expression is not None: + self.kwargs["band_expression"] = self.band_expression @dataclass From 5085bcd0f997ef64338d64a9a81a9bc2a8ef4d84 Mon Sep 17 00:00:00 2001 From: vincentsarago Date: Tue, 7 Sep 2021 17:24:21 +0200 Subject: [PATCH 3/3] add tests for multiBand --- src/titiler/core/tests/test_factories.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/titiler/core/tests/test_factories.py b/src/titiler/core/tests/test_factories.py index 02a481e03..770cfd0eb 100644 --- a/src/titiler/core/tests/test_factories.py +++ b/src/titiler/core/tests/test_factories.py @@ -653,6 +653,15 @@ def test_MultiBandTilerFactory(): assert meta["dtype"] == "int32" assert meta["count"] == 3 + response = client.get( + f"/preview.tif?url={DATA_DIR}&bands=B01&band_expression=b1,b1,b1&return_mask=false" + ) + assert response.status_code == 200 + assert response.headers["content-type"] == "image/tiff; application=geotiff" + meta = parse_img(response.content) + assert meta["dtype"] == "int32" + assert meta["count"] == 3 + # GET - statistics response = client.get(f"/statistics?url={DATA_DIR}&bands=B01,B09") assert response.status_code == 200