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

replace geographic_bounds with bounds and removes maxzoom, minzoom from info() response #744

Closed
vincentsarago opened this issue Oct 7, 2024 · 3 comments

Comments

@vincentsarago
Copy link
Member

Those variable depends on the TMS and on the geographic CRS, which then needs to be passed and rightfully configured when opening the file

class Bounds(RioTilerBaseModel):
"""Dataset Bounding box"""
bounds: BoundingBox
class SpatialInfo(Bounds):
"""Dataset SpatialInfo"""
minzoom: int
maxzoom: int
class Info(SpatialInfo):

ref: developmentseed/titiler#995 (comment)

@AndrewAnnex
Copy link
Contributor

I disagree, see developmentseed/titiler#995 (comment)

@vincentsarago
Copy link
Member Author

started something over #745

when we started rio-tiler, things were simple, the module was mainly for creating Tile image in one TMS. Things changed and now rio-tiler can de way more than this, which motivate the decision for removing the TMS from the Class attribute.

Once we remove the TMS attribute, we also need to remove the min/max zoom and in a way also the geographic crs.

This makes things (IMO) way more simpler.

The PR also removes the min/maxzoom from the info response because it's IMO useless to have this info here (we don't return the TMS in the response so the values are almost unitless. Same for the bounds, we were returning the bounds in the geographic_crs but without return the CRS it self. I believe it's easier to return the dataset bounds + crs itself.

Users can easily get the min/maxzoom and geographic CRS with 3 lines of code:

# before 
tms = morecantile.tms.get("WebMercatorQuad")
with Reader("cog.tif", tms=tms, geographic_crs=tms.rasterio_geographic_crs) as src:
    bounds = src.geographic_bounds
    minzoom, maxzoom = src.minzoom, src.maxzoom

# now
tms = morecantile.tms.get("WebMercatorQuad")
with Reader("cog.tif") as src:
    bounds = src.geographic_bounds(tms.rasterio_geographic_crs)
    minzoom, maxzoom = src.get_zooms(tms)

@AndrewAnnex
Copy link
Contributor

@vincentsarago added a comment or two to that pr, my only concern really is that any given cog should have an a CRS associated from it, and so to me as a user the geographic_bounds should probably be a bit more implicit and return the bounds in the geographic CRS appropriate to the COG itself rather than always defaulting to WGS_84, and the Reader should inspect the meta data for the asset to determine that, so that the following is enabled:

# earth cog is in some projection with a WGS84 ellipsoid
with Reader("earth_cog.tif") as src_earth:
    # the geographic_crs for the cog happens to be WGS84
    bounds_4326 = src_earth.geographic_bounds() 
    # using a different geographic crs
    bounds_grs67 = src_earth.geographic_bounds(GRS1967)
   
# mars cog is using IAU:49900 geographic crs
with Reader("mars_cog.tif") as src_mars:
      # this should work, but current pr would not allow it to work
      bounds_49900 = src.geographic_bounds()
      # this should fail
      _ = src_mars.geographic_bounds(WGS84) 

@vincentsarago vincentsarago changed the title remove geographic bounds, maxzoom, minzoom from info() method replace geographic_bounds with bounds and removes maxzoom, minzoom from info() response Oct 8, 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
2 participants