-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from developmentseed/patch/adjust-colormap-res…
…cale adjust rescale and colormap render params
- Loading branch information
Showing
3 changed files
with
256 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
{ | ||
"collections": [ | ||
{ | ||
"id": "MAXAR_BayofBengal_Cyclone_Mocha_May_23", | ||
"type": "Collection", | ||
"links": [ | ||
{ | ||
"rel": "items", | ||
"type": "application/geo+json", | ||
"href": "https://stac.endpoint.io/collections/MAXAR_BayofBengal_Cyclone_Mocha_May_23/items" | ||
}, | ||
{ | ||
"rel": "parent", | ||
"type": "application/json", | ||
"href": "https://stac.endpoint.io/" | ||
}, | ||
{ | ||
"rel": "root", | ||
"type": "application/json", | ||
"href": "https://stac.endpoint.io/" | ||
}, | ||
{ | ||
"rel": "self", | ||
"type": "application/json", | ||
"href": "https://stac.endpoint.io/collections/MAXAR_BayofBengal_Cyclone_Mocha_May_23" | ||
} | ||
], | ||
"title": "Bay of Bengal Cyclone Mocha 2023", | ||
"extent": { | ||
"spatial": { | ||
"bbox": [ | ||
[ | ||
91.831615, | ||
19.982078842323997, | ||
92.97426268500965, | ||
21.666101 | ||
], | ||
[ | ||
92.567815, | ||
20.18811887678192, | ||
92.74417544237298, | ||
20.62968532404085 | ||
], | ||
[ | ||
92.72278776887262, | ||
20.104801, | ||
92.893524, | ||
20.630214 | ||
], | ||
[ | ||
92.75855246040959, | ||
19.982078842323997, | ||
92.89682495377032, | ||
20.514473160464657 | ||
], | ||
[ | ||
92.84253515935835, | ||
19.984656587012033, | ||
92.97426268500965, | ||
20.514418665444474 | ||
], | ||
[ | ||
91.831615, | ||
21.518411, | ||
91.957078, | ||
21.666101 | ||
] | ||
] | ||
}, | ||
"temporal": { | ||
"interval": [ | ||
[ | ||
"2023-01-03T04:30:17Z", | ||
"2023-05-22T04:35:25Z" | ||
] | ||
] | ||
} | ||
}, | ||
"license": "CC-BY-NC-4.0", | ||
"renders": { | ||
"visual": { | ||
"title": "Visual Image", | ||
"assets": [ | ||
"visual" | ||
], | ||
"asset_bidx": "visual|1,2,3", | ||
"minmax_zoom": [ | ||
8, | ||
22 | ||
], | ||
"tilematrixsets": { | ||
"WebMercatorQuad": [ | ||
8, | ||
22 | ||
] | ||
} | ||
}, | ||
"color": { | ||
"title": "Colored Image", | ||
"assets": [ | ||
"visual" | ||
], | ||
"asset_bidx": "visual|1", | ||
"colormap": { | ||
"1": [0, 0, 0, 255], | ||
"1000": [255, 255, 255, 255] | ||
} | ||
}, | ||
"visualr": { | ||
"title": "Rescaled Image", | ||
"assets": [ | ||
"visual" | ||
], | ||
"asset_bidx": "visual|1", | ||
"rescale": [ | ||
[0, 100] | ||
] | ||
} | ||
}, | ||
"description": "Maxar OpenData | Cyclone Mocha, a category five cyclone with 130 mph winds and torrential rain, hit parts of Myanmar and Bangladesh, forcing mass evacuations ahead of the storm. The cyclone, one of the most powerful to hit the region in the last decade, made landfall on Sunday, May 14, 2023, near Sittwe in Myanmar's Rakhine state. Rain and a storm surge caused widespread flooding in low-lying areas. The United National Office Coordination of Humanitarian Affairs stated that there had been extensive damage among already vulnerable communities and that communications with the affected areas have been difficult.", | ||
"item_assets": { | ||
"visual": { | ||
"type": "image/tiff; application=geotiff; profile=cloud-optimized", | ||
"roles": [ | ||
"visual" | ||
], | ||
"title": "Visual Image" | ||
}, | ||
"data-mask": { | ||
"type": "application/geopackage+sqlite3", | ||
"roles": [ | ||
"data-mask" | ||
], | ||
"title": "Data Mask" | ||
}, | ||
"ms_analytic": { | ||
"type": "image/tiff; application=geotiff; profile=cloud-optimized", | ||
"roles": [ | ||
"data" | ||
], | ||
"title": "Multispectral Image" | ||
}, | ||
"pan_analytic": { | ||
"type": "image/tiff; application=geotiff; profile=cloud-optimized", | ||
"roles": [ | ||
"data" | ||
], | ||
"title": "Panchromatic Image" | ||
} | ||
}, | ||
"stac_version": "1.0.0", | ||
"stac_extensions": [ | ||
"https://stac-extensions.github.io/item-assets/v1.0.0/schema.json", | ||
"https://stac-extensions.github.io/render/v1.0.0/schema.json" | ||
] | ||
} | ||
], | ||
"links": [ | ||
{ | ||
"rel": "root", | ||
"type": "application/json", | ||
"href": "https://stac.endpoint.io/" | ||
}, | ||
{ | ||
"rel": "parent", | ||
"type": "application/json", | ||
"href": "https://stac.endpoint.io/" | ||
}, | ||
{ | ||
"rel": "self", | ||
"type": "application/json", | ||
"href": "https://stac.endpoint.io/collections" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
"""test render extension.""" | ||
|
||
import json | ||
import os | ||
from unittest.mock import patch | ||
|
||
import pystac | ||
|
||
from titiler.core import dependencies | ||
from titiler.stacapi.factory import get_dependency_params, get_layer_from_collections | ||
|
||
catalog_json = os.path.join(os.path.dirname(__file__), "fixtures", "catalog.json") | ||
|
||
|
||
@patch("titiler.stacapi.factory.Client") | ||
def test_render(client): | ||
"""test STAC items endpoints.""" | ||
|
||
with open(catalog_json, "r") as f: | ||
collections = [ | ||
pystac.Collection.from_dict(c) for c in json.loads(f.read())["collections"] | ||
] | ||
client.open.return_value.get_collections.return_value = collections | ||
|
||
collections_render = get_layer_from_collections( | ||
"https://something.stac", None, None | ||
) | ||
assert len(collections_render) == 3 | ||
|
||
visual = collections_render["MAXAR_BayofBengal_Cyclone_Mocha_May_23_visual"] | ||
assert visual["bbox"] | ||
assert visual["tilematrixsets"]["WebMercatorQuad"] | ||
assert visual["time"] | ||
assert visual["render"]["asset_bidx"] | ||
|
||
color = collections_render["MAXAR_BayofBengal_Cyclone_Mocha_May_23_color"]["render"] | ||
assert isinstance(color["colormap"], str) | ||
|
||
cmap = get_dependency_params( | ||
dependency=dependencies.ColorMapParams, | ||
query_params=color, | ||
) | ||
assert cmap | ||
|
||
visualr = collections_render["MAXAR_BayofBengal_Cyclone_Mocha_May_23_visualr"][ | ||
"render" | ||
] | ||
assert isinstance(visualr["rescale"][0], str) | ||
rescale = get_dependency_params( | ||
dependency=dependencies.RescalingParams, | ||
query_params=visualr, | ||
) | ||
assert rescale |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters