First off, a big thanks to the people behind the new boost::geometry library!
This question replaces an earlier one which I have now split into two as two separate issues have become clearer.
I have read http://www.boost.org/doc/libs/1_47_0/libs/geometry/doc/html/geometry/design.html which explains the traits mechanism but am none the wiser as to why this code doesn't compile...
//code to calculate area of convex hull from a set of points
#include <boost/geometry.hpp>
#include <b开发者_如何学Coost/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);
}
The first error is
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
If I use a polygon instead of a multipoint, the code works just fine, though presumably with overheads I don't need. What is going on?
This turned out to be a bug in boost. It is now fixed in the head revision and should roll out in 1.49.0.
精彩评论