Opened 5 years ago
Last modified 5 years ago
#13096 new Bugs
boost::geometry::intersection results depend on polypoints inputorder
| Reported by: | Owned by: | Barend Gehrels | |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | geometry |
| Version: | Boost 1.64.0 | Severity: | Problem |
| Keywords: | intersection | Cc: |
Description
Hello,
when calculating the intersection of the givin polygons, the result depends on the order of the inputpoints.
#include <boost/geometry/geometry.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
int main(int argc, char* argv[])
{
typedef boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double>> boost_polygon;
boost_polygon RedPoly, GreenPoly, RedPolyReverted, GreenPolyReverted;
boost::geometry::read_wkt("POLYGON((864.11024748062812 524.94908797221251, 881.01048034069004 524.77831898197212, 877.68802698783907 501.82023487475703, 860.75736496460991 501.99865072086430, 864.11024748062812 524.94908797221251))", RedPoly);
boost::geometry::read_wkt("POLYGON((864.62221751510151 524.94391475320754, 868.20628459909278 524.90769942280622, 864.93694798456659 502.47800172931238, 861.34657616182551 502.51580174027310, 864.62221751510151 524.94391475320754))", GreenPoly);
boost::geometry::read_wkt("POLYGON((860.75736496460991 501.99865072086430, 877.68802698783907 501.82023487475703, 881.01048034069004 524.77831898197212, 864.11024748062812 524.94908797221251, 860.75736496460991 501.99865072086430))", RedPolyReverted);
boost::geometry::read_wkt("POLYGON((861.34657616182551 502.51580174027310, 864.93694798456659 502.47800172931238, 868.20628459909278 524.90769942280622, 864.62221751510151 524.94391475320754, 861.34657616182551 502.51580174027310))", GreenPolyReverted);
boost::geometry::correct(RedPoly);
boost::geometry::correct(GreenPoly);
boost::geometry::correct(RedPolyReverted); // reverts order of points and is now equal it RedPoly
boost::geometry::correct(GreenPolyReverted); // reverts order of points and is now equal it GreenPoly
std::list<boost_polygon> output;
boost::geometry::intersection(RedPoly, GreenPoly, output); // error: output is empty
std::list<boost_polygon> outputReverted;
boost::geometry::intersection(RedPolyReverted, GreenPolyReverted, outputReverted); // correct: outputReverted.front equals GreenPoly
return 0;
}
Attachments (1)
Change History (2)
by , 5 years ago
| Attachment: | examplePolys.png added |
|---|
comment:1 by , 5 years ago
In addition, if the Polygondefinition is changed from "clockWise-closed" to "clockWise-open", both intersection lists are empty
Note:
See TracTickets
for help on using tickets.

Plot of example polygons