WCSTerrainProvider and IndexedDB : How to chain two promesis ?

I added to my WCSTerrainProvider a mechanism allowing me to store locally the heighmap buffer with IndexedDB.
The process works as follows:
I search in IndexedDB if the requested tile is present locally.
If the tile is present then I get the heighmap buffer and I return the HeightmapTerrainData
But, if the tile is not stored locally, I submit a WCS request. If the query is executed correctly, I parse the returned geotiff and create the buffer that I store in the local database then I return the HeightmapTerrainData.

My first tests are promising.
I encounter a problem to chain correctly the 2 promises in the requestTileGeometry function:
I have to define a promise “request Tile In IndexedDB” and if this promise is rejected then I have to define a new promise “request Tile in WCS”

which gives:
Cesium.when (requestTileInIndexedDB, function (tileData) {…
return heightmapTerrainData ;
}) .otherwise (Function (evt)
{
var promiseGetCoverage = Cesium.loadWithXh ({url: urlGetCoverage, responseType ‘ArrayBuffer’});
Cesium.when (promiseGetCoverage, function (image) {…
return heightmapTerrainData ; }) .otherwise …

})

What should return the first Otherwise function ? if I return the second promise Cesium throw an issue because I do not return a heightmapTerrainData but a promise.

xlhomme

Hello,
you can see the documentation of when here : https://github.com/cujojs/when/blob/master/docs/api.md#promisecatch

Hi,

Returning the chained promise from the otherwise callback should work. If you’re still having trouble getting that to work, please share your exact code and the error that you’re seeing.

Kevin

Indeed it works ! I wasn’t returning the promesis but undefined…