JuliaGeo / Proj.jl

Julia wrapper for the PROJ cartographic projections library
MIT License
48 stars 9 forks source link

Remove StaticArrays dependency #64

Closed visr closed 2 years ago

visr commented 2 years ago

Change Coord from being a SVector{4, Float64} alias to a struct implemented here. This struct is now mostly internal, since tuples are always returned from transformations. Length of the output tuple still depends on the input length. SVectors still work as input coordinates, just like tuples, vectors, and multiple arguments f(x, y).

I included a benchmark here that shows that performance is good: https://github.com/JuliaGeo/Proj4.jl/blob/a2e71c159a5892b0986e1b933fe0ff405ce940a2/test/benchmark.jl

This is the same benchmark as used here: https://github.com/JuliaGeo/Proj4.jl/pull/51#issuecomment-864467491. For types like SVector or tuples the return type (tuple length) can be inferred precisely, for Vector it infers Union{NTuple{2,Float64},NTuple{3,Float64},NTuple{4,Float64}} which is as good as we can expect.

This is on top of #57, but since it changes the return type of transformations I wanted to put it up separately for review. I think after this #57 would be ready for release, I was thinking to make it Proj.jl v1, such that we can actually start using the minor version number for features.

visr commented 2 years ago

Thanks for having a look, and good point about the return type. Returning the same type was originally a design goal, see also old discussion here. It looks like on top of this refactor it's really as easy as #65.