Skip to content

Commit 4df3d46

Browse files
avoid usage of mosaic_def document (#1270)
* avoid usage of mosaic_def document * fix
1 parent c7eb1b1 commit 4df3d46

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
* add `/validate` endpoint via `ValidateExtension` extension
88
* add `Latitude` and `Longitude` as compatible spatial dimensions (@abarciauskas-bgse, https://github.com/developmentseed/titiler/pull/1268)
99

10+
### titiler.mosaic
11+
12+
* remove usage of `mosaic_def.center` and calculate from bounds
13+
1014
## 0.25.0 (2025-11-07)
1115

1216
### Misc

src/titiler/application/tests/routes/test_mosaic.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ def test_tilejson(app):
8282
assert body["minzoom"] == mosaicjson["minzoom"]
8383
assert body["maxzoom"] == mosaicjson["maxzoom"]
8484
assert body["bounds"] == mosaicjson["bounds"]
85-
assert body["center"] == mosaicjson["center"]
8685

8786

8887
def test_point(app):

src/titiler/mosaic/titiler/mosaic/factory.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -696,15 +696,19 @@ def tilejson(
696696
reader_options=reader_params.as_dict(),
697697
**backend_params.as_dict(),
698698
) as src_dst:
699-
center = list(src_dst.mosaic_def.center)
700-
if minzoom is not None:
701-
center[-1] = minzoom
702-
699+
bounds = src_dst.get_geographic_bounds(tms.rasterio_geographic_crs)
700+
minzoom = minzoom if minzoom is not None else src_dst.minzoom
701+
maxzoom = maxzoom if maxzoom is not None else src_dst.maxzoom
702+
center = (
703+
(bounds[0] + bounds[2]) / 2,
704+
(bounds[1] + bounds[3]) / 2,
705+
minzoom,
706+
)
703707
return {
704-
"bounds": src_dst.bounds,
708+
"bounds": bounds,
705709
"center": tuple(center),
706-
"minzoom": minzoom if minzoom is not None else src_dst.minzoom,
707-
"maxzoom": maxzoom if maxzoom is not None else src_dst.maxzoom,
710+
"minzoom": minzoom,
711+
"maxzoom": maxzoom,
708712
"tiles": [tiles_url],
709713
"attribution": os.environ.get("TITILER_DEFAULT_ATTRIBUTION"),
710714
}

0 commit comments

Comments
 (0)