osgearth由经纬度得到高程

本文介绍了两种从经纬度获取高程的方法,并对比了它们的优缺点。方法一使用ElevationQuery对象直接查询源高程数据,虽然速度较慢但更准确;方法二通过Terrain接口获取高度,该方法依赖于场景图交集且结果可能因地形细节不同而有所变化。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

首先就是中所周知的由世界坐标转成经纬度的方法,鼠标操作获取地理信息都是这样的。

如果已知经纬度,要得到高程主要有以下两种方法。

方法一举例:

 

GeoPoint gp(mapNode, lon, la, 0.0);
double query_resolution= 0.0;
double actual_resolution = 0.0;
float elevation = 0.0f;
osgEarth::ElevationQuery query(mapNode->getMap());
elevation= query.getElevation(gp,query_resolution, &actual_resolution);
return elevation;
方法二举例:

float elevation = 0.0;
mapNode->getTerrain()->getHeight(mapNode->getMapSRS(), lon,la, &elevation);


在这里推荐第一种方法即使它比较慢,第二种方法你会发现获得的高程在不断的变化。

官方解释:The Terrain interface (on MapNode::getTerrain) returns heights based on scene graph intersection, i.e. the triangles in memory. So the value will differ depending on what level of detail of terrain tiles are currently paged into memory. 

If you want to query the source elevation data directly you can use ElevationQuery object. It's slower, but more accurate since it samples the actual source data.

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值