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

s2_rebuild transforms POLYGON FULL into an empty geometrycollection #262

Open
edzer opened this issue Sep 20, 2024 · 3 comments
Open

s2_rebuild transforms POLYGON FULL into an empty geometrycollection #262

edzer opened this issue Sep 20, 2024 · 3 comments

Comments

@edzer
Copy link
Member

edzer commented Sep 20, 2024

I'm (finally) implementing support for POLYGON FULL in sf, and ran into s2_rebuild converting an s2 full polygon to a GEOMETRYCOLLECTION EMPTY. I don't think it should! I'll work around it in sf, but it would be nice if it wasn't touched in s2_rebuild: In a debug session in sf::st_make_valid():

Browse[1]> s2
<geodesic s2_geography[2] with CRS=OGC:CRS84>
[1] POLYGON ((0 -90, 0 -90))             POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0...
Browse[1]> 
debug: s2 = s2::s2_rebuild(s2, s2_options)
Browse[1]> 
debug: st_as_sfc(s2, crs = crs)
Browse[1]> s2
<geodesic s2_geography[2] with CRS=OGC:CRS84>
[1] GEOMETRYCOLLECTION EMPTY             POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0...
@paleolimbot
Copy link
Collaborator

That's a great point...the S2Builder doesn't know about full polygons (I seem to remember) and there are some special gymnastics to ensure that it is handled properly in boolean operations. A single full polygon can probably be special-cased...I am not sure what would happen if one tried to rebuild a polygon that contained a FULL loop, though.

@paleolimbot
Copy link
Collaborator

I don't think we have an s2_is_full() to special-case this at the R level but that would basically be the workaround.

@edzer
Copy link
Member Author

edzer commented Sep 21, 2024

s2_is_full() would be great to have!

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

2 participants