boost :: geometry multi_point不能像多边形一样构造

问题描述 投票:3回答:1

首先,非常感谢新的boost :: geometry库背后的人们!

这个问题取代了之前我已经分成两部分的问题,因为两个单独的问题变得更加清晰。

我已经阅读了http://www.boost.org/doc/libs/1_47_0/libs/geometry/doc/html/geometry/design.html,它解释了特征机制但是没有明白为什么这个代码不能编译...

//code to calculate area of convex hull from a set of points

#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/multi/geometries/multi_point.hpp>

double convex_hull_area()
{
    using boost::geometry::model::d2::point_xy;
    using boost::geometry::append;
    using boost::geometry::make;

    //this bit works if I use a polygon instead of multi_point
    boost::geometry::model::multi_point<point_xy<float> > all_points_in_radius;

    append(all_points_in_radius,make<point_xy<float> >(0,0));
    append(all_points_in_radius,make<point_xy<float> >(3,0));
    append(all_points_in_radius,make<point_xy<float> >(3,3));
    append(all_points_in_radius,make<point_xy<float> >(2,1));

    boost::geometry::model::polygon<point_xy<float> > hull;
    boost::geometry::convex_hull(all_points_in_radius,hull);
    return boost::geometry::area(hull);
}

第一个错误是

Error   1   error C2039: 'apply' : is not a member of 'boost::geometry::dispatch::for_each_range<Tag,Geometry,Actor,IsConst>'   d:\boost\boost_1_47_0\boost\geometry\algorithms\detail\for_each_range.hpp   115 boost_geom_test

如果我使用多边形而不是多点,代码工作得很好,虽然可能是我不需要的开销。到底是怎么回事?

c++ boost boost-geometry
1个回答
3
投票

结果证明这是一个提升中的错误。它现在在头版本中修复,应该在1.49.0中推出。

© www.soinside.com 2019 - 2024. All rights reserved.