I started a quick investigation of a client side query function. I set it up to be called like this…
// user fills an array of Cesium.Cartographic() query locations
// the height value of the points will be modified in place
var terrainProvider = new Cesium.CesiumTerrainProvider(…);
var cartPts = … ;
var tileLevel = 8; // The desired tile level for queries
Cesium.when(terrainProvider.queryElevation(cartPts, tileLevel, scene.getContext()), elevationSuccessFunction);
I’m then setting up a set of query tiles, requesting them manually, and doing as per the terrain providers but without the final createResources(). I’m assuming the output of transformGeometry() would be standard across the terrain providers since there’s a centralized createTileEllipsoidGeometryFromBuffers(). I’m therefore taking a similar approach and centralizing what I’ve done in TerrainProvider.js in the hope that it would work with other terrain providers. I’m also hopeful that there would automatically be some level of caching via the context since I’m still using the standard Cesium tile request mechanisms.
The mechanics seem to be starting to work and I can litter billboards across a terrain. There’s still issues to be worked through such as tile fail/rejections, interpolation etc. Also, sequencing of tile requests then transformation etc is a bit different in my case since I’m working outside of a draw loop so I’ve just blocked it in with setTimeout() calls for now.
I realize the approach I’ve investigated will be brittle as the terrain branch continues to evolve. You mentioned that terrain query is a service you would like to provide in the future. I’d like to gauge your level of interest in me cleaning up what I have so far and contributing this to the terrain branch so that it can be reviewed, integrated and kept in sync with the work you are doing. If not, it would still be helpful for me if I could quiz you on details at some stage. A client side query seems appealing to me, particularly if it could work across the various terrain providers.