
Boost Users : 
Subject: Re: [Boostusers] [geometry] Cannot compile boost::geometry::intersection
From: Barend Gehrels (barend_at_[hidden])
Date: 20161116 16:07:29
Hi Stanley,
Op 16112016 om 19:40 schreef Stanley Friesen:
> I am using boost library version 1.54 with gcc std=c++11.
>
> I am trying a simple use of geometry::intersection as follows:
>
> #include <boost/geometry.hpp>
> #include <boost/geometry/geometries/point_xy.hpp>
> #include <boost/geometry/geometries/polygon.hpp>
> #include <boost/geometry/geometries/adapted/boost_polygon.hpp>
>
> using namespace boost::geometry;
> ......
> typedef model::d2::point_xy<double> point_xy;
> model::polygon<point_xy> clipBounds;
> // add points to clipBounds
> model::polygon<point_xy> area;
> // add points to area
> model::polygon<point_xy> result;
> if(boost::geometry::intersection(area, clipBounds, result))
> {
> std::cout << std::endl << "Boost intersection, size = " <<
> num_points(result) << std::endl;
> }
>
> If I comment out the call to intersection, everything compiles. With it I
> get:
> In file included from /usr/include/boost/serialization/level.hpp:28:0,
> from /usr/include/boost/serialization/nvp.hpp:31,
> from ...:
> /usr/include/boost/mpl/eval_if.hpp: In instantiation of â€˜struct
> boost::mpl::eval_if_c<false,
> boost::range_const_iterator<boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double,
> boost::geometry::cs::cartesian> > >,
> boost::range_mutable_iterator<boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double,
> boost::geometry::cs::cartesian> > > >â€™:
> [...]
>
> Since my code is virtually identical to the sample code in the
> documentation, I am very puzzled by this. What have I missed? How do I get
> this to compile?
>
> (I do find it odd that this error refers to boost/serialization rather than
> boost/geometry, but I suppose that has to do with the order of inclusion).
Yes, it is odd that it refers to boost/serialization  we don't include
that in Boost.Geometry. So how does it come there? Is your include list
accurate?
Do you need the Boost.Polygon adaptation? Apparently you don't need it
so it can be omitted, but I doubt if that is relevant.
Anyway, I think that the error is here:
model::polygon<point_xy> result;
But Intersection needs to output to a vector of polygons, or a
multipolygon (that must be like that in the documentation...)
Regards, Barend
Boostusers list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net