使用boost::geometry::azimuth函数计算方位角的示例
在地理信息系统(GIS)领域,计算两个点之间的距离和方位角是一项常见的任务。Boost几何库中的boost::geometry::azimuth函数可以用来计算两个点之间的方位角,它接受两个点的经纬度作为输入。
下面是一个使用boost::geometry::azimuth函数的示例程序:
#include <iostream>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point.hpp>
namespace bg = boost::geometry;
int main()
{
bg::model::point<double, 2, bg::cs::spherical<bg::degree>> p1(116.4074, 39.9042);
bg::model::point<double, 2, bg::cs::spherical<bg::degree>> p2(121.4737, 31.2304);
double azimuth = bg::azimuth(p1, p2);
std::cout << "The azimuth of p1 to p2 is: " << azimuth << std::endl;