Skip to content

Commit

Permalink
Honor renderWorldCopies in Transform.getVisibleUnwrappedCoordinates()
Browse files Browse the repository at this point in the history
  • Loading branch information
Asheem Mamoowala committed Jan 2, 2018
1 parent ca01a1e commit bca2f06
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/geo/transform.js
Expand Up @@ -196,9 +196,11 @@ class Transform {
const w0 = Math.floor(ul.column);
const w1 = Math.floor(ur.column);
const result = [new UnwrappedTileID(0, tileID)];
for (let w = w0; w <= w1; w++) {
if (w === 0) continue;
result.push(new UnwrappedTileID(w, tileID));
if (this._renderWorldCopies) {
for (let w = w0; w <= w1; w++) {
if (w === 0) continue;
result.push(new UnwrappedTileID(w, tileID));
}
}
return result;
}
Expand Down
19 changes: 18 additions & 1 deletion test/unit/geo/transform.test.js
Expand Up @@ -3,8 +3,8 @@
const test = require('mapbox-gl-js-test').test;
const Point = require('@mapbox/point-geometry');
const Transform = require('../../../src/geo/transform');
const OverscaledTileID = require('../../../src/source/tile_id').OverscaledTileID;
const LngLat = require('../../../src/geo/lng_lat');
const {OverscaledTileID, CanonicalTileID} = require('../../../src/source/tile_id');

const fixed = require('mapbox-gl-js-test/fixed');
const fixedLngLat = fixed.LngLat;
Expand Down Expand Up @@ -234,5 +234,22 @@ test('transform', (t) => {
t.end();
});

t.test('visibleUnwrappedCoordinates', (t) => {
const transform = new Transform();
transform.resize(200, 200);
transform.zoom = 0;
transform.center = { lng: -170.01, lat: 0.01 };

let unwrappedCoords = transform.getVisibleUnwrappedCoordinates(new CanonicalTileID(0, 0, 0));
t.equal(unwrappedCoords.length, 2);

//getVisibleUnwrappedCoordinates should honor _renderWorldCopies
transform._renderWorldCopies = false;
unwrappedCoords = transform.getVisibleUnwrappedCoordinates(new CanonicalTileID(0, 0, 0));
t.equal(unwrappedCoords.length, 1);

t.end();
});

t.end();
});

0 comments on commit bca2f06

Please sign in to comment.