-> My Backend require MSL altitude.
-> Cesium use WSG84 altitude.

I found on internet that converting WSG84 to MSL require GEOID.

In My app I use Cesium World Terrain terrainProvider : Cesium.createWorldTerrain()

So I am full of different altitude everywhere.

I made a function to convert a GPS altitude in my backend, using a package to retrieve GEOID.
So I need Cesium to send a correct WSG(GPS) altitude to the backend

PROBLEM :

The problem I face is the following :

I draw points on a map, and I use createWorldTerrain. I want user to be able to change that altitude using above ground (cause none know the MSL of the place they are right ? ).

So what I am doing right now is the following

User Click on Map and I retrieve long/lat

I then call a function sampleTerrainMostDetailed to get the height of a point on the ground and return it.

ok, so with the above part of function, I have the altitude of a point above ground at 0m right ? since this updatedPositions[0].height since this is the altitude of a point above ground from TerrainProvider ?

I use this height as 0 and add my desired height let’s say 20m

I send this altitude to the backend,
so let’s say I put a point at lat: 35, long:129

I call my function and get back 90m (so this should be the height of the ground in WSG (GPS) ?

I add my desired height above the ground so let’s say 20m

I add 90m (the ground) + 20m (the height) = 110(GPS) elevation for this point
SO I send this elevation to my backend, but the result is wrong.

After checking all the backend code, the problem is that sampleTerrainMostDetailed do not return what I want.
GPS for my point should be 50m, but that function return me a 90m.

QUESTION ;

What is exactly the altitude returned from sampleTerrainMostDetailed ?

What is the altitude used from TerrainProvider ?

How Can I correctly get my WSG altitude above my Terrain Provider if not like this ?

I made some comparison of the data I get in meters.

GPS | CESIUM | GEOID | DIFF (GPS / CESIUM)

669 | 705 | 49.421 | +36

52 | 88 | 37.162 | +36

51 | 36 | -15.992 | -15

0 | -86 | -98 | +86

So sampleTerrainMostDetailed should return

As is typical of the [Cartographic](https://cesium.com/docs/cesiumjs-ref-doc/Cartographic.html) type, the supplied height is a height above the reference ellipsoid (such as [Ellipsoid.WGS84](https://cesium.com/docs/cesiumjs-ref-doc/Ellipsoid.html#.WGS84))

So Cesium WorldTerrain Altitude return some WGS84, I believe I am then missing an additional conversion. from WGS84to GPS, to then convert GPS to MSL using GEOID. That is a lot of conversion.
I am searching online some library or tool to convert WGS84 to GPS. I thougt they were similar if not the same .

**The problem is the same, I don’t know what the value height is from *sampleTerrainMostDetailed . If it’s an ellipsoidal height, like the description state, then the above formula should work when I use createWorldTerrain and the sampleTerrainMostDetailed It should provide me with the height of the ground above the ellipsoid, which I substract *Orthometric (geoid) **
height and I would correctly find the MSL N.
But the value from Cesium is way out of the value I would need so I am very confused with all those altitude with same name MSL = GeoID height above ellipsoid but MSL =! orthometric (geoid) height

The height returned in CesiumJS is height above the ellipsoid. You may find this blog post useful, especially the part under the title: “Altitude: Sea Level and the Ellipsoid” which talks about doing this computation:

Thanks Omar, I had see this before and that’s exactly what I wanted to apply.

Technically it would be just (Height in cesium above ellipsoid) - geoid = MSL.

I am sure my MSL and my GEOID are correct cause I compared them with tools online, but the height in cesium when using world terrain is not correct, it’s always + or - 50 meter away from what it should be (like in the little table I shown)

I take different point in different place on earth, get the height above ellipsoid in cesium, and compare to other altitude provider on the internet, I found correct value with the internet but rarely with Cesium

I wonder if it’s a precision problem or something else.

The elevation above the ellipsoid (ellipsoidal height) is the elevation above a mathematical model that approximates the shape of the earth.The current most common one is WGS84. These are the elevations that you’d get from a GPS.

Like we said in this case, the simple calculation of

Cesium (WSG84) - EGM2008 (Geoid) = MSL

Should work.

But when for example I make a point in Cesium in WorldTerrain at this position (that I convert ofc to radian before)

POINT => {longitude: 139.6072415,latitude: 35.7139224, height: 0}
MEASURE => SampleTerrainMostDetailed (with createWorldTerrain) => 86.8920731655 meter above the ellipsoid
CALCULATE => 86.8920731655 - 2*(37.29716) = 12.2977531655
which is ± 3meter from my measure of 14m MSL

Same with all around the world.

if I only do a single GEOID I get the wrong value I showed above of 49.7280731655