Skip to content
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

Make tile service GoogleMaps-Compatible when the cog file is GoogleMapsCompatible #1637

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sharkAndshark
Copy link
Collaborator

@sharkAndshark sharkAndshark commented Dec 30, 2024

GDAL provides an interesting option when creating COG, TILING_SCHEME=[CUSTOM​/​GoogleMapsCompatible​/​...]

The goal of this PR is to allow frontend could use the googlemaps-compatible cog without extra steps(like make a custom tile grid), as google tilling schema seems is the most widely used schema, almost every JS lib support it( even only support it.)

LIke if we hanve a tiff file which is from zoom 0 - zoom 5 and it's googlemaps-compatible.

So there is a mapping from tiff-internal-xyz to google-map-xyz, I'm wondering if we could take this mapping and pretending that it's a tile source which use google tilling schema.

A sample like below:

tiff ifd number zoom level zoom level in google maps
0 5 14
1 4 13
2 3 12
3 2 11
.... .... ....

Update the tilejson

To implement this, we could update the tilejson

{
    ...,
    // tell user the zoom level is  from 9-14 instead of 0-5 
   "min_zoom": 9, 
   "max_zoom": 14,
    ...
}

Convert the user requested zxy internally

To implement this, we could transform the resquested xyz to the actuall xyz of tiff tile

user requested the actual zxy internally
/14/0/0 /5/4/3
.... ....

@sharkAndshark
Copy link
Collaborator Author

Still a concept proofing draft.

) -> Result<(Option<String>, Option<u8>), CogError> {
let gdal_metadata = decoder
.get_tag_ascii_string(Tag::Unknown(42112))
.map_err(|e| CogError::TagsNotFound(e, vec![42112], 0, PathBuf::new()))?;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just return None. It's normal a tiff file have no tag 42112

@@ -75,9 +79,14 @@ impl Source for CogSource {
Decoder::new(tif_file).map_err(|e| CogError::InvalidTiffFile(e, self.path.clone()))?;
decoder = decoder.with_limits(tiff::decoder::Limits::unlimited());

let ifd = self.meta.zoom_and_ifd.get(&(xyz.z)).ok_or_else(|| {
let actual_zoom = if let Some(google_zoom) = self.meta.google_compatible_max_zoom {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should calculate the actual_x and actual_y either.

@maplibre maplibre locked and limited conversation to collaborators Dec 30, 2024
@maplibre maplibre unlocked this conversation Dec 30, 2024
@sharkAndshark sharkAndshark changed the title Make COG GoogleMaps-Compatible when it's GoogleMapsCompatible Make tile service GoogleMaps-Compatible when the cog file is GoogleMapsCompatible Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant