I started working with boost::polygons and was able to successfully get a first example running.
#include <iostream>
#include <fstream>
#include <vector>
//#define BOOST_GEOMETRY_DEBUG_HAS_SELF_INTERSECTIONS
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/foreach.hpp>
int main()
{
typedef boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double> > polygon;
// Specify the basic type
typedef boost::geometry::model::d2::point_xy<double> point_type;
polygon green, blue;
boost::geometry::read_wkt(
"POLYGON((12.498745833578186 12.419536883345382,18.263594394377002 12.398943230174154,23.978688520205729 12.383298944907036,24.117525749229547 13.39910172244412,24.314487540550175 14.570898587939885,24.8712597310756 14.95622429032219,25.722320817630298 15.18669582515999,21.665321235499064 14.361044268799734,17.608321653367831 13.535392712439478,16.597333336177559 13.465711863871391,15.575005842654047 13.467928032115791,14.650514031858414 13.861061276572014,14.50777576527776 14.88453162583931,14.504178352199876 15.938164676704075,14.498922431255201 16.980204917006496,14.492487976121353 17.993708667900485,14.482196117069734 19.03875319327711,14.505949729856848 20.08096824046109,14.487600188688662 21.258545088092454,14.494045448969553 22.514232472934879,14.471263903221249 23.982497591804666,13.920030768216524 26.028938654517198,13.3687976332118 28.07537971722973,12.751698142799956 27.83731500761612,12.675327187786968 27.278487344996226,12.410127358939876 28.329289803991813,11.630862363615753 27.38439104956101,11.366069160657506 25.269592320747837,11.454907972746462 23.631048945110475,11.14527423338151 21.473853988778856,11.473062343193799 19.030442683079997,10.68111686547576 21.239108596078747,10.09412389842208 23.910637018125264,9.0207400350496094 23.925356665714602,8.00874969039352 23.92442448224471,6.9326492897538321 23.923751548863741,5.9100005733740266 23.91522930376081,8.6191805076842627 19.035983271895432,11.458716436823121 14.162878132681334,8.3648944955942959 16.241560533944583,5.4560945132752288 18.913954234473017,3.4898175279532406 20.001072805137184,1.654900313361626 21.416153785178913,0.27999276701328135 20.717427984993051,1.9154908692445858 19.284664207728184,3.5684030937031626 18.148504086755285,1.854111066416996 18.398736020603927,0.25154726202361566 19.11936654229617,0.2410887668001962 18.052469462360897,1.6886750919026348 17.224602184728568,3.1484603974372192 16.520300720548533,1.7058818631140902 17.089558899611941,0.26330332879096119 17.658817078675348,1.9014764360128389 16.911254729451212,3.5396495432347201 16.163692380227072,1.6814357997733644 16.063472342057828,0.26176246875252041 16.438323609921341,2.8560101124456434 14.913027495218095,5.4502826497972254 14.200567424756574,2.8060167135881073 13.931287611770278,0.24079624348122586 14.291076793793071,0.5805464484707521 13.290752506542628,1.1299074646020237 12.256989548794317))", green);
boost::geometry::correct(green);
bool ignored = boost::geometry::detail::overlay::has_self_intersections(green);
if (ignored) {
throw boost::geometry::overlay_invalid_input_exception();
}
boost::geometry::read_wkt(
"POLYGON((12.554339773698544 14.438303882919723,13.556408150348114 14.311982476566227,14.508924153278642 14.192336570242801,14.491894188757335 15.194797514119246,14.498718879216096 16.209261368422823,14.482858022109253 17.226299309915841,14.466609990775966 18.244985495507549,14.457740221723956 19.352565231920845,14.475971206130955 20.469574910206095,14.494565261021805 21.848507859513113,14.456342188935233 22.897103417472088,14.435778436234628 23.964283518478155,13.873873407419911 26.035803136298021,13.311968378605194 28.107322754117881,12.713766687987608 27.656839589371383,12.592659118552055 27.168245445394287,12.353587306121009 28.336853420903552,11.67987122152636 27.509084998677608,11.475464150905493 27.879948142390603,11.367731091946926 28.488285057097642,11.380729095525506 27.686295875391828,11.39372709910409 26.88430669368601,11.302539400572902 25.356676009412304,11.441613019985377 23.731927373861001,10.398554485487139 23.905969184664578,10.922052991341372 21.512365551904701,11.445551497195604 19.118761919144823,10.317786756847857 21.250491606536841,9.41299821510502 23.921556030376088,9.9978672726613116 20.338205829880021,11.51609868052212 16.789251651501782,9.9013068286980683 20.333821764852267,8.2865149768740185 23.878391878202752,7.2253002190135609 23.923858412698742,9.3066115011822674 20.178022903164681,11.387922783350973 16.432187393630624,9.1449391987298974 20.171051957576665,6.9019556141088207 23.909916521522703,8.6790229689698855 20.201497426932747,11.138893291332419 16.511130816054479,8.5427565294532428 20.223478498146026,5.9466197675740675 23.935826180237576,4.2495013933676731 23.91447496442872,3.3116567486786117 24.236963564742929,1.8275896645849521 24.06999873875623,0.33140195040079767 24.576064902949781,4.6714289155723669 20.950520444051485,9.0114558807439362 17.324975985153184,7.0876409570623062 18.179102976770029,5.4471757490774966 19.173261148822398,2.8104591028155248 19.644519248613815,0.31295005811201015 20.722090489670641,0.20781105996930371 19.723012222103602,1.8621692769721676 18.858701179753805,3.506810689459094 18.125461749699031,1.8483302357490476 18.145150111728292,0.21965697740675694 18.606759152122567,0.27967096236987032 17.537998021437538,1.8778078324301841 16.505932735971658,3.4840016210832641 16.147648717470997,1.8688196645954065 15.82326598692636,0.26129396125550741 15.985276291319144,0.21321592462115646 14.906463747748829))", blue);
boost::geometry::correct(blue);
ignored = boost::geometry::detail::overlay::has_self_intersections(blue);
if (ignored) {
throw boost::geometry::overlay_invalid_input_exception();
}
std::vector<polygon> output;
boost::geometry::union_(green, blue, output);
int i = 0;
std::cout << "green || blue:" << std::endl;
BOOST_FOREACH(polygon const& p, output)
{
std::cout << i++ << ": " << boost::geometry::area(p) << std::endl;
}
//
// Declare a stream and an SVG mapper
std::ofstream svg("my_polygons.svg");
boost::geometry::svg_mapper<point_type> mapper(svg, 800, 500);
// Add geometries such that all these geometries fit on the map
mapper.add(green);
mapper.add(blue);
// Draw the geometries on the SVG map, using a specific SVG style
mapper.map(green, "fill-opacity:0.5;fill:rgb(153,204,0);stroke:rgb(153,204,0);stroke-width:2", 5);
mapper.map(blue, "fill-opacity:0.3;fill:rgb(51,51,153);stroke:rgb(51,51,153);stroke-width:2");
if (0 < output.size()) {
mapper.add(output[0]);
//mapper.map(output[0], "fill-opacity:0.3;fill:rgb(51,51,153);stroke:rgb(51,51,153);stroke-width:2");
mapper.map(output[0], "opacity:0.4;fill:none;stroke:rgb(212,0,0);stroke-width:5");
}
// Destructor of map will be called - adding </svg>
// Destructor of stream will be called, closing the file
return 0;
}
As the polygon vertices I am working with have some special attributes, I need to define a custom polygon that uses a custom point type.
Therefore, I started to play around with custom Polygons as explained in https://www.boost.org/doc/libs/1_69_0/libs/polygon/doc/gtl_custom_polygon.htm
I would like to visualize them as I did in the first working example. The code does not compile and I get some, for me cryptic, error messages.
g++ -std=c++14 gtl_custom_polygon.cpp -o gtl_custom_polygon -g -ggdb3 In file included from /usr/include/boost/geometry/core/closure.hpp:22, from /usr/include/boost/geometry/geometry.hpp:25, from /usr/include/boost/geometry.hpp:17, from gtl_custom_polygon.cpp:9: /usr/include/boost/geometry/core/point_type.hpp: In instantiation of ‘struct boost::geometry::traits::point_type’: /usr/include/boost/geometry/core/point_type.hpp:66:17: required from ‘struct boost::geometry::core_dispatch::point_type’ /usr/include/boost/geometry/core/coordinate_type.hpp:58:62: required from ‘struct boost::geometry::core_dispatch::coordinate_type’ /usr/include/boost/geometry/core/coordinate_type.hpp:92:25:
required from ‘struct boost::geometry::coordinate_type’ /usr/include/boost/geometry/io/svg/svg_mapper.hpp:289:17: required from ‘class boost::geometry::svg_mapper’ gtl_custom_polygon.cpp:143:81: required from here /usr/include/boost/geometry/core/point_type.hpp:45:5: error: no matching function for call to ‘assertion_failed(mpl_::failed************ (boost::geometry::traits::point_type::NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE::************)(mpl_::assert_::types))’ BOOST_MPL_ASSERT_MSG ^~~~~~~~~~~~~~~~~~~~ /usr/include/boost/mpl/assert.hpp:83:5: note: candidate: ‘template int mpl_::assertion_failed(typename mpl_::assert::type)’ int assertion_failed( typename assert::type ); ^~~~~~~~~~~~~~~~ /usr/include/boost/mpl/assert.hpp:83:5: note: template argument deduction/substitution failed: /usr/include/boost/geometry/core/point_type.hpp:45:5: note: cannot convert ‘boost::geometry::traits::point_type::NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE48::assert_arg()’ (type ‘mpl_::failed************ (boost::geometry::traits::point_type::NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE::************)(mpl_::assert_::types)’) to type mpl_::assert::type’ {aka ‘mpl_::assert’} BOOST_MPL_ASSERT_MSG ^ In file included from /usr/include/boost/geometry/core/coordinate_dimension.hpp:23, from /usr/include/boost/geometry/geometry.hpp:26, from /usr/include/boost/geometry.hpp:17, from gtl_custom_polygon.cpp:9: /usr/include/boost/geometry/core/point_type.hpp: In instantiation of ‘struct boost::geometry::core_dispatch::point_type’: /usr/include/boost/geometry/core/coordinate_type.hpp:58:62: required from ‘struct boost::geometry::core_dispatch::coordinate_type’ /usr/include/boost/geometry/core/coordinate_type.hpp:92:25:
required from ‘struct boost::geometry::coordinate_type’ /usr/include/boost/geometry/io/svg/svg_mapper.hpp:289:17: required from ‘class boost::geometry::svg_mapper’ gtl_custom_polygon.cpp:143:81: required from here /usr/include/boost/geometry/core/point_type.hpp:66:17: error: no type named ‘type’ in ‘struct boost::geometry::traits::point_type’::type type; ^~~~ In file included from /usr/include/boost/geometry/arithmetic/arithmetic.hpp:23, from /usr/include/boost/geometry/geometry.hpp:46, from /usr/include/boost/geometry.hpp:17, from gtl_custom_polygon.cpp:9: /usr/include/boost/geometry/geometries/concepts/point_concept.hpp: In instantiation of ‘class boost::geometry::concepts::Point’: /usr/include/boost/concept/detail/has_constraints.hpp:32:62:
required by substitution of ‘template boost::concepts::detail::yes boost::concepts::detail::has_constraints_(Model*, boost::concepts::detail::wrap_constraints*) [with Model = boost::geometry::concepts::Point]’ /usr/include/boost/concept/detail/has_constraints.hpp:42:5: required from ‘const bool boost::concepts::not_satisfied ::value’ /usr/include/boost/concept/detail/has_constraints.hpp:45:31: required from ‘struct boost::concepts::not_satisfied ’ /usr/include/boost/mpl/if.hpp:63:11: required from ‘struct boost::mpl::if_ , boost::concepts::constraint , boost::concepts::requirement::************> >’ /usr/include/boost/concept/detail/general.hpp:51:8: required from ‘struct boost::concepts::requirement_)>’ /usr/include/boost/geometry/util/for_each_coordinate.hpp:69:5:
required from ‘class boost::geometry::model::box’ /usr/include/boost/geometry/io/svg/svg_mapper.hpp:300:23: required from ‘class boost::geometry::svg_mapper’ gtl_custom_polygon.cpp:143:81: required from here /usr/include/boost/geometry/geometries/concepts/point_concept.hpp:106:10: error: ‘value’ is not a member of ‘boost::geometry::dimension’ enum { ccount = dimension::value }; ^ In file included from /usr/include/boost/geometry/core/closure.hpp:22, from /usr/include/boost/geometry/geometry.hpp:25, from /usr/include/boost/geometry.hpp:17, from gtl_custom_polygon.cpp:9: /usr/include/boost/geometry/core/coordinate_dimension.hpp: In instantiation of ‘struct boost::geometry::traits::dimension’: /usr/include/boost/geometry/core/coordinate_dimension.hpp:60:8:
required from ‘struct boost::geometry::core_dispatch::dimension’ /usr/include/boost/geometry/core/coordinate_dimension.hpp:57:8:
required from ‘struct boost::geometry::core_dispatch::dimension >’ /usr/include/boost/geometry/core/coordinate_dimension.hpp:81:8:
required from ‘struct boost::geometry::dimension >’ /usr/include/boost/geometry/algorithms/detail/assign_values.hpp:94:70: required from ‘static void boost::geometry::detail::assign::assign_inverse_box_or_segment::apply(BoxOrSegment&) [with BoxOrSegment = boost::geometry::model::box]’ /usr/include/boost/geometry/algorithms/assign.hpp:105:17: required from ‘void boost::geometry::assign_inverse(Geometry&) [with Geometry = boost::geometry::model::box]’ /usr/include/boost/geometry/io/svg/svg_mapper.hpp:349:23: required from ‘boost::geometry::svg_mapper::svg_mapper(std::ostream&, SvgCoordinateType, SvgCoordinateType, const string&) [with Point = CPoint; bool SameScale = true; SvgCoordinateType = double; std::ostream = std::basic_ostream; std::__cxx11::string = std::__cxx11::basic_string]’ gtl_custom_polygon.cpp:143:94:
required from here /usr/include/boost/geometry/core/coordinate_dimension.hpp:43:4: error: no matching function for call to ‘assertion_failed(mpl_::failed************ (boost::geometry::traits::dimension::NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE::************)(mpl_::assert_::types))’ BOOST_MPL_ASSERT_MSG ^~~~~~~~~~~~~~~~~~~~ /usr/include/boost/mpl/assert.hpp:83:5: note: candidate: ‘template int mpl_::assertion_failed(typename mpl_::assert::type)’ int assertion_failed( typename assert::type ); ^~~~~~~~~~~~~~~~ /usr/include/boost/mpl/assert.hpp:83:5: note: template argument deduction/substitution failed: /usr/include/boost/geometry/core/coordinate_dimension.hpp:43:4: note: cannot convert ‘boost::geometry::traits::dimension::NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE46::assert_arg()’ (type ‘mpl_::failed************ (boost::geometry::traits::dimension::NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE::************)(mpl_::assert_::types)’) to type ‘mpl_::assert::type’ {aka ‘mpl_::assert’} BOOST_MPL_ASSERT_MSG ^ /usr/include/boost/geometry/core/coordinate_dimension.hpp: In instantiation of ‘struct boost::geometry::core_dispatch::dimension’: /usr/include/boost/geometry/core/coordinate_dimension.hpp:57:8:
required from ‘struct boost::geometry::core_dispatch::dimension >’ /usr/include/boost/geometry/core/coordinate_dimension.hpp:81:8:
required from ‘struct boost::geometry::dimension >’ /usr/include/boost/geometry/algorithms/detail/assign_values.hpp:94:70: required from ‘static void boost::geometry::detail::assign::assign_inverse_box_or_segment::apply(BoxOrSegment&) [with BoxOrSegment = boost::geometry::model::box]’ /usr/include/boost/geometry/algorithms/assign.hpp:105:17: required from ‘void boost::geometry::assign_inverse(Geometry&) [with Geometry = boost::geometry::model::box]’ /usr/include/boost/geometry/io/svg/svg_mapper.hpp:349:23: required from ‘boost::geometry::svg_mapper::svg_mapper(std::ostream&, SvgCoordinateType, SvgCoordinateType, const string&) [with Point = CPoint; bool SameScale = true; SvgCoordinateType = double; std::ostream = std::basic_ostream; std::__cxx11::string = std::__cxx11::basic_string]’ gtl_custom_polygon.cpp:143:94:
required from here /usr/include/boost/geometry/core/coordinate_dimension.hpp:63:5: error: ‘value’ is not a member of ‘boost::geometry::traits::dimension’ BOOST_MPL_ASSERT_MSG( ^ In file included from /usr/include/boost/geometry/algorithms/detail/assign_indexed_point.hpp:21, from /usr/include/boost/geometry/policies/relate/intersection_points.hpp:20, from /usr/include/boost/geometry/strategies/intersection_strategies.hpp:20, from /usr/include/boost/geometry/strategies/strategies.hpp:39, from /usr/include/boost/geometry/geometry.hpp:49, from /usr/include/boost/geometry.hpp:17, from gtl_custom_polygon.cpp:9: /usr/include/boost/geometry/algorithms/detail/assign_values.hpp: In instantiation of ‘static void boost::geometry::detail::assign::assign_inverse_box_or_segment::apply(BoxOrSegment&) [with BoxOrSegment = boost::geometry::model::box]’: /usr/include/boost/geometry/algorithms/assign.hpp:105:17: required from ‘void boost::geometry::assign_inverse(Geometry&) [with Geometry = boost::geometry::model::box]’ /usr/include/boost/geometry/io/svg/svg_mapper.hpp:349:23: required from ‘boost::geometry::svg_mapper::svg_mapper(std::ostream&, SvgCoordinateType, SvgCoordinateType, const string&) [with Point = CPoint; bool SameScale = true; SvgCoordinateType = double; std::ostream = std::basic_ostream; std::__cxx11::string = std::__cxx11::basic_string]’ gtl_custom_polygon.cpp:143:94:
required from here /usr/include/boost/geometry/algorithms/detail/assign_values.hpp:94:70: error: no type named ‘type’ in ‘struct boost::geometry::dimension >’ initialize<0, 0, dimension::type::value>::apply( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ geometry, geometry::bounds::highest() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
); ~ /usr/include/boost/geometry/algorithms/detail/assign_values.hpp:97:70: error: no type named ‘type’ in ‘struct boost::geometry::dimension >’ initialize<1, 0, dimension::type::value>::apply( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ geometry, geometry::bounds::lowest() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
); ~ In file included from /usr/include/boost/geometry/geometries/concepts/check.hpp:27, from /usr/include/boost/geometry/algorithms/detail/assign_indexed_point.hpp:20, from /usr/include/boost/geometry/policies/relate/intersection_points.hpp:20, from /usr/include/boost/geometry/strategies/intersection_strategies.hpp:20, from /usr/include/boost/geometry/strategies/strategies.hpp:39, from /usr/include/boost/geometry/geometry.hpp:49, from /usr/include/boost/geometry.hpp:17, from gtl_custom_polygon.cpp:9: /usr/include/boost/geometry/geometries/concepts/box_concept.hpp: In instantiation of ‘boost::geometry::concepts::Box::~Box() [with Geometry = boost::geometry::model::box ’: /usr/include/boost/concept/detail/general.hpp:39:28: required from ‘static void boost::concepts::requirement::failed() [with Model = boost::geometry::concepts::Box >]’ /usr/include/boost/concept_check.hpp:50:7: required from ‘class boost::geometry::detail::concept_check::check’ /usr/include/boost/geometry/geometries/concepts/check.hpp:126:8: required from ‘struct boost::geometry::dispatch::check, boost::geometry::box_tag, false>’ /usr/include/boost/geometry/geometries/concepts/check.hpp:195:8:
required from ‘struct boost::geometry::concepts::detail::checker ’ /usr/include/boost/geometry/geometries/concepts/check.hpp:218:31: required from ‘void boost::geometry::concepts::check() [with Geometry = boost::geometry::model::box]’ /usr/include/boost/geometry/algorithms/assign.hpp:99:30: required from ‘void boost::geometry::assign_inverse(Geometry&) [with Geometry = boost::geometry::model::box]’ /usr/include/boost/geometry/io/svg/svg_mapper.hpp:349:23: required from ‘boost::geometry::svg_mapper::svg_mapper(std::ostream&, SvgCoordinateType, SvgCoordinateType, const string&) [with Point = CPoint; bool SameScale = true; SvgCoordinateType = double; std::ostream = std::basic_ostream; std::__cxx11::string = std::__cxx11::basic_string]’ gtl_custom_polygon.cpp:143:94:
required from here /usr/include/boost/geometry/geometries/concepts/box_concept.hpp:79:34: error: no type named ‘type’ in ‘struct boost::geometry::dimension >’ static const std::size_t n = dimension::type::value
I assume that I have to define some more of these traits but I am not sure and do not know which ones?
#include <boost/polygon/polygon.hpp>
#include <boost/geometry.hpp>
#include <cassert>
#include <list>
#include <iostream>
#include <fstream>
namespace gtl = boost::polygon;
using namespace boost::polygon::operators;
//Now lets declare our own polygon class
//Oops, we need a point class to support our polygon, lets borrow
//the CPoint example
struct CPoint {
int x;
int y;
//int type;
};
//we have to get CPoint working with boost polygon to make our polygon
//that uses CPoint working with boost polygon
namespace boost { namespace polygon {
template <>
struct geometry_concept<CPoint> { typedef point_concept type; };
template <>
struct point_traits<CPoint> {
typedef int coordinate_type;
static inline coordinate_type get(const CPoint& point,
orientation_2d orient) {
if(orient == HORIZONTAL)
return point.x;
return point.y;
}
};
template <>
struct point_mutable_traits<CPoint> {
typedef int coordinate_type;
static inline void set(CPoint& point, orientation_2d orient, int value) {
if(orient == HORIZONTAL)
point.x = value;
else
point.y = value;
}
static inline CPoint construct(int x_value, int y_value) {
CPoint retval;
retval.x = x_value;
retval.y = y_value;
return retval;
}
};
} }
//I'm lazy and use the stl everywhere to avoid writing my own classes
//my toy polygon is a std::list<CPoint>
typedef std::list<CPoint> CPolygon;
//we need to specialize our polygon concept mapping in boost polygon
namespace boost { namespace polygon {
//first register CPolygon as a polygon_concept type
template <>
struct geometry_concept<CPolygon>{ typedef polygon_concept type; };
template <>
struct polygon_traits<CPolygon> {
typedef int coordinate_type;
typedef CPolygon::const_iterator iterator_type;
typedef CPoint point_type;
// Get the begin iterator
static inline iterator_type begin_points(const CPolygon& t) {
return t.begin();
}
// Get the end iterator
static inline iterator_type end_points(const CPolygon& t) {
return t.end();
}
// Get the number of sides of the polygon
static inline std::size_t size(const CPolygon& t) {
return t.size();
}
// Get the winding direction of the polygon
static inline winding_direction winding(const CPolygon& t) {
return unknown_winding;
}
};
template <>
struct polygon_mutable_traits<CPolygon> {
//expects stl style iterators
template <typename iT>
static inline CPolygon& set_points(CPolygon& t,
iT input_begin, iT input_end) {
t.clear();
t.insert(t.end(), input_begin, input_end);
return t;
}
};
} }
//now there's nothing left to do but test that our polygon
//works with library interfaces
int main() {
//test_polygon<CPolygon>(); //woot!
CPoint p1 = {0, 0};//, 0};
CPoint p2 = {10, 0};//, 0};
CPoint p3 = {10, 10};//, 1};
CPoint p4 = {0, 10};//, 1};
CPoint pts_1[] = {p1, p2, p3, p4};
CPolygon poly_1;
gtl::set_points(poly_1, pts_1, pts_1+4);
p1 = {5, 5};//, 0};
p2 = {15, 5};//, 0};
p3 = {15, 15};//, 1};
p4 = {5, 15};//, 1};
CPoint pts_2[] = {p1, p2, p3, p4};
CPolygon poly_2;
gtl::set_points(poly_2, pts_2, pts_2+4);
//std::vector<CPolygon> output;
//boost::geometry::union_(poly_1, poly_2, output);
auto output = poly_1 | poly_2;
// Declare a stream and an SVG mapper
std::ofstream svg("my_polygons.svg");
boost::geometry::svg_mapper<gtl::polygon_traits<CPolygon>::point_type> mapper(svg, 800, 500);
return 0;
}