On 07/11/2014 12:10 πμ, Menelaos Karavelas wrote:
On 06/11/2014 11:56 μμ, Will Lucas wrote:
I think this is because your vector's value type is a ring
rather than a polygon.
Actually this works for me. Though since a container of Rings
isn't a "proper" Geometry other functions may not work with it,
e.g. bg::wkt() from your example.
My code:
#include <boost/foreach.hpp>
#include <boost/geometry.hpp>
namespace bg = boost::geometry;
typedef bg::model::point<int, 2, bg::cs::cartesian> point_type;
typedef bg::model::ring<point_type> ring_type;
typedef std::vector<ring_type> rings_container;
int main()
{
ring_type pol1, pol2;
bg::read_wkt("POLYGON((75 75,75 175,275 175,275 75,75 75))", pol1);
bg::read_wkt("POLYGON((50 50,50 150,250 150,250 50,50 50))", pol2);
rings_container rings;
bg::intersection(pol1, pol2, rings);
BOOST_FOREACH(ring_type const& r, rings)
std::cout << bg::wkt(r) << std::endl;
return 0;
}
FYI, it compiles also if the input Geometries are Polygons. I
tried this:
polygon_type pol1,
pol2;
bg::read_wkt("POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,6 4,6 6,4 6,4 4))", pol1);
bg::read_wkt("POLYGON((1 1,1 11,11 11,11 1,1 1))", pol2);
rings_container rings;
bg::intersection(pol1, pol2, rings);
BOOST_FOREACH(ring_type const& r, rings)
std::cout << bg::wkt(r) << std::endl;
bg::intersection(pol2, pol1, rings);
BOOST_FOREACH(ring_type const& r, rings)
std::cout << bg::wkt(r) << std::endl;
In this case holes aren't included in the output:
POLYGON((1 10,10 10,10 1,1 1,1 10))
POLYGON((1 10,10 10,10 1,1 1,1 10))
Is this behavior intended?