From e0fd84b40da64e11292f4ab61baf79c03742a421 Mon Sep 17 00:00:00 2001 From: sharkAndshar Date: Fri, 13 Dec 2024 15:36:20 +0800 Subject: [PATCH] add min_zoom and max_zoom to tilejson --- martin/src/cog/mod.rs | 10 +++++++--- tests/expected/auto/rgb_u8.json | 4 +++- tests/expected/auto/rgba_u8.json | 4 +++- tests/expected/auto/rgba_u8_nodata.json | 4 +++- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/martin/src/cog/mod.rs b/martin/src/cog/mod.rs index 1ea26637c..3ffc7d77e 100644 --- a/martin/src/cog/mod.rs +++ b/martin/src/cog/mod.rs @@ -215,9 +215,9 @@ impl ConfigExtras for CogConfig { impl SourceConfigExtras for CogConfig { async fn new_sources(&self, id: String, path: PathBuf) -> FileResult> { - let tilejson = get_tilejson(); let tileinfo = TileInfo::new(Format::Png, martin_tile_utils::Encoding::Uncompressed); let meta = get_meta(&path)?; + let tilejson = get_tilejson(meta.min_zoom, meta.max_zoom); Ok(Box::new(CogSource { id, path, @@ -238,8 +238,12 @@ impl SourceConfigExtras for CogConfig { } //todo add more to tileJson -fn get_tilejson() -> TileJSON { - tilejson! {tiles: vec![] } +fn get_tilejson(min_zoom: u8, max_zoom: u8) -> TileJSON { + tilejson! { + tiles: vec![], + minzoom: min_zoom, + maxzoom: max_zoom + } } fn get_meta(path: &PathBuf) -> Result { diff --git a/tests/expected/auto/rgb_u8.json b/tests/expected/auto/rgb_u8.json index 0973270ba..f9e3fa4c8 100644 --- a/tests/expected/auto/rgb_u8.json +++ b/tests/expected/auto/rgb_u8.json @@ -2,5 +2,7 @@ "tilejson": "3.0.0", "tiles": [ "http://localhost:3111/rgb_u8/{z}/{x}/{y}" - ] + ], + "maxzoom": 3, + "minzoom": 0 } diff --git a/tests/expected/auto/rgba_u8.json b/tests/expected/auto/rgba_u8.json index 088afd2e3..93c37fb01 100644 --- a/tests/expected/auto/rgba_u8.json +++ b/tests/expected/auto/rgba_u8.json @@ -2,5 +2,7 @@ "tilejson": "3.0.0", "tiles": [ "http://localhost:3111/rgba_u8/{z}/{x}/{y}" - ] + ], + "maxzoom": 3, + "minzoom": 0 } diff --git a/tests/expected/auto/rgba_u8_nodata.json b/tests/expected/auto/rgba_u8_nodata.json index 4c39b09b0..744c13547 100644 --- a/tests/expected/auto/rgba_u8_nodata.json +++ b/tests/expected/auto/rgba_u8_nodata.json @@ -2,5 +2,7 @@ "tilejson": "3.0.0", "tiles": [ "http://localhost:3111/rgba_u8_nodata/{z}/{x}/{y}" - ] + ], + "maxzoom": 2, + "minzoom": 0 }