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

Fix uncautht OverscaledTileID error appearing with terrain enabled #1871

Merged
merged 4 commits into from
Nov 25, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@

### 🐞 Bug fixes
- *...Add new stuff here...*
- Fix `getElevation()` causing uncaught error ([#1650](https://github.com/maplibre/maplibre-gl-js/issues/1650)).
- Add dev version for csp build ([#1730](https://github.com/maplibre/maplibre-gl-js/pull/1730))
- Fix headless benchmark execution especially on VM ([#1732](https://github.com/maplibre/maplibre-gl-js/pull/1732))
- fix issue [#860](https://github.com/maplibre/maplibre-gl-js/issues/860) fill-pattern with pixelRatio > 1 is now switched correctly at runtime. ([#1765](https://github.com/maplibre/maplibre-gl-js/pull/1765))
- Fix the exception that would be thrown on `map.setStyle` when it is passed with transformStyle option and map is initialized without an initial style. ([#1824](https://github.com/maplibre/maplibre-gl-js/pull/1824))
- fix issue [#1582](https://github.com/maplibre/maplibre-gl-js/issues/1582) source maps are now properly generated


## 3.0.0-pre.1

### ✨ Features and improvements
Expand Down
12 changes: 12 additions & 0 deletions src/geo/transform.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@ describe('transform', () => {
expect(transform.tileZoom).toBe(transform.zoom);
});

test('set zoom inits tileZoom with zoom value', () => {
const transform = new Transform(0, 22, 0, 60);
transform.zoom = 5;
expect(transform.tileZoom).toBe(5);
});

test('set zoom clamps tileZoom to non negative value ', () => {
const transform = new Transform(-2, 22, 0, 60);
transform.zoom = -2;
expect(transform.tileZoom).toBe(0);
});

test('set fov', () => {
const transform = new Transform(0, 22, 0, 60, true);
transform.fov = 10;
Expand Down
12 changes: 5 additions & 7 deletions src/geo/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class Transform {
height: number;
angle: number;
rotationMatrix: mat2;
zoomFraction: number;
pixelsToGLUnits: [number, number];
cameraToCenterDistance: number;
cameraToSeaLevelDistance: number;
Expand Down Expand Up @@ -196,13 +195,12 @@ class Transform {

get zoom(): number { return this._zoom; }
set zoom(zoom: number) {
const z = Math.min(Math.max(zoom, this.minZoom), this.maxZoom);
if (this._zoom === z) return;
const constrainedZoom = Math.min(Math.max(zoom, this.minZoom), this.maxZoom);
if (this._zoom === constrainedZoom) return;
this._unmodified = false;
this._zoom = z;
this.scale = this.zoomScale(z);
this.tileZoom = Math.floor(z);
this.zoomFraction = z - this.tileZoom;
this._zoom = constrainedZoom;
this.tileZoom = Math.max(0, Math.floor(constrainedZoom));
this.scale = this.zoomScale(constrainedZoom);
this._constrain();
this._calcMatrices();
}
Expand Down