Skip to content
New issue

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

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

Already on GitHub? # to your account

BUG: intersection of polygons is not symmetric #741

Open
brendan-ward opened this issue Nov 23, 2022 · 5 comments
Open

BUG: intersection of polygons is not symmetric #741

brendan-ward opened this issue Nov 23, 2022 · 5 comments
Labels

Comments

@brendan-ward
Copy link
Contributor

First reported in Shapely #1623.

Given a.wkt:

POLYGON ((11174.451451065055 13710.473363871335, -14730.97396732842 -5570.416909945428, -24371.419104236804 7382.295799251309, 1534.0063141566734 26663.18607306807, 11174.451451065055 13710.473363871335))

and b.wkt:

POLYGON ((-2129.8301268088653 3808.3625460804574, -13.419399941060902 5383.564741760034, 2589.8327945394485 5383.564741760034, 2589.8327945394485 2421.1656459793585, 760.529880485728 -6043.318375123083, -2129.8301268088653 -6043.318375123083, -2129.8301268088653 3808.3625460804574))

The intersection of a and b is not equivalent to the intersection of b and a (is sensitive to order).

❯ geosop -a a.wkt -b b.wkt -f wkt intersection
POLYGON ((-2129.8301268088653 3808.3625460804574, -13.419399941060902 5383.564741760034,
 -13.419399941060874 5383.564741760034, -2129.8301268088653 3808.3625460804574))

❯ geosop -a b.wkt -b a.wkt -f wkt intersection
POLYGON ((-13.419399941060902 5383.564741760034, -13.419399941060874 5383.564741760034, 
2589.8327945394485 5383.564741760034, 2589.8327945394485 2421.1656459793585, 
760.529880485728 -6043.318375123083, -2129.8301268088653 -6043.318375123083, 
-2129.8301268088653 3808.3625460804574, -13.419399941060902 5383.564741760034))
@dr-jts
Copy link
Contributor

dr-jts commented Nov 23, 2022

It's simpler to say that the intersection computed for B and A is incorrect. But may be useful to know that it's order-sensitive.

@dr-jts
Copy link
Contributor

dr-jts commented Aug 10, 2023

This does not seem to be a problem in JTS.

@pramsey
Copy link
Member

pramsey commented Aug 10, 2023

If you flip JTS to using an unordered map, as GEOS did, do you generate the bug in JTS?

@dr-jts
Copy link
Contributor

dr-jts commented Aug 10, 2023

I'll try and check this. Although the difference here is that this works in JTS, whereas in #827 JTS also fails.

@dr-jts dr-jts changed the title BUG: intersection of polygons is sensitive to order BUG: intersection of polygons is not symmetric Oct 5, 2024
@dr-jts
Copy link
Contributor

dr-jts commented Oct 5, 2024

This seems to work in GEOS 3.14. The results have different vertex order, but they are topologically identical.

@brendan-ward are you able to test?

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

No branches or pull requests

3 participants