Skip to content

Commit

Permalink
rename additionalRadius to queryPadding
Browse files Browse the repository at this point in the history
  • Loading branch information
ansis committed Mar 6, 2018
1 parent ea8a2ee commit b4d0f13
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/data/feature_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type QueryParameters = {
bearing: number,
tileSize: number,
queryGeometry: Array<Array<Point>>,
additionalRadius: number,
queryPadding: number,
params: {
filter: FilterSpecification,
layers: Array<string>,
Expand Down Expand Up @@ -98,7 +98,7 @@ class FeatureIndex {
filter = featureFilter(params.filter);

const queryGeometry = args.queryGeometry;
const additionalRadius = args.additionalRadius * pixelsToTileUnits;
const queryPadding = args.queryPadding * pixelsToTileUnits;

let minX = Infinity;
let minY = Infinity;
Expand All @@ -115,7 +115,7 @@ class FeatureIndex {
}
}

const matching = this.grid.query(minX - additionalRadius, minY - additionalRadius, maxX + additionalRadius, maxY + additionalRadius);
const matching = this.grid.query(minX - queryPadding, minY - queryPadding, maxX + queryPadding, maxY + queryPadding);
matching.sort(topDownFeatureComparator);
this.filterMatching(result, matching, this.featureIndexArray, queryGeometry, filter, params.layers, styleLayers, args.bearing, pixelsToTileUnits);

Expand Down
6 changes: 3 additions & 3 deletions src/source/source_cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -705,15 +705,15 @@ class SourceCache extends Evented {
const tile = this._tiles[ids[i]];
const tileID = tile.tileID;
const scale = Math.pow(2, this.transform.zoom - tile.tileID.overscaledZ);
const additionalRadius = tile.additionalRadius * EXTENT / tile.tileSize / scale;
const queryPadding = tile.queryPadding * EXTENT / tile.tileSize / scale;

const tileSpaceBounds = [
coordinateToTilePoint(tileID, new Coordinate(minX, minY, z)),
coordinateToTilePoint(tileID, new Coordinate(maxX, maxY, z))
];

if (tileSpaceBounds[0].x - additionalRadius < EXTENT && tileSpaceBounds[0].y - additionalRadius < EXTENT &&
tileSpaceBounds[1].x + additionalRadius >= 0 && tileSpaceBounds[1].y + additionalRadius >= 0) {
if (tileSpaceBounds[0].x - queryPadding < EXTENT && tileSpaceBounds[0].y - queryPadding < EXTENT &&
tileSpaceBounds[1].x + queryPadding >= 0 && tileSpaceBounds[1].y + queryPadding >= 0) {

const tileSpaceQueryGeometry = [];
for (let j = 0; j < queryGeometry.length; j++) {
Expand Down
10 changes: 5 additions & 5 deletions src/source/tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class Tile {
refreshedUponExpiration: boolean;
reloadCallback: any;
resourceTiming: ?Array<PerformanceResourceTiming>;
additionalRadius: number;
queryPadding: number;

/**
* @param {OverscaledTileID} tileID
Expand All @@ -104,7 +104,7 @@ class Tile {
this.tileSize = size;
this.buckets = {};
this.expirationTime = null;
this.additionalRadius = 0;
this.queryPadding = 0;

// Counts the number of times a response was already expired when
// received. We're using this to add a delay when making a new request
Expand Down Expand Up @@ -168,10 +168,10 @@ class Tile {
}
}

this.additionalRadius = 0;
this.queryPadding = 0;
for (const id in this.buckets) {
const bucket = this.buckets[id];
this.additionalRadius = Math.max(this.additionalRadius, painter.style.getLayer(bucket.layerIds[0]).queryRadius(bucket));
this.queryPadding = Math.max(this.queryPadding, painter.style.getLayer(bucket.layerIds[0]).queryRadius(bucket));
}

if (data.iconAtlasImage) {
Expand Down Expand Up @@ -266,7 +266,7 @@ class Tile {
tileSize: this.tileSize,
bearing: bearing,
params: params,
additionalRadius: this.additionalRadius,
queryPadding: this.queryPadding,
collisionBoxArray: this.collisionBoxArray,
sourceID: sourceID,
collisionIndex: collisionIndex,
Expand Down

0 comments on commit b4d0f13

Please sign in to comment.