Opened 6 years ago
#12355 new Bugs
False self intersection
Reported by: | Owned by: | Barend Gehrels | |
---|---|---|---|
Milestone: | To Be Determined | Component: | geometry |
Version: | Boost 1.61.0 | Severity: | Problem |
Keywords: | Cc: |
Description
Please see the following code:
#include <boost/geometry.hpp> #include <boost/geometry/geometries/point_xy.hpp> #include <boost/geometry/geometries/polygon.hpp> using namespace boost::geometry; typedef double FloatType; typedef model::d2::point_xy<FloatType> Point; typedef model::polygon<Point> Polygon; typedef model::multi_polygon<Polygon> MultiPolygon; typedef model::ring<Point> Ring; typedef model::box<Point> Box; typedef model::linestring<Point> LineString; int main(int argc, char *argv[]) { using namespace std; Polygon p1; boost::geometry::read_wkt("POLYGON((440408.69120520249 5684415.5176829416," "440376.96050000004 5684329.5744000003," "440376.93154344801 5684329.5945822615," "440408.69005920028 5684415.5145825278," "440408.69120520249 5684415.5176829416))", p1); std::string err; bool valid = boost::geometry::is_valid(p1, err); cout << "is_valid(p1): " << (valid?"true":"false") << ":\n" << err << endl; Polygon p2; boost::geometry::read_wkt("POLYGON((" "440408.83723096416 5684415.9121634094," "440421.56219999958 5684410.6604999993," "440423.30049999990 5684412.0036999993," "440439.33189999964 5684394.8839999996," "440423.75960000046 5684357.4199000001," "440420.99959999975 5684350.7814000007," "440404.12129999977 5684310.1740000006," "440393.24469999969 5684317.6517999992," "440377.49349999987 5684329.2028999999," "440376.96050000004 5684329.5744000003," "440408.69005920028 5684415.5145825278," "440408.69120520249 5684415.5176829416," "440408.83689894457 5684415.9118452258," "440408.83723096416 5684415.9121634094))", p2); MultiPolygon mp; union_(p1, p2, mp); cout << "mp: " << boost::geometry::wkt(mp) << endl; return 0; }
Output:
is_valid(p1): false: Geometry has invalid self-intersections. A self-intersection point was found at (440409, 5.68442e+006); method: i; operations: i/u; segment IDs {source, multi, ring, segment}: {0, -1, -1, 0}/{0, -1, -1, 2} mp: MULTIPOLYGON(((440409 5.68442e+006,440409 5.68442e+006,440377 5.68433e+006,440409 5.68442e+006)))
Both polygons (p1 and p2) are in fact valid, without any self-intersections. But boost.geometry sees one and can't union the two polygons correctly.
Thank you, for the good work.
Note:
See TracTickets
for help on using tickets.