Skip to content

fix: improve minimum zoom calculation in TileRanger#92

Merged
razbroc merged 3 commits into
masterfrom
fix/range-calc
May 19, 2026
Merged

fix: improve minimum zoom calculation in TileRanger#92
razbroc merged 3 commits into
masterfrom
fix/range-calc

Conversation

@razbroc
Copy link
Copy Markdown
Contributor

@razbroc razbroc commented May 19, 2026

This pull request makes a targeted improvement to the TileRanger class in src/geo/tileRanger.ts. The main change is a fix to how the minimum zoom level is calculated, particularly for edge cases where the bounding range width or height is zero. This prevents invalid or negative zoom levels and ensures the zoom does not exceed the current value.

Tile zoom calculation fix:

  • Updated the calculation of minXZoom and minYZoom to handle cases where dx or dy are zero, defaulting to the current zoom value in those cases. Also, ensured that minZoom does not exceed the current zoom by including it in the Math.min call.
Question Answer
Bug fix

Copy link
Copy Markdown
Contributor

@vitaligi vitaligi left a comment

Choose a reason for hiding this comment

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

please add a test for the case when the input bbox generates a range with a single tile:
{minX: 0, maxX: 0, minY: 1, maxY: 1}

Comment thread src/geo/tileRanger.ts Outdated
@razbroc razbroc merged commit 5e4b91e into master May 19, 2026
3 of 4 checks passed
@razbroc razbroc deleted the fix/range-calc branch May 19, 2026 20:21
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.

3 participants