Skip to content

Commit

Permalink
fix querySourceFeatures on overscaled tiles (#7061)
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner committed Aug 2, 2018
1 parent 47e637c commit 3ffa20a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/source/tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,13 @@ class Tile {
if (!layer) return;

const filter = featureFilter(params && params.filter);
const coord = { z: this.tileID.overscaledZ, x: this.tileID.canonical.x, y: this.tileID.canonical.y };
const {z, x, y} = this.tileID.canonical;
const coord = {z, x, y};

for (let i = 0; i < layer.length; i++) {
const feature = layer.feature(i);
if (filter(new EvaluationParameters(this.tileID.overscaledZ), feature)) {
const geojsonFeature = new GeoJSONFeature(feature, coord.z, coord.x, coord.y);
const geojsonFeature = new GeoJSONFeature(feature, z, x, y);
(geojsonFeature: any).tile = coord;
result.push(geojsonFeature);
}
Expand Down
3 changes: 2 additions & 1 deletion test/unit/source/tile.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test('querySourceFeatures', (t) => {


t.test('geojson tile', (t) => {
const tile = new Tile(new OverscaledTileID(1, 0, 1, 1, 1));
const tile = new Tile(new OverscaledTileID(3, 0, 2, 1, 2));
let result;

result = [];
Expand All @@ -37,6 +37,7 @@ test('querySourceFeatures', (t) => {
result = [];
tile.querySourceFeatures(result);
t.equal(result.length, 1);
t.deepEqual(result[0].geometry.coordinates[0], [-90, 0]);
result = [];
tile.querySourceFeatures(result, {});
t.equal(result.length, 1);
Expand Down

0 comments on commit 3ffa20a

Please sign in to comment.