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

Siyamak Mohammadinejad smplife64 at gmail.com
Fri Jan 19 01:23:30 PST 2018


Hi,

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

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:
Code:
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!

Cheers,
Siyamak[/code]

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=72646#72646







More information about the osg-users mailing list