-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* source.change -> data * source.load -> sourceload & data * style.change -> data * style.load -> data, styleload * tile.add -> dataloading * tile.load -> data * tile.remove -> data * Unrename "source.load" and "style.load" * source.add & source.remove -> data * layer.add & layer.remove -> data * Remove isDataRemoved flag * Add documentation for "data" event * Fix setDataPerf benchmark utility * Minor doc fix * Add docs for dataloading event * merge 'sprite' and 'style' into 'style' * merge all several types into 'source' * Refactor "set data perf" benchmark utility * Ensure "Map#_update(true)" is only called after style mutations * Ensure Attribution#_update is only called for "data[dataType=source]" events * Attach Source, not SourceCache, to data events
- Loading branch information
Showing
19 changed files
with
150 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,29 @@ | ||
'use strict'; | ||
|
||
var NUM_TILES = 6; | ||
|
||
module.exports = function(source, numCalls, geojson, cb) { | ||
var tileCount = 0; | ||
module.exports = function(sourceCache, data, callback) { | ||
var sampleCount = 50; | ||
var startTime = null; | ||
var times = []; | ||
|
||
source.on('tile.load', function tileCounter() { | ||
tileCount++; | ||
if (tileCount === NUM_TILES) { | ||
tileCount = 0; | ||
times.push(performance.now() - startTime); | ||
var samples = []; | ||
|
||
if (times.length < numCalls) { | ||
sourceCache.on('data', function onData() { | ||
if (sourceCache.loaded()) { | ||
samples.push(performance.now() - startTime); | ||
sourceCache.off('data', onData); | ||
if (samples.length < sampleCount) { | ||
startTime = performance.now(); | ||
source.setData(geojson); | ||
sourceCache.clearTiles(); | ||
sourceCache.on('data', onData); | ||
sourceCache.getSource().setData(data); | ||
} else { | ||
var avgTileTime = times.reduce(function (v, t) { | ||
return v + t; | ||
}, 0) / times.length; | ||
source.off('tile.load', tileCounter); | ||
cb(null, avgTileTime); | ||
callback(null, average(samples)); | ||
} | ||
} | ||
}); | ||
|
||
startTime = performance.now(); | ||
source.setData(geojson); | ||
sourceCache.getSource().setData(data); | ||
}; | ||
|
||
function average(array) { | ||
return array.reduce(function (sum, value) { return sum + value; }, 0) / array.length; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
With this change, we no longer have access to the tile coordinate in event handlers when a tile is removed. Was this change intentional? Any reason we can't include the tile here and indicate that it's been removed?