Skip to content

Commit

Permalink
add tests for stac projection extension 2.0 (#783)
Browse files Browse the repository at this point in the history
* add tests for stac projection extension 2.0

* skip if <3.10
  • Loading branch information
vincentsarago authored Jan 27, 2025
1 parent 4c1b2a6 commit 3fbeaf3
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 1 deletion.
94 changes: 94 additions & 0 deletions tests/fixtures/stac_proj_2_0.json
Original file line number Diff line number Diff line change
@@ -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" ]
}
}
}
9 changes: 8 additions & 1 deletion tests/test_io_stac.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -152,7 +153,7 @@ def raise_for_status(self):
assert s3_get.call_args[0] == ("somewhereovertherainbow.io", "mystac.json")


@pytest.mark.skipif(sys.version_info < (3, 9), reason="requires python3.9 or higher")
@pytest.mark.skipif(sys.version_info < (3, 10), reason="requires python3.9 or higher")
def test_projection_extension():
"""Test STAC with the projection extension."""
with STACReader(STAC_PATH_PROJ) as stac:
Expand All @@ -161,6 +162,12 @@ def test_projection_extension():
assert stac.bounds
assert stac.crs == CRS.from_epsg(32617)

with STACReader(STAC_PATH_PROJ_2_0) 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:
assert stac.minzoom == 4
assert stac.maxzoom == 8
Expand Down

0 comments on commit 3fbeaf3

Please sign in to comment.