Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong result in difference of linestrings #1232

Open
vissarion opened this issue Jan 26, 2024 · 0 comments
Open

Wrong result in difference of linestrings #1232

vissarion opened this issue Jan 26, 2024 · 0 comments

Comments

@vissarion
Copy link
Member

vissarion commented Jan 26, 2024

The program

#include <boost/geometry.hpp>

int main() {


    using Point = boost::geometry::model::d2::point_xy<double>;
    using Polygon = boost::geometry::model::polygon<Point>;
    using Linestring = boost::geometry::model::linestring<Point>;
    using MultiPolygon = boost::geometry::model::multi_polygon<Polygon>;
    using MultiLinestring = boost::geometry::model::multi_linestring<Linestring>;

    Linestring l1;
    boost::geometry::read_wkt("LINESTRING(5 -8,-7 -6,-3 6,-3 1,-5 4,-1 0,8 5,5 1,-2 3, 1 10,8 5,6 2,7 4)", l1);

    MultiLinestring ml1, ml2;
    boost::geometry::read_wkt("MULTILINESTRING((1.9375 1.875,1.7441860465116283 1.9302325581395348,-0.7692307692307692 2.6483516483516487,-2 3,-1.0071942446043165 5.316546762589928))", ml1);

    boost::geometry::difference(l1, ml1, ml2);

    std::cout << boost::geometry::wkt(ml2) << std::endl;

    std::cout << boost::geometry::is_valid(l1) << std::endl;
    std::cout << boost::geometry::is_valid(ml1) << std::endl;
    std::cout << boost::geometry::is_valid(ml2) << std::endl;

    std::cout << boost::geometry::length(l1) << std::endl;
    std::cout << boost::geometry::length(ml1) << std::endl;
    std::cout << boost::geometry::length(ml2) << std::endl;

}

returns

MULTILINESTRING((5 -8,-7 -6,-3 6,-3 1,-5 4,-1 0,8 5,5 1,1.9375 1.875))
1
1
1
83.7125
6.61539
57.5577

in boost 1.84, which is wrong.

In boost 1.77 it throws an Inconsistent Turns exception.

Screenshot from 2024-01-26 14-50-17
in figure ml1 is red, ml2 is green and the union of red-green-purple is l1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant