C++ 用经度和纬度推进凸面外壳

C++ 用经度和纬度推进凸面外壳,c++,boost,convex-hull,boost-geometry,C++,Boost,Convex Hull,Boost Geometry,我正在尝试使用boost的凸包算法和经纬度坐标 从这里开始: 我可以看出,我们可以计算两点之间的距离,甚至可以使用经度/纬度坐标找到区域(参见PDF文档第19页和第22页) 再加上 我提出了这样一个:,但它没有编译,为了方便起见,在这里编写代码: #include <iostream> #include <boost/geometry.hpp> #include <boost/geometry/geometries/polygon.hpp> #include

我正在尝试使用boost的
凸包
算法和经纬度坐标

从这里开始:

我可以看出,我们可以计算两点之间的距离,甚至可以使用经度/纬度坐标找到区域(参见PDF文档第19页和第22页)

再加上

我提出了这样一个:,但它没有编译,为了方便起见,在这里编写代码:

#include <iostream>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/geometries/adapted/boost_tuple.hpp>

namespace bg = boost::geometry;

int main()
{
    typedef bg::model::point<double, 2, bg::cs::geographic<bg::degree>> point;
    typedef boost::geometry::model::polygon<point> polygon;
    polygon poly;
    bg::read_wkt(" POLYGON ((4.346693 50.858306, 4.367945 50.852455, 4.366227 50.840809, 4.344961 50.833264, 4.338074 50.848677,4.346693 50.858306))",
    poly );
    
    polygon hull;
    boost::geometry::convex_hull(poly, hull);

    using boost::geometry::dsv;
    std::cout << "polygon: " << dsv(poly) << std::endl << "hull: " << dsv(hull) << std::endl;
}
#包括
#包括
#包括
#包括
名称空间bg=boost::geometry;
int main()
{
typedef bg::model::point;
typedef boost::geometry::model::polygon;
多边形多边形;
bg::read_wkt(“多边形((4.346693 50.858306,4.367945 50.852455,4.366227 50.840809,4.344961 50.833264,4.338074 50.848677,4.346693 50.858306)),
保利);
多边形外壳;
几何体:凸面外壳(多边形,外壳);
使用boost::geometry::dsv;

是的,虽然你可能是对的,一个战略/可以/可以制定,但没有实施

一个小型并排测试仪清楚地表明,该策略未针对地理坐标系实施:

template <typename cs> void test() {
    using point   = bg::model::point<double, 2, cs>;
    using polygon = bg::model::polygon<point>;
    polygon poly;
    bg::read_wkt("POLYGON((4.346693 50.858306, 4.367945 50.852455, 4.366227 "
                 "50.840809, 4.344961 50.833264, 4.338074 50.848677,4.346693 "
                 "50.858306))",
                 poly);

    std::cout << std::fixed;
    std::cout << "Polygon:   " << bg::dsv(poly)       << std::endl;
    std::cout << "Perimeter: " << bg::perimeter(poly) << std::endl;
    std::cout << "Area:      " << bg::area(poly)      << std::endl;

    using Strategy = typename bg::strategy_convex_hull<polygon, point>::type;
    std::cout << "Strategy " << boost::core::demangle(typeid(Strategy).name()) << "\n";

    if constexpr (not std::is_same_v<Strategy, bg::strategy::not_implemented>) {
        polygon hull;
        bg::convex_hull(poly, hull);
        std::cout << "Hull: " << bg::dsv(hull) << std::endl;
    }
}
/*!
    \brief Traits class binding a convex hull calculation strategy to a coordinate system
    \ingroup convex_hull
    \tparam Tag tag of coordinate system
    \tparam Geometry the geometry type (hull operates internally per hull over geometry)
    \tparam Point point-type of output points
*/
template
<
    typename Geometry1,
    typename Point,
    typename CsTag = typename cs_tag<Point>::type
>
struct strategy_convex_hull
{
    typedef strategy::not_implemented type;
};
深入研究该战略的实施,这里有一个充满希望的提示:

    // TODO: User-defiend CS-specific side strategy
    typename strategy::side::services::default_strategy<cs_tag>::type side;
//TODO:用户定义特定于CS的端策略
typename策略::端::服务::默认策略::类型端;
也许我们可以“完成”为您的坐标系专门化侧面策略?更有趣的是:存在。我对参数(例如大地测量解决方案策略的含义)的理解不够深入,但也许您自己可以从中吸取教训


我确信,如果您知道需要做什么,邮件列表中那些有帮助的开发人员将非常愿意指导有关如何将其放入库中的技术问题。

谢谢您的时间。我将研究strategy::side::geographic,并试着了解它是如何工作的。
/*!
    \brief Traits class binding a convex hull calculation strategy to a coordinate system
    \ingroup convex_hull
    \tparam Tag tag of coordinate system
    \tparam Geometry the geometry type (hull operates internally per hull over geometry)
    \tparam Point point-type of output points
*/
template
<
    typename Geometry1,
    typename Point,
    typename CsTag = typename cs_tag<Point>::type
>
struct strategy_convex_hull
{
    typedef strategy::not_implemented type;
};
    // TODO: User-defiend CS-specific side strategy
    typename strategy::side::services::default_strategy<cs_tag>::type side;