-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add support for multiple hulls #18
base: main
Are you sure you want to change the base?
Add support for multiple hulls #18
Conversation
The input hull from the triangulation can be either a single array for a single hull, or an array of arrays for several hulls. This makes it possible to handle the cases where the region is made up of multiply connected components or has holes (multiply connected).
Nice! To run the tests simply run Please also update the documentation. |
Thanks for the pointer, all the tests do pass :) I'd be happy to update the docs, could you just specify where that would go? Did you mean in the README or something else? |
Re: documentation, yes I was thinking the README maybe if there is a good place for it, and also maybe as a stand-alone example (notebook?) |
Ok I think I know where to put it in the README. An example notebook would indeed be nice to showcase the functionality. I assume you meant something like the examples you have here right? Should I then add an example to your collection? I'm new to observable so I'm not sure what the process is. |
yes; if you can create the example (anywhere convenient for you), I will then set it up properly |
@Fil I just added the documentation and I wrote an example that you can find here. I made this public so you should be able to access the example, but if you are having any trouble just let me know. I adapted the existing examples on re-using a triangulation but made a couple of tweaks that are necessary in the case of multiple hulls (in particular the Let me know if that looks good to you! And happy holidays :) |
It's working well, but do you think it would be possible to accept a GeoJSON (Polygon, MultiPolygon) rather than an "array of arrays of indices"? It would be closer to standards. One difficulty is that we'd need to ensure that the (x,y) coordinates are matched to the internal numbering of vertices. |
I can certainly look into that, could you point me to the GeoJSON documentation so that I can look up how we could go about accepting that as input? |
The GeoJSON specification includes Polygon and MultiPolygon type geometries. Basically the difference with your code is that the coordinates are given as pairs of numbers (x, y), not as indices. So there would be a bit of rematching to do. |
So if I understand correctly, you would like the The thing is we are currently using Also, we still need the indices to access the And there is also the fact that this would be a breaking change, I was trying to be backwards compatible but maybe that's something you don't mind? What do you think? Feel free to let me know if I misunderstood what you were suggesting. |
Yes. My suggestion to go back to the geometries (points) would only have added more work and indirection. However, I rewrote the algorithm to use the triangulation ( |
As mentioned in the UK Tricontours example:
This PR is a proposed implementation of the upgrade mentioned in the case where there are multiple hulls. This is useful for two different cases: when the domain is a single connected component but is multiply connected (i.e. it's in one piece but it has holes), and/or when the domain is made up of several connected components.
This upgrade required very few changes in the code and is backwards compatible.
I saw there is a
test
folder in the repo, but I don't know how to run the test suite, so I did not add a test. If that is something you would like me to add, I'd be happy to exchange on how you test this repo. For my own purposes, the new implementation works correctly, even in cases where there are several connected components and each has several holes.