Boost logo

Geometry :

Subject: [ggl] Help needed with Intersection operation
From: angusj (awj1958)
Date: 2011-08-13 19:52:25


The following intersection operation returns the second hole in the green
polygon.
 
Since I've only just started playing with boost geometry, I presume I'm
doing something wrong.

    typedef boost::geometry::model::polygon ggl_polygon;
    typedef boost::geometry::model::multi_polygon ggl_polygons;

    ggl_polygon blue, green;
    boost::geometry::read_wkt(
        "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 3,5.3
2.6,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3)"
            "(4.0 2.0, 4.2 1.4, 4.8 1.9, 4.4 2.2, 4.0 2.0)(2.8 1.1,3.3
1.1,2.8 1.6))", green);
    boost::geometry::read_wkt(
        "POLYGON((4.0 -0.5 , 3.5 1.0 , 2.0 1.5 , 3.5 2.0 , 4.0 3.5 , 4.5 2.0
, 6.0 1.5 , 4.5 1.0 , 4.0 -0.5))", blue);

    ggl_polygons output;
    boost::geometry::intersection(green, blue, output);

        for (ggl_polygons::iterator it = output.begin(); it != output.end(); ++it)
        {
                for (ggl_polygon::ring_type::size_type j = 0; j < it->outer().size(); ++j)
                        cout << it->outer()[j].x() << ", " << it->outer()[j].y() << "\n";
                cout << "\n";

                for (ggl_polygon::inner_container_type::size_type i = 0; i <
it->inners().size(); ++i)
                {
                        for (ggl_polygon::ring_type::size_type j = 0; j < it->inners()[i].size();
++j)
                                cout << it->inners()[i][j].x() << ", " << it->inners()[i][j].y() <<
"\n";
                        cout << "\n";
                }
        }

Thanks for any help ...

Angus

--
View this message in context: http://boost-geometry.203548.n3.nabble.com/Help-needed-with-Intersection-operation-tp3250402p3250402.html
Sent from the Boost Geometry mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/ggl/attachments/20110812/75b534a7/attachment.html

Geometry list run by mateusz at loskot.net