Failing to use boost::geometry::model::polygon

323 views Asked by At

I'm trying to use boost::geometry::model:polygon and i just can't make it work, i also found out there something else inside :

#include <boost/geometry/geometry.hpp>

called polygon_2d

i don't know which one i need and how to use it.

i tried to write the following code :

double points[][2] = {{2.0, 1.3}, {4.1, 3.0}, {5.3, 2.6}, {2.9, 0.7}, {2.0, 1.3}};
model::polygon<model::d2::point_xy<double> > poly;
append(poly, points);

But unfortunatly it doesn't work, i got the following compilation error :

boost::mpl::assertion:_failed : cannot convert parameter 1 from 'boost::mpl::failed**** (_cdecl boost::geometry::traits::point_type<Geometry>::NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE

my final goal is to create a polygon and to check if points are inside of him ..

thanks in advance

EDIT : the append function expect (Geometry& geometry, RangeOrPoint const& range_or_point);

1

There are 1 answers

0
Adam Wulkiewicz On

double points[][2] is not a Range of Points. You could use std::vector<model::d2::point_xy<double> > instead.

See the example: http://www.boost.org/doc/libs/1_55_0/libs/geometry/doc/html/geometry/reference/algorithms/append.html Here boost::tuple<> is used as a Point. Note the use of BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS macro to adapt tuple<> to the Point concept.

Using those functions you can access the rings of a Polygon:

http://www.boost.org/doc/libs/1_55_0/libs/geometry/doc/html/geometry/reference/access/exterior_ring/exterior_ring_1.html

http://www.boost.org/doc/libs/1_55_0/libs/geometry/doc/html/geometry/reference/access/interior_rings/interior_rings_1.html