JuliaGeo / LibGEOS.jl

Julia package for manipulation and analysis of planar geometric objects
MIT License
72 stars 23 forks source link

GEOSConcaveHullByLength Error #182

Closed MaximeROUBY closed 1 year ago

MaximeROUBY commented 1 year ago

I tried to use your GEOSConcaveHullByLength function and it seems that it crashes when calling the C code. I am looking into it but if you find a solution before I do, it could be nice to correct it XD. image

visr commented 1 year ago

Like in https://github.com/JuliaGeo/LibGEOS.jl/issues/181#issuecomment-1701708022, this hasn't been wrapped, so it's a bit harder to use, but here is an example. The main things are that the first argument needs to be a context handle, and a Vector{Point} is not accepted, it needs to be converted to a MultiPoint first.

julia> using LibGEOS

julia> g = MultiPoint([[1.1,2.2],[3.3,4.4],[2.2,3.3]])
MULTIPOINT ((1.1 2.2), (3.3 4.4), (2.2 3.3))

julia> ctx = LibGEOS.get_context(g)
LibGEOS.GEOSContext(Ptr{Nothing} @0x0000024a80733c20)

julia> ptr = LibGEOS.GEOSConcaveHullByLength_r(ctx, g, 1.5, 1)
Ptr{Nothing} @0x0000024b131a8b50

julia> conc = LibGEOS.geomFromGEOS(ptr)
POLYGON ((1.1 2.2, 3.3 4.4, 2.2 3.3, 1.1 2.2))
MaximeROUBY commented 1 year ago

Thanks for the quick answer. However, I tried your code and it didn't work for me. Is there something wrong with my installation ? image

visr commented 1 year ago

It looks like it, yes. Is this using LibGEOS v0.8.5 with GEOS_jll v3.12.0? Could you share the output of versioninfo() and from the package manager (press ]), st -m? That shows the versions.

MaximeROUBY commented 1 year ago

[a90b1aa1] LibGEOS v0.8.5 [d604d12d] GEOS_jll v3.11.2+0 Oh Here is the issue, isn't it ?

MaximeROUBY commented 1 year ago

(The output was huge so I took only those two)

MaximeROUBY commented 1 year ago

I also use GDAL for this project and it seems to block my version of GEOS_jll

visr commented 1 year ago

Right indeed that explains it. I should've added compat bounds such that you cannot get the newly wrapped functions with an old binary that doesn't have them, I forgot. So for now you cannot use both at the same time, until a new GDAL_jll is released that is compatible with GEOS 3.12.

I saw some work was underway in https://github.com/JuliaPackaging/Yggdrasil/pull/7050 but it looks a bit stalled.

MaximeROUBY commented 1 year ago

Ok. No problem, thank you for the help :)

visr commented 1 year ago

GDAL.jl 1.6.1 should no longer hold back the GEOS version.

MaximeROUBY commented 1 year ago

Yes I just tried it and it worked perfectly. Thanks :)