Skip to content

Commit

Permalink
Fix 5486 (#5518)
Browse files Browse the repository at this point in the history
* add failing unit test

* fix 5486. Do not allow variable zoom tiles just because the top padding is non-zero. Only allow variable zoom at high pitch or when terrain is enabled.

* update changelog
  • Loading branch information
NathanMOlson authored Feb 20, 2025
1 parent 8bf8132 commit b61bb03
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- _...Add new stuff here..._
- Fix how padding is applied when using flyTo() with Globe ([#5406](https://github.com/maplibre/maplibre-gl-js/pull/5406))
- Fix URL hash validation to support bearing range -180 to 180 ([#5461](https://github.com/maplibre/maplibre-gl-js/issues/5461))
- Fix variable zoom tile calculation when padding is set ([#5486](https://github.com/maplibre/maplibre-gl-js/issues/5486))

## 5.1.0

Expand Down
16 changes: 16 additions & 0 deletions src/geo/projection/covering_tiles.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,22 @@ describe('coveringTiles', () => {
new OverscaledTileID(10, 0, 10, 511, 512),
new OverscaledTileID(10, 0, 10, 512, 512)]);

transform.resize(2048, 128);
transform.setZoom(9);
transform.setPadding({top: 16});
expect(coveringTiles(transform, options)).toEqual([
new OverscaledTileID(9, 0, 9, 255, 255),
new OverscaledTileID(9, 0, 9, 256, 255),
new OverscaledTileID(9, 0, 9, 255, 256),
new OverscaledTileID(9, 0, 9, 256, 256),
new OverscaledTileID(9, 0, 9, 254, 255),
new OverscaledTileID(9, 0, 9, 254, 256),
new OverscaledTileID(9, 0, 9, 257, 255),
new OverscaledTileID(9, 0, 9, 257, 256),
new OverscaledTileID(9, 0, 9, 253, 255),
new OverscaledTileID(9, 0, 9, 253, 256)]);

transform.setPadding({top: 0});
transform.setZoom(5.1);
transform.setPitch(60.0);
transform.setBearing(32.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class MercatorCoveringTilesDetailsProvider implements CoveringTilesDetail
allowVariableZoom(transform: IReadonlyTransform, options: CoveringTilesOptions): boolean {
const zfov = transform.fov * (Math.abs(Math.cos(transform.rollInRadians)) * transform.height + Math.abs(Math.sin(transform.rollInRadians)) * transform.width) / transform.height;
const maxConstantZoomPitch = clamp(78.5 - zfov / 2, 0.0, 60.0);
return (!!options.terrain || transform.pitch > maxConstantZoomPitch || transform.padding.top >= 0.1);
return (!!options.terrain || transform.pitch > maxConstantZoomPitch);
}

allowWorldCopies(): boolean {
Expand Down

0 comments on commit b61bb03

Please sign in to comment.