File tree Expand file tree Collapse file tree 9 files changed +99
-29
lines changed Expand file tree Collapse file tree 9 files changed +99
-29
lines changed Original file line number Diff line number Diff line change @@ -24,4 +24,5 @@ Download the following file for use in the tests.
2424
2525``` shell
2626aws s3 cp s3://naip-visualization/ny/2022/60cm/rgb/40073/m_4007307_sw_18_060_20220803.tif ./ --request-payer
27+ aws s3 cp s3://prd-tnm/StagedProducts/Elevation/13/TIFF/current/s14w171/USGS_13_s14w171.tif ./ --no-sign-request --region us-west-2
2728```
Original file line number Diff line number Diff line change 22uv sync --no-install-package async-tiff
33uv run --no-project maturin develop
44uv run --no-project mkdocs serve
5+ uv run --no-project pytest --verbose
56```
Original file line number Diff line number Diff line change @@ -295,8 +295,15 @@ impl ImageFileDirectory {
295295 . expect ( "There should be a chunk for each key." ) ;
296296
297297 let key_id = chunk[ 0 ] ;
298- let tag_name =
299- GeoKeyTag :: try_from_primitive ( key_id) . expect ( "Unknown GeoKeyTag id: {key_id}" ) ;
298+ let tag_name = if let Ok ( tag_name) = GeoKeyTag :: try_from_primitive ( key_id) {
299+ tag_name
300+ } else {
301+ // Skip unknown GeoKeyTag ids. Some GeoTIFFs include keys that were proposed
302+ // but not included in the GeoTIFF spec. See
303+ // https://github.com/developmentseed/async-tiff/pull/131 and
304+ // https://github.com/virtual-zarr/virtual-tiff/issues/52
305+ continue ;
306+ } ;
300307
301308 let tag_location = chunk[ 1 ] ;
302309 let count = chunk[ 2 ] ;
Original file line number Diff line number Diff line change 1+ use std:: env;
2+ use std:: sync:: Arc ;
3+
4+ use async_tiff:: metadata:: { PrefetchBuffer , TiffMetadataReader } ;
5+ use async_tiff:: reader:: { AsyncFileReader , ObjectReader } ;
6+ use object_store:: local:: LocalFileSystem ;
7+
8+ #[ tokio:: test]
9+ async fn test_parse_file_with_unknown_geokey ( ) {
10+ let folder = env:: current_dir ( ) . unwrap ( ) ;
11+ let path = object_store:: path:: Path :: parse ( "tests/images/geogtowgs_subset_USGS_13_s14w171.tif" )
12+ . unwrap ( ) ;
13+ let store = Arc :: new ( LocalFileSystem :: new_with_prefix ( folder) . unwrap ( ) ) ;
14+ let reader = Arc :: new ( ObjectReader :: new ( store, path) ) as Arc < dyn AsyncFileReader > ;
15+ let prefetch_reader = PrefetchBuffer :: new ( reader. clone ( ) , 32 * 1024 )
16+ . await
17+ . unwrap ( ) ;
18+ let mut metadata_reader = TiffMetadataReader :: try_open ( & prefetch_reader)
19+ . await
20+ . unwrap ( ) ;
21+ let _ = metadata_reader
22+ . read_all_ifds ( & prefetch_reader)
23+ . await
24+ . unwrap ( ) ;
25+ }
Original file line number Diff line number Diff line change 1+ ` geogtowgs_subset_USGS_13_s14w171.tif ` was created from "s3://prd-tnm/StagedProducts/Elevation/13/TIFF/current/s14w171/USGS_13_s14w171.tif" using these commands:
2+
3+ ``` bash
4+ gdal_translate USGS_13_s14w171.tif tiny.tif -srcwin 0 0 1 1 -co COMPRESS=DEFLATE
5+ listgeo USGS_13_s14w171.tif > metadata.txt # Then modify to remove information related to spatial extent
6+ cp tiny.tif geogtowgs_subset_USGS_13_s14w171.tif
7+ geotifcp -g metadata.txt tiny.tif geogtowgs_subset_USGS_13_s14w171.tif
8+ listgeo geogtowgs_subset_USGS_13_s14w171.tif
9+ ```
10+
11+ and this workspace definition:
12+
13+ ``` toml
14+ [project ]
15+ name = " gdal-workspace"
16+ version = " 0.1.0"
17+ description = " workspace for using gdal via pixi"
18+ readme = " README.md"
19+ requires-python = " >=3.12"
20+ dependencies = []
21+
22+ [tool .pixi .workspace ]
23+ channels = [" conda-forge" ]
24+ platforms = [" osx-arm64" ]
25+
26+ [tool .pixi .pypi-dependencies ]
27+ gdal-workspace = { path = " ." , editable = true }
28+
29+ [tool .pixi .tasks ]
30+
31+ [tool .pixi .dependencies ]
32+ gdal = " >=3.11.5,<4"
33+ libgdal = " >=3.11.5,<4"
34+ geotiff = " >=1.7.4,<2"
35+ ```
Original file line number Diff line number Diff line change 1+ mod geo;
12mod image_tiff;
3+ mod ome_tiff;
Original file line number Diff line number Diff line change 1- /// Integration tests on OME-TIFF files.
1+ //! Integration tests on OME-TIFF files.
2+
3+ use std:: sync:: Arc ;
4+
5+ use async_tiff:: metadata:: { PrefetchBuffer , TiffMetadataReader } ;
6+ use async_tiff:: reader:: { AsyncFileReader , ObjectReader } ;
27use async_tiff:: tiff:: tags:: PhotometricInterpretation ;
8+ use async_tiff:: TIFF ;
9+ use reqwest:: Url ;
310
4- mod util;
11+ async fn open_remote_tiff ( url : & str ) -> TIFF {
12+ let parsed_url = Url :: parse ( url) . expect ( "failed parsing url" ) ;
13+ let ( store, path) = object_store:: parse_url ( & parsed_url) . unwrap ( ) ;
14+
15+ let reader = Arc :: new ( ObjectReader :: new ( Arc :: new ( store) , path) ) as Arc < dyn AsyncFileReader > ;
16+ let prefetch_reader = PrefetchBuffer :: new ( reader. clone ( ) , 32 * 1024 )
17+ . await
18+ . unwrap ( ) ;
19+ let mut metadata_reader = TiffMetadataReader :: try_open ( & prefetch_reader)
20+ . await
21+ . unwrap ( ) ;
22+ let ifds = metadata_reader
23+ . read_all_ifds ( & prefetch_reader)
24+ . await
25+ . unwrap ( ) ;
26+ TIFF :: new ( ifds)
27+ }
528
629#[ tokio:: test]
730async fn test_ome_tiff_single_channel ( ) {
831 let tiff =
9- util :: open_remote_tiff ( "https://downloads.openmicroscopy.org/images/OME-TIFF/2016-06/bioformats-artificial/single-channel.ome.tif" ) . await ;
32+ open_remote_tiff ( "https://downloads.openmicroscopy.org/images/OME-TIFF/2016-06/bioformats-artificial/single-channel.ome.tif" ) . await ;
1033
1134 assert_eq ! ( tiff. ifds( ) . len( ) , 1 ) ;
1235 let ifd = & tiff. ifds ( ) [ 0 ] ;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments