I’ve studied the heightmap terrain spec and I think I have a grasp of it. However, I’d appreciate if someone could confirm my understandings:
The binary data format for heights is unsigned int16 (as opposed to signed int16), so that the possible range of terrain heights that can be represented is -1000 m to 12107 m. The upper bound is computed from 65535/5 - 1000.
A terrain file contains data for 65x65 points, starting in NorthWest corner and tracing values East. The data points correspond to a regular grid over the lat/lon limits of the tile with regular lat/lon spacing between data points. As an example, file 1/0/0.terrain defines terrain for the range -180 to -90 longitude and -90 to 0 latitude. That means that the first value in the terrain file corresponds to longitude -180 and latitude 0. The spacing between data points in degrees would then be 90/(65-1)=1.4063, so that the second data point would represent longitude -178.5937 and latitude 0, since it is directly East of the first point by the spacing amount.
If someone had terrain files in a different format than .terrain, they could implement support for it in Cesium by writing a custom terrain provider. For example, if someone had the same TMS-style file folder layout but had a different format of file, it should be fairly straightforward to write a class implementing the TerrainProvider interface to support it.
Is that all right?