Skip to content

Commit d099a69

Browse files
committed
fix for older julia versions
1 parent 6ba9d45 commit d099a69

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

src/libproj.jl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -490,10 +490,17 @@ function proj_degree_output(P, dir)
490490
@ccall libproj.proj_degree_output(P::Ptr{PJ}, dir::PJ_DIRECTION)::Cint
491491
end
492492

493-
proj_trans(P, direction, coord) = proj_trans(P, direction, Coord(coord))
494-
function proj_trans(P, direction, coord::Coord{N}) where N
495-
@ccall libproj.proj_trans(P::Ptr{PJ}, direction::PJ_DIRECTION, coord::Coord{N})::Coord{N}
496-
end
493+
# In older Julia versions `@ccall` fails silently on `Coord{N}` input
494+
# So we temporarily unrap it as an NTuple and rewrap.
495+
# This *should* have no overhead.
496+
#
497+
# When there is a new LTS we can remove these specialisations
498+
function proj_trans(P, direction, coord::Coord{N}) where N
499+
coord1 = (coord.x, coord.y, coord.z, coord.t)
500+
@ccall libproj.proj_trans(P::Ptr{PJ}, direction::PJ_DIRECTION, coord1::NTuple{4,Float64})::Coord{N}
501+
end
502+
# Accept other types
503+
proj_trans(P, direction, coord) = proj_trans(P, direction, Coord(coord...))
497504

498505
function proj_trans_get_last_used_operation(P)
499506
@ccall libproj.proj_trans_get_last_used_operation(P::Ptr{PJ})::Ptr{PJ}

test/libproj.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,11 @@ end
104104

105105
# transform to UTM zone 32
106106
b = Proj.proj_trans(pj, Proj.PJ_FWD, a)
107-
@show b
108107
@test is_approx(b, (691875.632, 6098907.825, 0.0, Inf))
109108

110109
# inverse transform, back to geographical
111-
b = Proj.proj_trans(pj, Proj.PJ_INV, b)
112-
@show b
113-
@test is_approx(b, (12.0, 55.0, 0.0, Inf))
110+
c = Proj.proj_trans(pj, Proj.PJ_INV, b)
111+
@test is_approx(c, (12.0, 55.0, 0.0, Inf))
114112

115113
# Clean up
116114
pj = Proj.proj_destroy(pj)

test/runtests.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@ is_approx(a, b) = all(isapprox(c[1], c[2]) for c in zip(a, b))
88
@testset "Proj" begin
99
include("libproj.jl")
1010
include("applications.jl")
11-
12-
end # testset "Proj"
11+
end

0 commit comments

Comments
 (0)