Subject: Re: [geometry] intersection() gives nonconsistent results
From: Vicky Vergara (vicky_vergara_at_[hidden])
Date: 2019-01-22 18:06:53
The following code is taken from the example on the documentation of
I changed the polygons to be simple triangles that have one point in common.
typedef boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double> > polygon;
polygon green, blue;
boost::geometry::read_wkt("POLYGON((3 1,2 2,2 1,3 1))", green);
boost::geometry::read_wkt("POLYGON((2 3,2 2,1 2,2 3))", blue);
boost::geometry::intersection(green, blue, output);
int i = 0;
std::cout << "green && blue:" << std::endl;
BOOST_FOREACH(polygon const& p, output)
std::cout << i++ << ": " << boost::geometry::wkt(p) << std::endl;
The Instresection its getting is
POLYGON((2 2,1 2,2 3,2 2))
Instead of a point.
My understanding is that his functions follows the OGC standard that says: Intersection (anotherGeometry: Geometry): Geometry Returns a geometric object that represents the
Point set intersection of this geometric object with anotherGeometry.
Then the result should be POINT(2 2)
The spatial intersection of 2 polygons can be a collection of multi geometries
Sometimes the intersection can be an Area
Sometimes the intersection can be a linestrig
Sometimes the intersection can be one point
Sometimes the intersection can be a collection of geometries that have an area, linestring and a point
What type do I have to make
in order to get either a polygon, a linestring or a point or a collection of anything?
-- Sent from: http://boost-geometry.203548.n3.nabble.com/ _______________________________________________ Geometry mailing list Geometry_at_[hidden] https://lists.boost.org/mailman/listinfo.cgi/geometry
Geometry list run by mateusz at loskot.net