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

update BaseBackend to use a default coord_crs from the tms #234

Merged
merged 3 commits into from
Oct 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions cogeo_mosaic/backends/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,12 @@ def assets_for_point(
self,
lng: float,
lat: float,
coord_crs: CRS = WGS84_CRS,
coord_crs: Optional[CRS] = None,
) -> List[str]:
"""Retrieve assets for point."""
mosaic_tms = self.mosaic_def.tilematrixset or WEB_MERCATOR_TMS

# default coord_crs should be the TMS's geographic CRS
coord_crs = coord_crs or self.tms.rasterio_geographic_crs
# If coord_crs is not the same as the mosaic's geographic CRS
# we reproject the coordinates
if coord_crs != mosaic_tms.rasterio_geographic_crs:
Expand All @@ -197,11 +198,12 @@ def assets_for_bbox(
ymin: float,
xmax: float,
ymax: float,
coord_crs: Optional[CRS] = WGS84_CRS,
coord_crs: Optional[CRS] = None,
) -> List[str]:
"""Retrieve assets for bbox."""
mosaic_tms = self.mosaic_def.tilematrixset or WEB_MERCATOR_TMS

# default coord_crs should be the TMS's geographic CRS
coord_crs = coord_crs or self.tms.rasterio_geographic_crs
# If coord_crs is not the same as the mosaic's geographic CRS
# we reproject the bounding box
if coord_crs != mosaic_tms.rasterio_geographic_crs:
Expand Down Expand Up @@ -315,11 +317,13 @@ def point(
self,
lon: float,
lat: float,
coord_crs: CRS = WGS84_CRS,
coord_crs: Optional[CRS] = None,
reverse: bool = False,
**kwargs: Any,
) -> List[PointData]:
"""Get Point value from multiple observation."""
# default coord_crs should be the TMS's geographic CRS
coord_crs = coord_crs or self.tms.rasterio_geographic_crs
mosaic_assets = self.assets_for_point(lon, lat, coord_crs=coord_crs)
if not mosaic_assets:
raise NoAssetFoundError(f"No assets found for point ({lon},{lat})")
Expand Down
Loading