Skip to content

Commit

Permalink
fix querySourceFeatures on overscaled tiles (mapbox#7061)
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner authored and pirxpilot committed Jun 18, 2019
1 parent 49ba2cb commit ab6f4a2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/source/tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,14 @@ 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);
(geojsonFeature).tile = coord;
const geojsonFeature = new GeoJSONFeature(feature, z, x, y);
geojsonFeature.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 @@ -19,7 +19,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 @@ -36,6 +36,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 ab6f4a2

Please sign in to comment.