From 5cb6060158c181137dc380bbfceef84829544848 Mon Sep 17 00:00:00 2001 From: vincentsarago Date: Mon, 27 Jan 2025 14:53:39 +0100 Subject: [PATCH] add tests for stac projection extension 2.0 --- tests/fixtures/stac_proj_2_0.json | 94 +++++++++++++++++++++++++++++++ tests/test_io_stac.py | 8 ++- 2 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 tests/fixtures/stac_proj_2_0.json diff --git a/tests/fixtures/stac_proj_2_0.json b/tests/fixtures/stac_proj_2_0.json new file mode 100644 index 00000000..56efa841 --- /dev/null +++ b/tests/fixtures/stac_proj_2_0.json @@ -0,0 +1,94 @@ +{ + "stac_version": "0.9.0", + "stac_extensions": [ + "https://stac-extensions.github.io/file/v2.1.0/schema.json", + "https://stac-extensions.github.io/projection/v2.0.0/schema.json" + ], + "type": "Feature", + "id": "JQT-123456789", + "bbox": [-81.3085227080129, 32.10817938759764, -78.81735409341113, 34.22870275071835], + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -81.3085227080129, + 32.10817938759764 + ], + [ + -78.81735409341113, + 32.10817938759764 + ], + [ + -78.81735409341113, + 34.22870275071835 + ], + [ + -81.3085227080129, + 34.22870275071835 + ], + [ + -81.3085227080129, + 32.10817938759764 + ] + ] + ] + }, + "properties": { + "proj:code": "EPSG:32617", + "proj:shape": [ + 259, + 255 + ], + "proj:transform": [ + 900.0, + 0.0, + 471585.0, + 0.0, + -900.0, + 3787515.0, + 0.0, + 0.0, + 1.0 + ], + "datetime": "2016-05-03T13:21:30.040Z", + "collection": "JQT" + }, + "links": [ + { + "rel": "self", + "href": "http://cool-sat.com/catalog/JQT/a-fake-item.json" + }, + { + "rel": "collection", + "href": "http://cool-sat.com/catalog.json" + } + ], + "assets": { + "red": { + "href": "http://somewhere-over-the-rainbow.io/red.tif", + "title": "red", + "file:header_size": 16384 + }, + "green": { + "href": "http://somewhere-over-the-rainbow.io/green.tif", + "title": "green", + "file:header_size": 30000 + }, + "blue": { + "href": "http://somewhere-over-the-rainbow.io/blue.tif", + "title": "blue", + "file:header_size": 20000 + }, + "lowres": { + "href": "http://somewhere-over-the-rainbow.io/lowres.tif", + "title": "lowres" + }, + "thumbnail": { + "href": "http://cool-sat.com/catalog/a-fake-item/thumbnail.png", + "title": "Thumbnail", + "type": "image/png", + "roles": [ "thumbnail" ] + } + } +} diff --git a/tests/test_io_stac.py b/tests/test_io_stac.py index a42c0bb0..0854115d 100644 --- a/tests/test_io_stac.py +++ b/tests/test_io_stac.py @@ -33,6 +33,7 @@ PREFIX = os.path.join(os.path.dirname(__file__), "fixtures") STAC_PATH = os.path.join(PREFIX, "stac.json") STAC_PATH_PROJ = os.path.join(PREFIX, "stac_proj.json") +STAC_PATH_PROJ_2_0 = os.path.join(PREFIX, "stac_proj_2_0.json") STAC_REL_PATH = os.path.join(PREFIX, "stac_relative.json") STAC_GDAL_PATH = os.path.join(PREFIX, "stac_headers.json") STAC_RASTER_PATH = os.path.join(PREFIX, "stac_raster.json") @@ -153,15 +154,16 @@ def raise_for_status(self): @pytest.mark.skipif(sys.version_info < (3, 9), reason="requires python3.9 or higher") -def test_projection_extension(): +@pytest.mark.parametrize("item_json", [STAC_PATH_PROJ, STAC_PATH_PROJ_2_0]) +def test_projection_extension(item_json): """Test STAC with the projection extension.""" - with STACReader(STAC_PATH_PROJ) as stac: + with STACReader(item_json) as stac: assert stac.minzoom == 6 assert stac.maxzoom == 7 assert stac.bounds assert stac.crs == CRS.from_epsg(32617) - with STACReader(STAC_PATH_PROJ, minzoom=4, maxzoom=8) as stac: + with STACReader(item_json, minzoom=4, maxzoom=8) as stac: assert stac.minzoom == 4 assert stac.maxzoom == 8 assert stac.bounds