-
Notifications
You must be signed in to change notification settings - Fork 4
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 a convex hull algorithm #160
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Know it's in draft but happened to notice a couple of things here
|
||
# TODO: have this respect the CRS by pulling it out of `geometries`. | ||
function convex_hull(::DelaunayTriangulationMethod, geometries) | ||
# Extract all points as tuples. We have to collect and allocate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this true? You can provide whatever point types you like so long as you extend the interfaces (which are hopefully sufficiently documented) from DelaunayTriangulation.jl appropriately. I give a complete example here https://juliageometry.github.io/DelaunayTriangulation.jl/dev/tutorials/custom_primitive/, maybe something goes wrong in convex_hull
that I'm not aware of?
Highlighted the wrong part of the text for this comment but I'm referring to the need to flatten and collect the points
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to flatten anyway to get a vector, and getting x and y values from C pointers is pretty bad for performance - best to do it once. I can update the comment with better verbiage, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plus, we'd have to extend the interface for every GeoInterface compatible type, which would probably mean either piracy or changes on the DelaunayTriangulation end. (Though if you do want to allow GeoInterface as a fallback it would be pretty easy I think).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to flatten anyway to get a vector, and getting x and y values from C pointers is pretty bad for performance - best to do it once. I can update the comment with better verbiage, though.
I have no preference either way just wanted to see if you were aware (I wasn't aware of the need for getting the values from C pointers, so fair enough). The verbiage is alright
Plus, we'd have to extend the interface for every GeoInterface compatible type, which would probably mean either piracy or changes on the DelaunayTriangulation end. (Though if you do want to allow GeoInterface as a fallback it would be pretty easy I think).
It would probably be welcome as a package extension in DelaunayTriangulation. I'm not familiar with the interfaces though, so I probably won't be delving into that. Just leaving the code as is is fine anyway, it works and would be fast enough :).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would probably just be:
DT.getx(p) = DT.getx(GI.trait(p), p)
DT.gety(p) = DT.gety(GI.trait(p), p)
DT.number_type(p) = DT.number_type(GI.trait(p), p)
DT.getx(::GI.PointTrait, p) = GI.x(p)
DT.gety(::GI.PointTrait, p) = GI.y(p)
DT.number_type(::GI.PointTrait, p) = typeof(GI.x(p))
Co-authored-by: Daniel VandenHeuvel <95613936+DanielVandH@users.noreply.github.com>
This is good to go from my end of things! |
GEOS's convex hull is wound clockwise? Somehow? Simple features dictates the opposite but I guess this is following ESRI... |
Via DelaunayTriangulation.jl.
Needs to be updated to latest main as well as some tests + a GEOS algorithm.