您的位置:首页 > 其它

地球上一个点(经纬度),求其周围360度,距离1米的采样点的经纬度坐标(每10度采一个点,共36个点)

2017-11-27 10:54 288 查看
struct pointInEarth
{
double lon;//经度
double lat;//纬度
double height;//高程
};

void surroundPoints(double longtitude, double latitude)
{
pointInEarth points[36];//结果在这里
double dis = 0.001;//两点之间的距离设为1米。单位是千米,即0.001千米=1米
double lonStep = dis / (111 * cos(latitude));//1米对应的经度步长,单位是度
double latStep = dis / 111;//1米对应的纬度步长,单位是度
for (int i = 0; i < 36; i++)//36个点
{
double angle = i * 10;//10度间隔
double lon = 0.0, lat = 0.0;
if (angle >= 0 && angle < 90)
{
lon = longtitude + lonStep *sin(angle*ONEANGLE);
lat = latitude + latStep *cos(angle*ONEANGLE);
}
else if (angle >= 90 && angle < 180)
{
lon = longtitude - lonStep *sin(angle*ONEANGLE);
lat = latitude + latStep *cos(angle*ONEANGLE);
}
else if (angle >= 180 && angle < 270)
{
lon = longtitude - lonStep *sin(angle*ONEANGLE);
lat = latitude - latStep *cos(angle*ONEANGLE);
}
else
{
lon = longtitude + lonStep *sin(angle*ONEANGLE);
lat = latitude - latStep *cos(angle*ONEANGLE);
}

points[i].lon=lon;
points[i].lat=lat;
osg::ref_ptr<osgEarth::MapNode> m_mapNode = _map->getCurrentMapView()->mapNode();
m_mapNode->getTerrain()->getHeight(m_mapNode->getMapSRS(), lon, lat, &points[i].height);

}
}

抛砖引玉,欢迎找茬! 若有错误,请不吝留下意见~~
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  osgEarth