在添加了DEM数据后,有时需要基于经纬度查询某一点的高程信息,本文主要介绍了如何实现基于经纬度查询高程数据的实现过程。
首先加载头文件:
#include <osgEarth/MapNode>
#include <osgEarth/ElevationQuery>
#include <osgDB/ReadFile>
创建需要使用到的变量:
osg::ref_ptr<osgEarth::MapNode> mapNode;
double query_resolution;
double out_resolution;
double out_haml ;
osgEarth::ElevationQuery *query;
初始化变量:
query_resolution = 0.00000001;
out_resolution = 0.0;
osg::ref_ptr<osg::Node> mp = osgDB::readNodeFile("./simple.earth");
mapNode = dynamic_cast<osgEarth::MapNode*>(mp.get());
query = new osgEarth::ElevationQuery(mapNode->getMap());
out_haml = 0.0;
基于经纬度对高程信息进行查询:
query->getElevation(osgEarth::GeoPoint(mapNode->g