added some code comments for addtl clarification

This commit is contained in:
andygup 2014-02-08 16:06:24 -07:00
parent 3dd0ecb1fc
commit 03ff996ccb

View File

@ -287,19 +287,31 @@ define([
/* internal methods */
/**
* Makes a request to a tile url and uses that as a basis for the
* the average tile size.
* Future Iterations could call multiple tiles and do an actual average.
* @param callback
* @returns {Number} Returns NaN if there was a problem retrieving the tile
*/
layer.estimateTileSize = function(callback)
{
var url = this.offline.proxyPath + "?" + layer._tileUrlArr[0];
var size = 0;
request.get(url,{
handleAs: "text/plain; charset=x-user-defined",
headers: { // This is required to stop the
"X-Requested-With": "" // server from rejecting the
}
}).then(function(response){
var img = Base64Utils.wordToBase64(Base64Utils.stringToWord(response));
callback(img.length + url.length);
});
if(layer._tileUrlArr.length > 0){
var url = this.offline.proxyPath + "?" + layer._tileUrlArr[0];
request.get(url,{
handleAs: "text/plain; charset=x-user-defined",
headers: {
"X-Requested-With": "" //bypasses a dojo xhr bug
}
}).then(function(response){
var img = Base64Utils.wordToBase64(Base64Utils.stringToWord(response));
callback(img.length + url.length);
});
}
else{
return NaN;
}
};
layer.doNextTile = function(i, cells, reportProgress)