[ create a new paste ] login | about

Link: http://codepad.org/LmamZ5s9    [ raw code | fork ]

C++, pasted on Mar 6:
#include <iostream>
#include <list>

#include <boost/geometry/geometry.hpp>
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/extensions/gis/io/wkt/wkt.hpp>

#include <boost/foreach.hpp>

static std::string javier2[2] =
    {"POLYGON((-2 2,2002 2,2002 -2002,-2 -2002,-2 2),(0 -147,0 -2000,2000 -2000,2000 0,104 0,440 -240,400 -280,0 -147))",
    "POLYGON((359.99 -280,0 -182,0 -147,400.01 -280,359.99 -280))"};


int main()
{
    typedef boost::geometry::model::polygon
        <
            boost::geometry::model::d2::point_xy<double> 
        > polygon;

    polygon green, blue;

    boost::geometry::read_wkt(javier2[0], green);
    boost::geometry::read_wkt(javier2[1], blue);

    std::list<polygon> output;
    boost::geometry::union_inserter<polygon>(green, blue, std::back_inserter(output));

    int i = 0;
    std::cout << "green - blue:" << std::endl;
    BOOST_FOREACH(polygon const& p, output)
    {
        std::cout << i++ << ": "
            << boost::geometry::area(p)
            << " " << boost::geometry::wkt(p)
            << std::endl;
    }

    return 0;
}


Create a new paste based on this one


Comments: