From the following code I calculate the intersection of two polygons. I hope the output can be NULL if it is not polygon. However the output is (((240, 52.9999), (240, 53), (240, 53), (240, 52.9999))). This is not a polygon. Is there any way to check whether the output is really a polygon??
#include <iostream>
#include <deque>
#include <vector>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/io/wkt/wkt.hpp>
#include <boost/geometry/algorithms/append.hpp>
#include <algorithm> // for reverse, unique
#include <iostream>
#include <string>
int main()
{
typedef boost::geometry::model::d2::point_xy<double, boost::geometry::cs::cartesian> point_2d;
typedef boost::geometry::model::polygon<point_2d> polygon_2d;
polygon_2d green;
boost::geometry::append(green, point_2d(286.188, 90.9575));
boost::geometry::append(green, point_2d(274.902, 56.2215));
boost::geometry::append(green, point_2d(274.238, 55.7393));
boost::geometry::append(green, point_2d(246.908, 51.9765));
boost::geometry::append(green, point_2d(194.477, 59.7441));
boost::geometry::append(green, point_2d(159.213, 101.141));
boost::geometry::append(green, point_2d(203.576, 149.537));
boost::geometry::append(green, point_2d(286.188, 90.9575));
polygon_2d blue;
boost::geometry::append(blue, point_2d(240, 53));
boost::geometry::append(blue, point_2d(240, -53));
boost::geometry::append(blue, point_2d(-60, -53));
boost::geometry::append(blue, point_2d(-60, 53));
boost::geometry::append(blue, point_2d(240, 53));
boost::geometry::correct(green);
boost::geometry::correct(blue);
std::vector<polygon_2d> output;
boost::geometry::intersection(green, blue, output);
std::cout << "green && blue:" << std::endl;
if(output.size())
{
std::cout<<boost::geometry::dsv(output[0])<<std::endl;
std::cout<<boost::geometry::area(output[0])<<std::endl;
}
return 0;
}