Terrain is composed of N^2 tiles and therefore (N+1)^2 vertices. Heights are set for vertices while textures are set for tiles. rmgen conveniently ignored this fact until the off-by-one error popped up visually when painting terrain based on height. See the left bank of the river which does not have the correct texture as the corner vertex has a height above the threshold even though the tile itself is clearly below it.
In rP10878, TILE_CENTERED_HEIGHT_MAP flag was added. What it essentially does is remove the last row and column of vertices. Since it now matches the number of tiles for size N, the height values were set for the tile. Upon export, the actual vertices grid was reconstructed by calculating the mean of the 4 surrounding tile centers for each vertex. The final grid is now implicitly smoothed as well as a consequence. However, it does fix the height based painting error as there is no discrepancy between the texture coordinate and the height coordinate.
Unless someone spends time trying to figure out the reasoning for it and the way how it works, the flag is just magic. rP12641 added some dead code due to this, changing the flag after the heightmap array is initialized and subsequently changing it back before exporting the map is a no-op.
Generally speaking, there is really no use case where the vertex height will be relevant when painting, or identifying tiles. You would be always looking for the tile height. The tile height, aka the center height, is the mean of the four vertices it makes up. This makes sure that the texture on a tile takes into account the tile itself rather than one vertex.
This is done via the aforementioned flag, IMO, the other way around. Rather than interpolating the 4 vertices, its more reasonable to interpolate the center instead. This prevents the heightmap from being implicitly smoothed as well. Pyrenean Sierra works because of the fact that the exported grid is interpolated. If you remove the flag, the mountain range becomes extremely jagged.
I find no reason why direct control of the vertex heights shouldn't be present. Therefore, switching it the other way around is the better solution.
The complexity is that there are several maps relying on the behavior which have to be adapted.
This is an initial attempt. Alternatives welcomed. Who knows, maybe the right approach is tile based heights rather than vertex based heights, as AoE2 had.