feat: Add auto_webmercator to COG#1893
Conversation
|
During a very intensive project deadline these days, would be back ASAP! |
|
|
||
| /// Convert min/max XYZ tile coordinates to a bounding box values in Web Mercator. | ||
| #[must_use] | ||
| pub fn xyz_to_bbox_webmercator( |
There was a problem hiding this comment.
we have already a xyz_to_bbox actually but its result is not in 3857
There was a problem hiding this comment.
Should we add it here?
There was a problem hiding this comment.
Yes, comparing in the doc string the two seems sensible.
Moreover, we should likely use xyz_to_bbox_webmercator in xyz_to_bbox (instead of copy and paste) and rename it to xyz_to_bbox_wgs84
| # Configured with a directory containing `*.tif` or `*.tiff` TIFF files. | ||
| martin /with/tiff/dir1 /with/tiff/dir2 | ||
| # Configured with dedicated TIFF file | ||
| martin /path/to/target1.tif /path/to/target2.tiff | ||
| # Configured with a combination of directories and dedicated TIFF files. | ||
| martin /with/tiff/files /path/to/target1.tif /path/to/target2.tiff |
There was a problem hiding this comment.
Enable auto-web in CLI Next PR.
|
Two comments (I am not sure if you want a review yet, but think getting these out of the way is nice)
|
auto_webmercator to COG
CommanderStorm
left a comment
There was a problem hiding this comment.
I am really happy to see progress on this.
I have left a few comments below, but the three where we need to align on are:
- I don't think
auto_webis not quite self-explanatory.
How aboutconvert_to_web_mercator_quador something liketiling_scheme: WebMercatorQuad? - Would be
trueby default not be a better call? I think this is what users most likely want and this would match the default of maplibre… - Do we need this setting to be per-source configurable, or would this being a global setting be sufficient?
docs/src/sources-cog-files.md
Outdated
| - /path/to/target1.tif | ||
| - /path/to/target2.tiff | ||
| # Default false | ||
| # If enabled, martin will automatically serve COG as a [WebMercatorQuad](https://docs.ogc.org/is/17-083r2/17-083r2.html#72) service, the tiles will be cliped and merged internally to be aligned with the Web Mercator grid. |
There was a problem hiding this comment.
| # If enabled, martin will automatically serve COG as a [WebMercatorQuad](https://docs.ogc.org/is/17-083r2/17-083r2.html#72) service, the tiles will be cliped and merged internally to be aligned with the Web Mercator grid. | |
| # If enabled, martin will automatically serve COG as a [WebMercatorQuad](https://docs.ogc.org/is/17-083r2/17-083r2.html#72) service. | |
| # The tiles will be cliped/merged internally to be aligned with the Web Mercator grid. |
docs/src/sources-cog-files.md
Outdated
| - /path/to/target2.tiff | ||
| # Default false | ||
| # If enabled, martin will automatically serve COG as a [WebMercatorQuad](https://docs.ogc.org/is/17-083r2/17-083r2.html#72) service, the tiles will be cliped and merged internally to be aligned with the Web Mercator grid. | ||
| # Note: Just work for COG files with a Web Mercator CRS (EPSG:3857). |
There was a problem hiding this comment.
could you clarify this comment?
There was a problem hiding this comment.
Welcome any better description!
That's said martin would make the output tiles aligned with the WebMercatoQuad so clients no need to set the customized tilegrid. I would try to make it better again, and any suggestion? I'm pain in English 😂
martin/src/cog/source.rs
Outdated
| nodata, | ||
| tilejson, | ||
| tileinfo, | ||
| web_friendly: auto_web, |
There was a problem hiding this comment.
lets use the same name across the whole api ^^
There was a problem hiding this comment.
I thought I have fix this lolll still left one here..... And let's discuss which is better?
- auto_web
- web_friendly
- convert_to_web_mercator_quad
- WebMercatorQuad
- Other suggestion? Maybe @nyurik have a better idea?
martin/src/cog/source.rs
Outdated
| /// find a zoom level of google web mercator that is closest to the given resolution | ||
| fn nearest_web_mercator_zoom(resolution: (f64, f64), tile_size: (u32, u32)) -> u8 { | ||
| let tile_width_in_model = resolution.0 * f64::from(tile_size.0); | ||
| let mut nearest_zoom = 0u8; | ||
| let mut min_diff = f64::INFINITY; | ||
|
|
||
| for google_zoom in 0..30 { | ||
| let tile_length = EARTH_CIRCUMFERENCE / f64::from(1_u32 << google_zoom); | ||
| let current_diff = (tile_width_in_model - tile_length).abs(); | ||
|
|
||
| if current_diff < min_diff { | ||
| min_diff = current_diff; | ||
| nearest_zoom = google_zoom; | ||
| } | ||
| } |
There was a problem hiding this comment.
this is the only place where google is mentioned
| /// find a zoom level of google web mercator that is closest to the given resolution | |
| fn nearest_web_mercator_zoom(resolution: (f64, f64), tile_size: (u32, u32)) -> u8 { | |
| let tile_width_in_model = resolution.0 * f64::from(tile_size.0); | |
| let mut nearest_zoom = 0u8; | |
| let mut min_diff = f64::INFINITY; | |
| for google_zoom in 0..30 { | |
| let tile_length = EARTH_CIRCUMFERENCE / f64::from(1_u32 << google_zoom); | |
| let current_diff = (tile_width_in_model - tile_length).abs(); | |
| if current_diff < min_diff { | |
| min_diff = current_diff; | |
| nearest_zoom = google_zoom; | |
| } | |
| } | |
| /// Find the closest web mercator zoom level for the given resolution | |
| fn nearest_web_mercator_zoom(resolution: (f64, f64), tile_size: (u32, u32)) -> u8 { | |
| let tile_width_in_model = resolution.0 * f64::from(tile_size.0); | |
| let mut nearest_zoom = 0u8; | |
| let mut min_diff = f64::INFINITY; | |
| for zoom in 0..30 { | |
| let tile_length = EARTH_CIRCUMFERENCE / f64::from(1_u32 << zoom); | |
| let current_diff = (tile_width_in_model - tile_length).abs(); | |
| if current_diff < min_diff { | |
| min_diff = current_diff; | |
| nearest_zoom = zoom; | |
| } | |
| } |
martin/src/file_config.rs
Outdated
| path: PathBuf, | ||
| ) -> impl Future<Output = MartinResult<TileInfoSource>> + Send; | ||
|
|
||
| fn new_sources_with_config( |
There was a problem hiding this comment.
lets add a doc comment what this trait-fn does allow to do (per source configurable sources)
martin/src/cog/config.rs
Outdated
| @@ -13,6 +13,11 @@ use crate::{MartinResult, TileInfoSource}; | |||
| pub struct CogConfig { | |||
There was a problem hiding this comment.
I think we should not serialize auto_web if None => add the serde_with marker
|
@CommanderStorm / @sharkAndshark what's the current status of this one? Is there anything I can do to help take it over the line? |
|
I had a new full time job that have no too much time on this project this year. It was almost there but the structure of Martin has been changed.
You could PR to my branch or just add a new PR, I'd love to review ❤️ @Auspicus |
I already have done that part, I think. |
a8e716a to
585eed3
Compare
|
I've picked this one. And have reset to the latest main branch. A fresh start would be more easier as it's too far away from the latest changes. |
4d3c51c to
413f7e4
Compare
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
auto_webmercator to COGauto_webmercator to COG
|
Lets focus on #2510 instead, which seems much farther along. |

To fix #1820 .