Skip to content

Commit

Permalink
Update max padding statistic on tiles.
Browse files Browse the repository at this point in the history
  • Loading branch information
Asheem Mamoowala committed Apr 17, 2018
1 parent 05a3607 commit 25d23f9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/source/source_cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class SourceCache extends Evented {
this._source.prepare();
}

this._state.coalesceChanges(this._tiles);
this._state.coalesceChanges(this._tiles, this.map ? this.map.painter : null);
for (const i in this._tiles) {
this._tiles[i].upload(context);
}
Expand Down Expand Up @@ -250,7 +250,7 @@ class SourceCache extends Evented {
if (previousState === 'expired') tile.refreshedUponExpiration = true;
this._setTileReloadTimer(id, tile);
if (this.getSource().type === 'raster-dem' && tile.dem) this._backfillDEM(tile);
this._state.initializeTileState(tile);
this._state.initializeTileState(tile, this.map ? this.map.painter : null);

this._source.fire(new Event('data', {dataType: 'source', tile: tile, coord: tile.tileID}));

Expand Down Expand Up @@ -578,7 +578,7 @@ class SourceCache extends Evented {

tile = this._cache.getAndRemove((tileID.key: any));
if (tile) {
this._state.initializeTileState(tile);
this._state.initializeTileState(tile, this.map ? this.map.painter : null);
if (this._cacheTimers[tileID.key]) {
clearTimeout(this._cacheTimers[tileID.key]);
delete this._cacheTimers[tileID.key];
Expand Down
16 changes: 8 additions & 8 deletions src/source/source_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,20 @@ class SourceFeatureState {
return extend({}, base[feature], changes[feature]);
}

initializeTileState(tile: Tile) {
tile.updateFeatureState(this.state);
initializeTileState(tile: Tile, painter: any) {
tile.updateFeatureState(this.state, painter);
}

coalesceChanges(tiles: {[any]: Tile}) {
coalesceChanges(tiles: {[any]: Tile}, painter: any) {
const changes: LayerFeatureStates = {};
for (const sourceLayer in this.stateChanges) {
this.state[sourceLayer] = this.state[sourceLayer] || {};
const layerStates = {};
for (const id in this.stateChanges[sourceLayer]) {
this.state[sourceLayer][id] = extend(
{},
this.state[sourceLayer][id],
this.stateChanges[sourceLayer][id]);
if (!this.state[sourceLayer][id]) {
this.state[sourceLayer][id] = {};
}
extend(this.state[sourceLayer][id], this.stateChanges[sourceLayer][id]);
layerStates[id] = this.state[sourceLayer][id];
}
changes[sourceLayer] = layerStates;
Expand All @@ -70,7 +70,7 @@ class SourceFeatureState {

for (const id in tiles) {
const tile = tiles[id];
tile.updateFeatureState(changes);
tile.updateFeatureState(changes, painter);
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/source/tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ class Tile {
}
}

updateFeatureState(states: LayerFeatureStates) {
updateFeatureState(states: LayerFeatureStates, painter: any) {
if (!this.latestRawTileData || Object.keys(states).length === 0) return;

if (!this.vtLayers) {
Expand All @@ -433,6 +433,9 @@ class Tile {
if (!sourceLayer || !sourceLayerStates || Object.keys(sourceLayerStates).length === 0) continue;

bucket.update(sourceLayerStates, sourceLayer);
if (painter) {
this.queryPadding = Math.max(this.queryPadding, painter.style.getLayer(bucket.layerIds[0]).queryRadius(bucket));
}
}
}
}
Expand Down

0 comments on commit 25d23f9

Please sign in to comment.