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

Incorrect geometry for Multipolygons with shells which share a single point! #424

Closed
rtroilo opened this issue Aug 28, 2021 · 0 comments · Fixed by #425
Closed

Incorrect geometry for Multipolygons with shells which share a single point! #424

rtroilo opened this issue Aug 28, 2021 · 0 comments · Fixed by #425
Assignees
Labels
bug Something isn't working as expected
Milestone

Comments

@rtroilo
Copy link
Member

rtroilo commented Aug 28, 2021

Wrong and inconsistent geometries for multipolygon with multiple outer shells which share a common node. In JTS this is a valid multipolygon.
Simplified case:

   lat
    ^
    |
    4 a--d
    3 |  |
    2 b--c--e
    1    |  |
    0    g--f
      0123456 -> lon
  
   A: (a,b,c)\
              one shell (a,b,c,d,a)
   B: (c,d,a)/
  
   C: (c,e,f)\
              one shell (c,e,f,g,c)
   D: (f,g,c)/
   

Expected behaviour

Either

  • MULTIPOLYGON (((0 4, 0 2, 3 2, 3 4, 0 4)), ((3 2, 6 2, 6 0, 3 0, 3 2)))
  • MULTIPOLYGON (((3 2, 6 2, 6 0, 3 0, 3 2)), ((0 4, 0 2, 3 2, 3 4, 0 4)))
  • or similar

for different member permutations we got different results.
According to the osm wiki "The order of the relation members does not matter".

ABCD - GEOMETRYCOLLECTION (LINESTRING (0 4, 0 2, 3 2), LINESTRING (3 2, 3 4, 0 4), LINESTRING (3 2, 6 2, 6 0), LINESTRING (6 0, 3 0, 3 2))
ABDC - GEOMETRYCOLLECTION (LINESTRING (0 4, 0 2, 3 2), LINESTRING (3 2, 3 4, 0 4), LINESTRING (6 0, 3 0, 3 2), LINESTRING (3 2, 6 2, 6 0))
ACBD - GEOMETRYCOLLECTION (LINESTRING (0 4, 0 2, 3 2), LINESTRING (3 2, 6 2, 6 0), LINESTRING (3 2, 3 4, 0 4), LINESTRING (6 0, 3 0, 3 2))
ACDB - POLYGON ((0 4, 0 2, 3 2, 6 2, 6 0, 3 0, 6 0, 3 4, 0 4))
ADBC - GEOMETRYCOLLECTION (LINESTRING (0 4, 0 2, 3 2), LINESTRING (6 0, 3 0, 3 2), LINESTRING (3 2, 3 4, 0 4), LINESTRING (3 2, 6 2, 6 0))
ADCB - POLYGON ((0 4, 0 2, 3 2, 3 0, 6 0, 6 2, 6 0, 3 4, 0 4))

BACD - GEOMETRYCOLLECTION (LINESTRING (3 2, 3 4, 0 4), LINESTRING (0 4, 0 2, 3 2), LINESTRING (3 2, 6 2, 6 0), LINESTRING (6 0, 3 0, 3 2))
BADC - GEOMETRYCOLLECTION (LINESTRING (3 2, 3 4, 0 4), LINESTRING (0 4, 0 2, 3 2), LINESTRING (6 0, 3 0, 3 2), LINESTRING (3 2, 6 2, 6 0))
BCAD - GEOMETRYCOLLECTION (LINESTRING (3 2, 3 4, 0 4), LINESTRING (3 2, 6 2, 6 0), LINESTRING (0 4, 0 2, 3 2), LINESTRING (6 0, 3 0, 3 2))
BDAC - GEOMETRYCOLLECTION (LINESTRING (3 2, 3 4, 0 4), LINESTRING (6 0, 3 0, 3 2), LINESTRING (0 4, 0 2, 3 2), LINESTRING (3 2, 6 2, 6 0))
BDCA - GEOMETRYCOLLECTION (LINESTRING (3 2, 3 4, 0 4), LINESTRING (6 0, 3 0, 3 2), LINESTRING (3 2, 6 2, 6 0), LINESTRING (0 4, 0 2, 3 2))
BCDA - GEOMETRYCOLLECTION (LINESTRING (3 2, 3 4, 0 4), LINESTRING (3 2, 6 2, 6 0), LINESTRING (6 0, 3 0, 3 2), LINESTRING (0 4, 0 2, 3 2))

CABD - GEOMETRYCOLLECTION (LINESTRING (3 2, 6 2, 6 0), LINESTRING (0 4, 0 2, 3 2), LINESTRING (3 2, 3 4, 0 4), LINESTRING (6 0, 3 0, 3 2))
CADB - GEOMETRYCOLLECTION (LINESTRING (3 2, 6 2, 6 0), LINESTRING (0 4, 0 2, 3 2), LINESTRING (6 0, 3 0, 3 2), LINESTRING (3 2, 3 4, 0 4))
CBAD - GEOMETRYCOLLECTION (LINESTRING (3 2, 6 2, 6 0), LINESTRING (3 2, 3 4, 0 4), LINESTRING (0 4, 0 2, 3 2), LINESTRING (6 0, 3 0, 3 2))
CBDA - GEOMETRYCOLLECTION (LINESTRING (3 2, 6 2, 6 0), LINESTRING (3 2, 3 4, 0 4), LINESTRING (6 0, 3 0, 3 2), LINESTRING (0 4, 0 2, 3 2))
CDAB - GEOMETRYCOLLECTION (LINESTRING (3 2, 6 2, 6 0), LINESTRING (6 0, 3 0, 3 2), LINESTRING (0 4, 0 2, 3 2), LINESTRING (3 2, 3 4, 0 4))
CDBA - GEOMETRYCOLLECTION (LINESTRING (3 2, 6 2, 6 0), LINESTRING (6 0, 3 0, 3 2), LINESTRING (3 2, 3 4, 0 4), LINESTRING (0 4, 0 2, 3 2))

DABC - POLYGON ((6 0, 3 0, 3 2, 0 2, 0 4, 3 4, 0 4, 6 2, 6 0))
DACB - GEOMETRYCOLLECTION (LINESTRING (6 0, 3 0, 3 2), LINESTRING (0 4, 0 2, 3 2), LINESTRING (3 2, 6 2, 6 0), LINESTRING (3 2, 3 4, 0 4))
DBAC - POLYGON ((6 0, 3 0, 3 2, 3 4, 0 4, 0 2, 0 4, 6 2, 6 0))
DBCA - GEOMETRYCOLLECTION (LINESTRING (6 0, 3 0, 3 2), LINESTRING (3 2, 3 4, 0 4), LINESTRING (3 2, 6 2, 6 0), LINESTRING (0 4, 0 2, 3 2))
DCAB - GEOMETRYCOLLECTION (LINESTRING (6 0, 3 0, 3 2), LINESTRING (3 2, 6 2, 6 0), LINESTRING (0 4, 0 2, 3 2), LINESTRING (3 2, 3 4, 0 4))
DCBA - GEOMETRYCOLLECTION (LINESTRING (6 0, 3 0, 3 2), LINESTRING (3 2, 6 2, 6 0), LINESTRING (3 2, 3 4, 0 4), LINESTRING (0 4, 0 2, 3 2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants