how to find self intersection in a polygon using boost/? -
i need find self intersections in polygon. know boost has ability. can't figure out how use turn_info information intersections. segments intersected , etc. can help? thanks
you cannot, properly, because concepts defined boost geometry dis-allow self intersections.
however, indirectly can use validation features (new since think 1.59) information self intersection:
std::string reason; poly p; bg::read_wkt("polygon((0 0, 0 4, 2 4, 2 2, 6 2, 6 6, 2 6, 2 4, 0 4, 0 8, 8 8, 8 0, 0 0))", expected); bool ok = bg::is_valid(p, reason); std::cout << "expected: " << bg::dsv(p) << (ok?" valid":" invalid: '" + reason + "'") << "\n";
prints:
expected: (((0, 0), (0, 4), (2, 4), (2, 2), (6, 2), (6, 6), (2, 6), (2, 4), (0, 4), (0, 8), (8, 8), (8, 0), (0, 0))) invalid: 'geometry has invalid self-intersections. self-intersection point found @ (0, 4); method: t; operations: x/u; segment ids {source, multi, ring, segment}: {0, -1, -1, 0}/{0, -1, -1, 7}'
Comments
Post a Comment