Skip to content

Commit

Permalink
Fix for maplibre#3935 - add test, update CHANGELOG
Browse files Browse the repository at this point in the history
  • Loading branch information
olsen232 committed Apr 4, 2024
1 parent ea7c8ae commit 95667c1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
- Added const enum for actor messages to improve readability and maintainability. In tsconfig.json, `isolatedModules` flag is set to false in favor of generated JS size. ([#3879](https://github.com/maplibre/maplibre-gl-js/issues/3879))

### 🐞 Bug fixes
- _...Add new stuff here..._
- Fix different unwanted panning changes at the end of a panning motion, that happen on a large screen ([#3935](https://github.com/maplibre/maplibre-gl-js/issues/3935))

## 4.1.2

Expand Down
22 changes: 19 additions & 3 deletions src/render/terrain.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ describe('Terrain', () => {

});

const setupMercatorOverflow = () => {
const setupMercatorOverflow = (pixelRatio: number = 1) => {
const WORLD_WIDTH = 4;
const painter = {
context: new Context(gl),
width: WORLD_WIDTH,
height: 1,
pixelRatio: 1,
maybeDrawDepthAndCoords: jest.fn(),
pixelRatio,
} as any as Painter;
const sourceCache = {} as SourceCache;
const terrain = new Terrain(painter, sourceCache, {} as any as TerrainSpecification);
Expand All @@ -91,7 +91,7 @@ describe('Terrain', () => {
rgba[0] = 0;
rgba[1] = 0;
rgba[2] = 0;
rgba[3] = 255 - x;
rgba[3] = 255 - x / pixelRatio;
});
return terrain;
};
Expand Down Expand Up @@ -122,6 +122,22 @@ describe('Terrain', () => {
expect(terrain.painter.maybeDrawDepthAndCoords).toHaveBeenCalled();
});

test(
'pointCoordinate should respect painter.pixelRatio',
() => {
const terrain = setupMercatorOverflow(2);

let pointX = 0;
let coordinate = terrain.pointCoordinate(new Point(pointX, 0));
expect(coordinate.x).toBe(-1);
expect(terrain.painter.maybeDrawDepthAndCoords).toHaveBeenCalled();

pointX = 3;
coordinate = terrain.pointCoordinate(new Point(pointX, 0));
expect(coordinate.x).toBe(2);
expect(terrain.painter.maybeDrawDepthAndCoords).toHaveBeenCalled();
});

test('Calculate tile minimum and maximum elevation', () => {
const tileID = new OverscaledTileID(5, 0, 5, 17, 11);
const tile = new Tile(tileID, 256);
Expand Down

0 comments on commit 95667c1

Please sign in to comment.