How to get accurate elevation information

classic Classic list List threaded Threaded
3 messages Options
sonnysan sonnysan
Reply | Threaded
Open this post in threaded view
|

How to get accurate elevation information

Hello,

I am using OSGEarth version 2.10 DEVELOPMENT alongside OSG version 3.6.3.

In my application I'll use many high precision elevation maps, and would like to know whats the best/correct way to fetch the elevation at either mouse coordinates or at a specified location (Lat-Lon).

For testing, I have tried fetching coordinates on both an empty earth and one with a few srtm layers. My problem is that getting coordinates at an empty map yields either negative or near zero values, and the values are affected by zoom level. Am I maybe casting rays into the geometry?

When testing with srtm files, some areas in low elevation get very low (but still negative) values as well, which reinforces my previous guess. Mountainous regions are still showing high values, but maybe they could be off by a few meters, which would be an issue for my application.

So far, to get at mouse coordinates, I looked into the MouseCoordsTool and did something like:

--
osg::Vec3d world;
if (mapNode->getTerrain()->getWorldCoordsUnderMouse(myView, mouseX, mouseY, world))
{
        osgEarth::GeoPoint map;
        map.fromWorld(mapNode->getMapSRS(), world);

        alt = map.z();
}
--

I also tried fetching directly from the terrain:

--
double mslH = 0, ellH = 0;
if (mapNode->getTerrain()->getHeight(mapNode->getMapSRS(), lon, lat, &mslH, &ellH))
{
        altT1 = mslH;
        altT2 = ellH;
}
--

which seemed to yield the same results.

Thanks in advance.

gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: How to get accurate elevation information

sonnysan,

That is correct, the MapNode::getTerrain API interacts with the geometric scene graph. The results are based on intersecting rays with the triangles in the scene.

To query the source data directly (which will be slower but more accurate) you can call Map::getElevationPool and use the ElevationPool API.

Hope this helps!
Glenn Waldron / Pelican Mapping
sonnysan sonnysan
Reply | Threaded
Open this post in threaded view
|

Re: How to get accurate elevation information

gwaldron,

Thanks for the quick reply, that was what I was looking for.