GeometryBasics.jl
GeometryBasics.jl copied to clipboard
StructArrays interface for points
When calling into C functions with large arrays of points, it would be useful to have mutable StructArrays of points. As far as I understand it, this would just involve defining a static schema for Points.
Would this be a wanted feature? Also, how would we handle vectors of n-dimensional Points?
it would be useful to have mutable StructArrays of point
Why? Can you give a concrete example?
Transformations with the Proj library come to mind - it accepts separate arrays of x, y, and z, and the most efficient mode of operation is to operate in place. Having 3 arrays of x, y, and z which could be transformed in place would be pretty useful, especially when you get into >500K points.
I thought this was trivially supported, but can't find the correct constructor right now :D Evidence, that this should be made easier & documented...
After talking with @piever it may be a bug: https://github.com/JuliaArrays/StructArrays.jl/issues/126
Well I tried it a while ago...the issue is that we store the data in a tuple, so StructArrays just makes an array of tuples, which is useless for this. We need to define our own static schema which takes, for example, a Point3f0, and maps it to x, y, and z (or x1, x2 and x3, but that's uglier)...
Yeah, but this is supposed to "just work"... So lets see if we can have this fixed ;)
I've commented over at https://github.com/JuliaArrays/StructArrays.jl/issues/126#issuecomment-624011508. It can be made to work already if one calls the constructor in a slightly different way, and one gets a
StructArray(data::StructArray(::Array{Float32,1}, ::Array{Float32,1}, ::Array{Float32,1}))
Alright, that's fair! I think GeometryBasics should just support a convenience constructor for this :)