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

Concave hull with holes #181

Open
Wikunia opened this issue Aug 31, 2023 · 2 comments
Open

Concave hull with holes #181

Wikunia opened this issue Aug 31, 2023 · 2 comments

Comments

@Wikunia
Copy link

Wikunia commented Aug 31, 2023

I just came across this library and I'm interested in the concave hull functionality of LibGEOS. Looks like there are some C calls implemented for this but I'm unsure how they can be used as there isn't a function like concavehull as one exists for convexhull.

Can the concave hull functionality be used already or does it need some more work and the functions like GEOSConcaveHull are just the preparation step?

@visr
Copy link
Member

visr commented Aug 31, 2023

Yes, the functions in src/generated/libgeos_api.jl and we generally wrap them in geos_functions.jl to offer a nicer API. And like you mention for GEOSConcaveHull that hasn't been done yet. That doesn't mean it cannot be used directly though. Contributions like this are always welcome.

function GEOSConcaveHull_r(handle, g, ratio, allowHoles)
@ccall libgeos.GEOSConcaveHull_r(
handle::GEOSContextHandle_t,
g::Ptr{GEOSGeometry},
ratio::Cdouble,
allowHoles::Cuint,
)::Ptr{GEOSGeometry}
end

function convexhull(obj::Geometry, context::GEOSContext = get_context(obj))
result = GEOSConvexHull_r(context, obj)
if result == C_NULL
error("LibGEOS: Error in GEOSConvexHull")
end
geomFromGEOS(result, context)
end

So if you have a GEOS geometry object, you can get its context from get_context(obj), and pass both into the low-level function. The geomFromGEOS function converts the pointer we get back from GEOS into a geometry type.

@visr
Copy link
Member

visr commented Sep 25, 2023

Similarly GEOSConcaveHullByLength needs to be wrapped, this came up in #182.

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