mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-12-01 17:46:07 +03:00
Move cache-key generation to TileSource: user might need to override default behaviour in case of non-unique URL's (post data used).
This commit is contained in:
parent
7f784835a7
commit
2750100d24
@ -54,8 +54,9 @@
|
|||||||
* with HTML the entire tile is always used.
|
* with HTML the entire tile is always used.
|
||||||
* @param {String} postData HTTP POST data (usually but not necessarily in k=v&k2=v2... form,
|
* @param {String} postData HTTP POST data (usually but not necessarily in k=v&k2=v2... form,
|
||||||
* see TileSrouce::getPostData) or null
|
* see TileSrouce::getPostData) or null
|
||||||
|
* @param {String} cacheKey key to act as a tile cache, must be unique for tiles with unique image data
|
||||||
*/
|
*/
|
||||||
$.Tile = function(level, x, y, bounds, exists, url, context2D, loadWithAjax, ajaxHeaders, sourceBounds, postData) {
|
$.Tile = function(level, x, y, bounds, exists, url, context2D, loadWithAjax, ajaxHeaders, sourceBounds, postData, cacheKey) {
|
||||||
/**
|
/**
|
||||||
* The zoom level this tile belongs to.
|
* The zoom level this tile belongs to.
|
||||||
* @member {Number} level
|
* @member {Number} level
|
||||||
@ -131,11 +132,7 @@ $.Tile = function(level, x, y, bounds, exists, url, context2D, loadWithAjax, aja
|
|||||||
* @member {String} cacheKey
|
* @member {String} cacheKey
|
||||||
* @memberof OpenSeadragon.Tile#
|
* @memberof OpenSeadragon.Tile#
|
||||||
*/
|
*/
|
||||||
if (this.ajaxHeaders) {
|
this.cacheKey = cacheKey;
|
||||||
this.cacheKey = this.url + "+" + JSON.stringify(this.ajaxHeaders);
|
|
||||||
} else {
|
|
||||||
this.cacheKey = this.url;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Is this tile loaded?
|
* Is this tile loaded?
|
||||||
* @member {Boolean} loaded
|
* @member {Boolean} loaded
|
||||||
|
@ -1530,7 +1530,8 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
|
|||||||
this.loadTilesWithAjax,
|
this.loadTilesWithAjax,
|
||||||
ajaxHeaders,
|
ajaxHeaders,
|
||||||
sourceBounds,
|
sourceBounds,
|
||||||
post
|
post,
|
||||||
|
tileSource.getTileHashKey(level, xMod, yMod, url, ajaxHeaders, post)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.getFlip()) {
|
if (this.getFlip()) {
|
||||||
|
@ -639,7 +639,11 @@ $.TileSource.prototype = {
|
|||||||
* let result = new FormData();
|
* let result = new FormData();
|
||||||
* result.append("data", myData);
|
* result.append("data", myData);
|
||||||
* return result;
|
* return result;
|
||||||
|
*
|
||||||
|
* IMPORTANT: in case you move all the logic on image fetching
|
||||||
|
* to post data, you must re-define 'getTileHashKey(...)' to
|
||||||
|
* stay unique for different tile images.
|
||||||
|
*
|
||||||
* @param level
|
* @param level
|
||||||
* @param x
|
* @param x
|
||||||
* @param y
|
* @param y
|
||||||
@ -666,6 +670,29 @@ $.TileSource.prototype = {
|
|||||||
return {};
|
return {};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Most tiles are cached because their 'context2D' property is null (otherwise no caching occurs).
|
||||||
|
* Then, their cache is uniquely determined by this key: this key should be different if images
|
||||||
|
* are different! Note: default behaviour does not take into account post data.
|
||||||
|
*
|
||||||
|
* A tile can have either context2D defined (TileSource.prototype.getContext2D)
|
||||||
|
* or it's context2D is set manually. In those cases cache is not used and this function
|
||||||
|
* is irrelevant.
|
||||||
|
* @param level tile level it was fetched with
|
||||||
|
* @param x x-coordinate in the pyramid level
|
||||||
|
* @param y y-coordinate in the pyramid level
|
||||||
|
* @param url the tile was fetched with
|
||||||
|
* @param ajaxHeaders the tile was fetched with
|
||||||
|
* @param post data the tile was fetched with
|
||||||
|
*/
|
||||||
|
getTileHashKey: function(level, x, y, url, ajaxHeaders, post) {
|
||||||
|
if (ajaxHeaders) {
|
||||||
|
return url + "+" + JSON.stringify(ajaxHeaders);
|
||||||
|
} else {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function
|
* @function
|
||||||
* @param {Number} level
|
* @param {Number} level
|
||||||
|
Loading…
Reference in New Issue
Block a user