Skip to content

Commit

Permalink
fix overscaled featuresAt
Browse files Browse the repository at this point in the history
fix #2103
  • Loading branch information
ansis committed Feb 11, 2016
1 parent a7b8f5a commit 1de0a5e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion js/data/feature_tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ FeatureTree.prototype.query = function(args, callback) {
var radius, bounds;
if (typeof x !== 'undefined' && typeof y !== 'undefined') {
// a point (or point+radius) query
radius = (params.radius || 0) * EXTENT / args.scale;
radius = (params.radius || 0) * EXTENT / args.tileSize / args.scale;
bounds = [x - radius, y - radius, x + radius, y + radius];
} else {
// a rectangle query
Expand Down
1 change: 1 addition & 0 deletions js/source/source.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ exports._vectorFeaturesAt = function(coord, params, callback) {
x: result.x,
y: result.y,
scale: result.scale,
tileSize: result.tileSize,
source: this.id,
params: params
}, callback, result.tile.workerID);
Expand Down
3 changes: 2 additions & 1 deletion js/source/tile_pyramid.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,8 @@ TilePyramid.prototype = {
tile: tile,
x: pos.x,
y: pos.y,
scale: this.transform.worldSize / Math.pow(2, tile.coord.z)
scale: Math.pow(2, this.transform.zoom - tile.coord.z),
tileSize: tile.tileSize
};
}
}
Expand Down
16 changes: 12 additions & 4 deletions test/js/data/feature_tree.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ test('featuretree', function(t) {
ft.insert(feature.bbox(), 'road', feature);
ft.query({
params: { },
scale: 1,
tileSize: 512,
x: 0,
y: 0
}, function(err, features) {
Expand All @@ -48,6 +50,8 @@ test('featuretree with args', function(t) {
params: {
radius: 5
},
scale: 1,
tileSize: 512,
x: 0,
y: 0
}, function(err, features) {
Expand All @@ -68,7 +72,8 @@ test('featuretree point query', function(t) {

ft.query({
source: "mapbox.mapbox-streets-v5",
scale: 724.0773439350247,
scale: 1.4142135624,
tileSize: 512,
params: {
radius: 30,
includeGeometry: true
Expand Down Expand Up @@ -100,7 +105,8 @@ test('featuretree rect query', function(t) {

ft.query({
source: "mapbox.mapbox-streets-v5",
scale: 724.0773439350247,
scale: 1.4142135624,
tileSize: 512,
params: {
includeGeometry: true
},
Expand Down Expand Up @@ -149,7 +155,8 @@ test('featuretree query with layerIds', function(t) {

ft.query({
source: "mapbox.mapbox-streets-v5",
scale: 724.0773439350247,
scale: 1.4142135624,
tileSize: 512,
params: {
radius: 30,
layerIds: ['water']
Expand All @@ -163,7 +170,8 @@ test('featuretree query with layerIds', function(t) {

ft.query({
source: "mapbox.mapbox-streets-v5",
scale: 724.0773439350247,
scale: 1.4142135624,
tileSize: 512,
params: {
radius: 30,
layerIds: ['none']
Expand Down
3 changes: 2 additions & 1 deletion test/js/source/tile_pyramid.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ test('TilePyramid#tileAt', function(t) {
var result = pyramid.tileAt(new Coordinate(0, 3, 2));

t.deepEqual(result.tile.coord.id, 65);
t.deepEqual(result.scale, 724.0773439350247);
t.deepEqual(result.scale, 1.4142135623730951);
t.deepEqual(result.tileSize, 512);
t.deepEqual(result.x, 0);
t.deepEqual(result.y, 4096);

Expand Down

0 comments on commit 1de0a5e

Please sign in to comment.