-
Notifications
You must be signed in to change notification settings - Fork 23
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
Type instability of buffer
function
#208
Comments
Oh I just figured that For example: mymultipoint2 = readgeom("MULTIPOINT(1.0 1.0, 2.0 2.0)")
buffer(mymultipoint2, 1.0) |> typeof # Polygon |
buffer
function
OK I just figured a case where mypoly = readgeom("POLYGON ((0.5 2.5, 0.5 0.5, 4.5 0.5, 4.5 3.5, 3.5 3.5, 3.5 5.5, 4.5 5.5, 4.5 8.5, 0.5 8.5, 0.5 5.5, 2.5 5.5, 2.5 3.5, 0.5 3.5, 0.5 2.5))")
mypoly |> typeof # Polygon
buffer(mypoly, -0.5) |> typeof # MultiPolygon So yeah, my previous understandings do not hold because of some edge cases. Do you have any idea if there is a way to make |
We can always restrict output to But it's not possible to know ahead of time whether the buffer of a geometry will return a Polygon or a MultiPolygon. Is this causing any slowdowns for you? The memory representation of all these objects in Julia is the same (a pointer to the C/C++ GEOS object)... |
Thanks for the rapid answer it answered my question. I did not test whether this was causing any slowdowns. I'm still learning Julia, and when I was inspecting my code, I noticed the multiple possible return types of buffer. I thought this might indicate a problem or a potential speedup that could be gained. That led me to create this issue. My initial use case was Feel free to close the issue! |
Hello! First of all, thank you for creating and working on the JuliaGeo ecosystem. It is really awesome work!
The
buffer
function is not type stable even though LibGEOS.jl documentation indicates that it always returns a polygon and GEOS documentation specifies the same thing.Edit: My initial understanding of the problem was not correct. See this comment below for the real question. Sorry for the messiness of the issue 😅
From my understanding:
buffer(::Polygon, ::Real)
returns aPolygon
(edit: it can also return aMultiPolygon
, see this comment below)buffer(::AbstractMultiGeometry, ::Real)
returns aMultiPolygon
(edit: it can also return aPolygon
, see this comment below)Here is two MWE:
For an
AbstractGeometry
:For an
AbstractMultiGeometry
:I don't know if I missed any edge cases but I was wondering if there was anything that could be done to fix this?
The text was updated successfully, but these errors were encountered: