mapbox / mapbox/mapbox-gl-js

wrong tiles at low zooms with terrain enabled

Open
#10,826 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug :lady_beetle:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

An unpitched map with terrain enabled shows a tiles from a mix of zoom levels. It should show tiles from the same zoom level (the way it looks without terrain). The visual effect is more severe when using tilesets with sharper cutoffs (data exists in z2, but not z1).

I think `transform.coveringTiles(...)` is not returning the right tiles and I think this may be related to the [distance calculation it uses](https://github.com/mapbox/mapbox-gl-js/blob/0eecef1d3fd42e9ebc41546e6ff1b292e9213491/src/geo/transform.js#L757). I think it uses a 3D distance from the camera point to the tile when maybe it should be using just the z distance from the camera to the tile.

**mapbox-gl-js version**: main (0eecef1)

**browser**: all

### Steps to Trigger Behavior

1. `yarn run start-debug`
2. open `http://localhost:9966/debug/terrain-debug.html#2.06/54.49/71.37` with a large viewport (innerWidth: 1701, innerHeight: 1361)
3. set `map.showTileBoundaries = true` in the console

### Expected Behavior

Viewport covered by z2 tiles:

![Screen Shot 2021-07-07 at 4 26 20 PM](https://user-images.githubusercontent.com/1421652/124824301-2f560680-df40-11eb-95bc-331c3c0cecf6.png)

### Actual Behavior

Viewport covered by a mix of z1 and z2 tiles:

![Screen Shot 2021-07-07 at 4 25 55 PM](https://user-images.githubusercontent.com/1421652/124824315-32e98d80-df40-11eb-9921-795e7267a5ee.png)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run `yarn run start-debug`, open the terrain debug URL from the report with a large viewport, and enable `map.showTileBoundaries`. Start in `src/geo/transform.js` at `transform.coveringTiles(...)` and its linked distance calculation; done means the viewport uses tiles from one zoom level, matching the no-terrain behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.