[osg-users] How to get height above terrain in lat/long location?

shayne.tueller shayne.tueller at comcast.net
Fri Jan 19 07:45:56 PST 2018

Does your terrain display correctly in osgviewer? Make sure elevation data exists for the given lat lon...

Sent via the Samsung Galaxy S7 active, an AT&T 4G LTE smartphone
-------- Original message --------From: Siyamak Mohammadinejad <smplife64 at gmail.com> Date: 12/28/17  5:25 AM  (GMT-07:00) To: osg-users at lists.openscenegraph.org Subject: [osg-users] How to get height above terrain in lat/long location? 

I have problem to get height above terrain with this code: 


double X;
double Y;
double Z;
double maxElevationInDatabase = 8848; // meters, Mount Everest
osgTerrain::Terrain* t = dynamic_cast<osgTerrain::Terrain*>(terrainNode_.get());
osg::CoordinateSystemNode* csn = dynamic_cast<osg::CoordinateSystemNode*>(t);
osg::EllipsoidModel* em = csn ? csn->getEllipsoidModel() : 0;
if (em)
em->convertLatLongHeightToXYZ(osg::DegreesToRadians(lattitude), osg::DegreesToRadians(longitude), maxElevationInDatabase, X, Y, Z);
hat = osgSim::HeightAboveTerrain::computeHeightAboveTerrain(terrainNode_.get(), osg::Vec3d(X, Y, Z));
hot = maxElevationInDatabase - hat;

hat is always 8848  :( 

My code to generate terrain is:
osgdem --bluemarble-west -t land_shallow_topo_west.tif --bluemarble-east -t land_shallow_topo_east.tif -d SRTM_1arc-sec.tif --geocentric --HEIGHT_FIELD --LOD --POLYGONAL --PagedLOD --TERRAIN -v 5 -l 10 -o earth.ive

Thank you!


Read this topic online here:

osg-users mailing list
osg-users at lists.openscenegraph.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20180119/71afa730/attachment.html>

More information about the osg-users mailing list