From dc6f9dfe2ecbf28e1ea1c1cd68dab40619e56209 Mon Sep 17 00:00:00 2001 From: vincentsarago Date: Thu, 15 Feb 2024 21:54:07 +0100 Subject: [PATCH] limit layer bounds to the max TMS bounds --- .gitignore | 2 ++ titiler/cmr/templates/map.html | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/.gitignore b/.gitignore index f35704d..72466f3 100644 --- a/.gitignore +++ b/.gitignore @@ -105,3 +105,5 @@ ENV/ cdk.out/ node_modules cdk.context.json + +notebooks/ diff --git a/titiler/cmr/templates/map.html b/titiler/cmr/templates/map.html index e67283a..9744217 100644 --- a/titiler/cmr/templates/map.html +++ b/titiler/cmr/templates/map.html @@ -122,6 +122,14 @@ // Bounds crossing dateline if (bounds[0] > bounds[2]) { bounds[0] = bounds[0] - 360 + } else { + // Avoid bounds overflow and limit to the max TileMatrixSet bbox + bounds = [ + max(bounds[0], tms.xy_bbox.left), + max(bounds[1], tms.xy_bbox.bottom), + min(bounds[2], tms.xy_bbox.right), + min(bounds[3], tms.xy_bbox.top), + ] } var left = bounds[0], bottom = bounds[1],