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 issue #5248: don't redo placement for zoom changes of low-pitch m… #5284

Merged
merged 1 commit into from
Sep 14, 2017
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
7 changes: 4 additions & 3 deletions src/source/tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,17 +226,18 @@ class Tile {
const cameraToTileDistance = source.map.transform.cameraToTileDistance(this);
if (this.angle === source.map.transform.angle &&
this.pitch === source.map.transform.pitch &&
this.cameraToCenterDistance === source.map.transform.cameraToCenterDistance &&
this.showCollisionBoxes === source.map.showCollisionBoxes) {
if (this.cameraToTileDistance === cameraToTileDistance) {
if (this.cameraToTileDistance === cameraToTileDistance &&
this.cameraToCenterDistance === source.map.transform.cameraToCenterDistance) {
return;
} else if (this.pitch < 25) {
// At low pitch tile distance doesn't affect placement very
// much, so we skip the cost of redoPlacement
// However, we might as well store the latest value of
// cameraToTileDistance in case a redoPlacement request
// cameraToTileDistance and cameraToCenterDistance in case a redoPlacement request
// is already queued.
this.cameraToTileDistance = cameraToTileDistance;
this.cameraToCenterDistance = source.map.transform.cameraToCenterDistance;
return;
}
}
Expand Down
35 changes: 35 additions & 0 deletions test/unit/source/tile.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,41 @@ test('Tile#redoPlacement', (t) => {
});
});

test('changing cameraToCenterDistance does not trigger placement for low pitch', (t)=>{
const tile = new Tile(new TileCoord(1, 1, 1));
tile.loadVectorData(createVectorData(), createPainter());
t.stub(tile, 'reloadSymbolData').returns(null);
const source1 = util.extend(new Evented(), {
type: 'vector',
dispatcher: {
send: (name, data, cb) => {
cb();
}
},
map: {
transform: { cameraToCenterDistance: 1, pitch: 10, cameraToTileDistance: () => { return 1; } },
painter: { tileExtentVAO: {vao: 0}}
}
});

const source2 = util.extend(new Evented(), {
type: 'vector',
dispatcher: {
send: () => {}
},
map: {
transform: { cameraToCenterDistance: 2, pitch: 10, cameraToTileDistance: () => { return 1; } },
painter: { tileExtentVAO: {vao: 0}}
}
});

tile.redoPlacement(source1);
tile.redoPlacement(source2);

t.ok(tile.state === 'loaded');
t.end();
});

t.end();
});

Expand Down