Hi
Has anybody looked for storing requested tiles from the ImageProvider in IndexedDB ?
I’m trying to store localy some tile from my geoserver
I have writen a simple class to access IndexedDB with the forllowing prototype :
TileCacheService()
TileCacheService.createDB()
var data = TileCacheService.getTile(x,y,level)
TileCacheService.addtTile(x,y,level,data)
The Idea is to create an IndexedDBImageryProvider with the same prototype that an ImageryProvider
This IndexedDBImageryProvider takes a defaultProvider as a parameter. (I’m using a WebMapServiceImageryProvider).
Here is the requestImage function I'm trying to write;
IndexedDBImageryProvider.prototype.requestImage = function(x, y, level) {
// If the requested tile is in the TileCacheService then return it
// Otherwise use _defaultProvider to request the tile
var that =this;
var tileDataPromise= this.tileCacheService.getTileData(x,y,level);
var retour = Cesium.when(tileDataPromise, function (tileData) {
return tileData.data;
}).otherwise(function (evt) {
var promises = that._defaultProvider.requestImage(x,y,level);
var retour2 = Cesium.when(promises, function (tileData) {
// tileData is a HTMLImageElement ...
// we should convert HTMLImageElement to a blob as it's done in the following sample
// ex https://github.com/BabylonJS/Babylon.js/blob/master/Babylon/Tools/babylon.database.ts
that.tileCacheService.addTile(x,y,level,tileData);
return tileData;
});
return promises;
});
return retour;
};
I need to convert the HTMLImageElement into a blob before storing it in the indexedDB. Any idea how to do this ?
There is something like this in the following example : https://github.com/BabylonJS/Babylon.js/blob/master/Babylon/Tools/babylon.database.ts
xlhomme