tentone / geo-three

Tile based geographic world map visualization library for threejs
https://tentone.github.io/geo-three/docs/
MIT License
651 stars 105 forks source link

How to obtain elevation data through longitude and latitude coordinates #38

Open fzw2408 opened 2 years ago

fzw2408 commented 2 years ago

hi tentone: base scene: we wan't to make same mark on map by longitude and latitude 。some time longitude and latitude location is on the mountain 。datumsToSpherical just return plane coordinates [x,y]. and then the make sprite will be Obscured by the terrain mesh。

In my way: longitude and latitude => ESP900913[x,y,z] (y ===0 )[plane x y coordinates] =>tile[x+offset,y+offset, >14level ] =>get tile terrain image. =>get offset pixe data cal the height data . but there still has error by this way。 do you have same method by gpu or some other ? look forward to your reply!!!

tentone commented 2 years ago

Hello

Sorry for the late response. The method you are using seems correct it only seems to miss on the height extraction from the tile image texture.

To calculate the height from a pixel value you have to use the following formula

elevation = -10000 + (({R} * 256 * 256 + {G} * 256 + {B}) * 0.1)

Maybe we could add a util to library with this technique.

Thanks a lot!

laraduarte commented 1 year ago

@tentone might be a silly question but how do we get the RGB? elevation = -10000 + (({R} 256 256 + {G} 256 + {B}) 0.1)

thanks!