Boost logo

Boost Users :

Subject: Re: [Boost-users] [geometry] Cannot compile boost::geometry::intersection
From: Barend Gehrels (barend_at_[hidden])
Date: 2016-11-16 16:07:29


Hi Stanley,

Op 16-11-2016 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&lt;boost::geometry::model::polygon&lt;boost::geometry::model::d2::point_xy&lt;double,
> boost::geometry::cs::cartesian> > >,
> boost::range_mutable_iterator<boost::geometry::model::polygon&lt;boost::geometry::model::d2::point_xy&lt;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
multi-polygon (that must be like that in the documentation...)

Regards, Barend


Boost-users 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