Skip to content

Commit

Permalink
add handleWrapJump tests (fixup)
Browse files Browse the repository at this point in the history
  • Loading branch information
ansis committed Apr 16, 2018
1 parent ee32a0b commit 4297d51
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/unit/source/source_cache.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,32 @@ test('SourceCache#update', (t) => {
sourceCache.onAdd();
});

t.test('reassigns tiles for large jumps in longitude', (t) => {

const transform = new Transform();
transform.resize(511, 511);
transform.zoom = 0;

const sourceCache = createSourceCache({});
sourceCache.on('data', (e) => {
if (e.sourceDataType === 'metadata') {
transform.center = new LngLat(360, 0);
const tileID = new OverscaledTileID(0, 1, 0, 0, 0);
sourceCache.update(transform);
t.deepEqual(sourceCache.getIds(), [tileID.key]);
const tile = sourceCache.getTile(tileID);

transform.center = new LngLat(0, 0);
const wrappedTileID = new OverscaledTileID(0, 0, 0, 0, 0);
sourceCache.update(transform);
t.deepEqual(sourceCache.getIds(), [wrappedTileID.key]);
t.equal(sourceCache.getTile(wrappedTileID), tile);
t.end();
}
});
sourceCache.onAdd();
});

t.end();
});

Expand Down
21 changes: 21 additions & 0 deletions test/unit/symbol/cross_tile_symbol_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,27 @@ test('CrossTileSymbolIndex.addLayer', (t) => {
t.end();
});

t.test('reuses indexes when longitude is wrapped', (t) => {
const index = new CrossTileSymbolIndex();
const longitude = 370;

const tileID = new OverscaledTileID(6, 1, 6, 8, 8);
const firstInstances = [
makeSymbolInstance(1000, 1000, ""), // A
];
const tile = makeTile(tileID, firstInstances);

index.addLayer(styleLayer, [tile], longitude);
t.equal(firstInstances[0].crossTileID, 1); // A

tile.tileID = tileID.wrapped();

index.addLayer(styleLayer, [tile], longitude % 360);
t.equal(firstInstances[0].crossTileID, 1);
t.end();

});

t.end();
});

Expand Down

0 comments on commit 4297d51

Please sign in to comment.