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

Building polygons in Python #56

Closed
foxan opened this issue Dec 21, 2018 · 1 comment
Closed

Building polygons in Python #56

foxan opened this issue Dec 21, 2018 · 1 comment

Comments

@foxan
Copy link

foxan commented Dec 21, 2018

Hi there,

I'm trying to build polygons from a list of vertices. However, there seems no S2Builder port to pywraps2. How can we build polygons effectively using the Python port?

I've actually tried to build it with S2Loop and S2Polygon,

loop = S2Loop()
points = [S2LatLng.FromDegrees(float(vertex[0]), float(vertex[1])).ToPoint() for vertex in hull[:-1]]
loop.Init(points)
loop.Normalize()
polygon = S2Polygon(loop)

The problem is that S2Loop requires a lot of checking, like edges not intersecting each other. And right now there are no easy ways for me to ensure the input (list of vertices) would not cross with each other (the input is from a concave hull calculation), so I often ran into errors like ERROR Edge 46 crosses edge 48.

Are there any effective ways to build polygons in Python given the circumstance above?

Thanks a lot,
Foxan

@jmr
Copy link
Member

jmr commented Feb 25, 2019

I thought I answered this, but apparently not.

It seems like your concave hull function shouldn't be outputting intersecting edges. Maybe just look at edges 46, 48, and the ones around there and see what's going on.

If that doesn't show you the problem, did you try SWIG wrapping the S2Builder functions you need? I'm not exactly sure what SWIG will do with the unique_ptrs, so it might take some fiddling.

@jmr jmr closed this as completed Sep 20, 2019
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