-
-
Notifications
You must be signed in to change notification settings - Fork 297
Add auto_webmercator to COG
#1893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
for more information, see https://pre-commit.ci
|
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have already a xyz_to_bbox actually but its result is not in 3857
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
auto_webmercator to COG
CommanderStorm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you clarify this comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 😂
| nodata, | ||
| tilejson, | ||
| tileinfo, | ||
| web_friendly: auto_web, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets use the same name across the whole api ^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
| /// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; | |
| } | |
| } |
| let mut nearest_zoom = 0u8; | ||
| let mut min_diff = f64::INFINITY; | ||
|
|
||
| for google_zoom in 0..30 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we use our MAX_ZOOM-constant instead?
| path: PathBuf, | ||
| ) -> impl Future<Output = MartinResult<TileInfoSource>> + Send; | ||
|
|
||
| fn new_sources_with_config( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets add a doc comment what this trait-fn does allow to do (per source configurable sources)
| use crate::{MartinResult, TileInfoSource}; | ||
|
|
||
| #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] | ||
| pub struct CogConfig { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should not serialize auto_web if None => add the serde_with marker

To fix #1820 .