w3reality / three-geo

3D geographic visualization library
MIT License
1.07k stars 180 forks source link

How to get elevation of points? #22

Open eserrose opened 4 years ago

eserrose commented 4 years ago

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.

j-devel commented 4 years ago

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

https://github.com/w3reality/three-geo/blob/07a47d6558297758bf606a67d0aebea90fde0a5c/examples/geo-viewer/src/viewer.js#L459-L463

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

Spope commented 4 years ago

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.

eserrose commented 4 years ago

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.

j-devel commented 4 years ago

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 4 years ago

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