Skip to content

Commit

Permalink
add min_zoom and max_zoom to tilejson
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkAndshark committed Dec 13, 2024
1 parent 4cd9fe7 commit e0fd84b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
10 changes: 7 additions & 3 deletions martin/src/cog/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ impl ConfigExtras for CogConfig {

impl SourceConfigExtras for CogConfig {
async fn new_sources(&self, id: String, path: PathBuf) -> FileResult<Box<dyn Source>> {
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,
Expand All @@ -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<Meta, FileError> {
Expand Down
4 changes: 3 additions & 1 deletion tests/expected/auto/rgb_u8.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
"tilejson": "3.0.0",
"tiles": [
"http://localhost:3111/rgb_u8/{z}/{x}/{y}"
]
],
"maxzoom": 3,
"minzoom": 0
}
4 changes: 3 additions & 1 deletion tests/expected/auto/rgba_u8.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
"tilejson": "3.0.0",
"tiles": [
"http://localhost:3111/rgba_u8/{z}/{x}/{y}"
]
],
"maxzoom": 3,
"minzoom": 0
}
4 changes: 3 additions & 1 deletion tests/expected/auto/rgba_u8_nodata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
"tilejson": "3.0.0",
"tiles": [
"http://localhost:3111/rgba_u8_nodata/{z}/{x}/{y}"
]
],
"maxzoom": 2,
"minzoom": 0
}

0 comments on commit e0fd84b

Please sign in to comment.