w3reality/three-geo

How to get elevation of points?

eserrose opened this issue · 5 comments

In geo-viewer, clicking a point gives all x,y, and z coordinates of a point. However, I could not find how that is done. Can someone please help?
Much appreciated.

That [x, y, z] is the result of applying "mouse picking" against the visible terrain mesh objects with:

_doRaycast(mx, my) {
return Viewer._applyWithMeshesVisible(
this.objsInteractive, (meshes) =>
this.threelet.raycastFromMouse(mx, my, meshes));
}

For the underlying raycasting function raycastFromMouse(), please follow its implementation.

Spope commented

Hi,

First thanks for your library, it rocks !
This ticket is named exactly as I would have named mine, so I put my question here.

I looked at your example "projection" and I saw that your are setting the elevation of the point by hand.
I tried to use the _resovleElevation by passing the meshes to the proj function (and it works) but I guess there is some debug code which try to access window._scene to display the result of the function.

I guess I should not be using this as it is mentionned WIP, but there is currently not any other way to retrieve the height of a given point right ?

Thanks again for your work.

I found out that you can obtain the height of any coordinate using Mapbox rgb terrain tiles (you can find a library for this). The rest is easy as shown in the projection example.

I tried to use the _resovleElevation by passing the meshes to the proj function (and it works)
...
I guess I should not be using this as it is mentionned WIP, but there is currently not any other way to retrieve the height of a given point right ?

Hi @Spope ! Resolving elevation by proj() with the meshes argument (i.e. [x, y, z] = proj(latlng, meshes)) is WIP and the internal _resolveElevation() would not be robust enough (hence not yet documented in API). Yes, this is the only approach tried thus far.

you can obtain the height of any coordinate using Mapbox rgb terrain tiles (you can find a library for this)

@eserrose Curious, what's the name of the library?

Spope commented

Thanks for the answers, will look for other way of doing this.