The methods provided in osgSim work for geocentric databases. Is your
terrain built as a geocentric database?

If so, you can get the HAT/HOT with this...

earth->convertLatLongHeightToXYZ(osg::DegreesToRadians(lat),
osg::DegreesToRadians(lon), alt, X,Y,Z);
hat =
osgSim::HeightAboveTerrain::computeHeightAboveTerrain(terrain.get(),
osg::Vec3d(X,Y,Z));

If you're a flat earth with lat/lon only, then what you've got is
probably fine...

-Shayne

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Zeki
Yugnak
Sent: Thursday, April 18, 2013 7:15 AM
To: [email protected]
Subject: [osg-users] Height of the terrain on a given lang/long

Hi everyone,

I am trying to calculate height value of the terrain on a given latitude
and longitude. I am using a ive formatted terrain model that was
converted using osgDem from Dted level-1 data. I searched a solution on
whole osg forum and web but i could not find good one. Also I looked
HeightAboveTerrain class and osgintersection sample but these class does
not work only given a latitude and longitude values. 

I can get height on terrain with following code block,  is it a good
solution?


Code:

osg::PagedLOD* pLod =
dynamic_cast<osg::PagedLOD*>(coordinateSystemNode->getChild(0));
osgTerrain::TerrainTile* pTopTile =
dynamic_cast<osgTerrain::TerrainTile*>(pLod->getChild(0));
osgTerrain::HeightFieldLayer* pLayer =
dynamic_cast<osgTerrain::HeightFieldLayer*>(pTopTile->getElevationLayer(
));

pLayer->getInterpolatedValidValue( osg::DegreesToRadians(langVal),
osg::DegreesToRadians(longVal), height );




Cheers,

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





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
g
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to