Skip to content

Commit 297d188

Browse files
authored
Merge pull request #2 from anowacki/an/tuples
Reduce allocations to improve speed
2 parents 4608ae0 + fa30005 commit 297d188

3 files changed

Lines changed: 114 additions & 98 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ConvertBNG"
22
uuid = "76c420ca-8e5d-4181-817d-b9cafca33221"
33
authors = ["Joshua Nunn <joshuanunn@hotmail.co.uk>"]
4-
version = "0.3.1"
4+
version = "0.4.0"
55

66
[deps]
77
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"

src/ConvertBNG.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ Perform Longitude, Latitude to ETRS89 conversion
135135
north = I + II * l ^ 2 + III * l ^ 4 + IIIA * l ^ 6
136136
east = E₀ + IV * l + V * l ^ 3 + VI * l ^ 5
137137

138-
return [east north]
138+
return east, north
139139
end
140140

141141
"""
@@ -184,7 +184,7 @@ Note that either GRS80 or Airy 1830 ellipsoids can be passed
184184
ϕ = rad2deg(ϕ)
185185
λ = rad2deg(λ)
186186
λ, ϕ = round_to_eight(λ, ϕ)
187-
return [λ ϕ]
187+
return λ, ϕ
188188
end
189189

190190
function convert_etrs89_to_ll(E::T, N::T) where {T<:Real}
@@ -207,7 +207,7 @@ function convert_osgb36(lonlat::Array{T,2}) where{T<:Real}
207207
en_arr = zeros(T, size(lonlat))
208208
# Transform
209209
Threads.@threads for i in 1:size(lonlat)[1]
210-
en_arr[i,:] = convert_osgb36(lonlat[i,1], lonlat[i,2])
210+
en_arr[i,:] .= convert_osgb36(lonlat[i,1], lonlat[i,2])
211211
end
212212
return en_arr
213213
end
@@ -220,7 +220,7 @@ function convert_osgb36_nothread(lonlat::Array{T,2}) where{T<:Real}
220220
en_arr = zeros(T, size(lonlat))
221221
# Transform
222222
for i in 1:size(lonlat)[1]
223-
en_arr[i,:] = convert_osgb36(lonlat[i,1], lonlat[i,2])
223+
en_arr[i,:] .= convert_osgb36(lonlat[i,1], lonlat[i,2])
224224
end
225225
return en_arr
226226
end
@@ -232,7 +232,7 @@ function convert_etrs89_to_osgb36(E::T, N::T) where {T<:Real}
232232
# Obtain OSTN15 corrections, and incorporate
233233
e_shift, n_shift, _ = ostn15_shifts(E, N)
234234
e_corr, n_corr = round_to_mm(E + e_shift, N + n_shift)
235-
return [e_corr n_corr]
235+
return e_corr, n_corr
236236
end
237237

238238
"""
@@ -250,7 +250,7 @@ function convert_osgb36_to_ll(en::Array{T,2}) where{T<:Real}
250250
ll_arr = zeros(T, size(en))
251251
# Transform
252252
Threads.@threads for i in 1:size(en)[1]
253-
ll_arr[i,:] = convert_osgb36_to_ll(en[i,1], en[i,2])
253+
ll_arr[i,:] .= convert_osgb36_to_ll(en[i,1], en[i,2])
254254
end
255255
return ll_arr
256256
end
@@ -263,7 +263,7 @@ function convert_osgb36_to_ll_nothread(en::Array{T,2}) where{T<:Real}
263263
ll_arr = zeros(T, size(en))
264264
# Transform
265265
for i in 1:size(en)[1]
266-
ll_arr[i,:] = convert_osgb36_to_ll(en[i,1], en[i,2])
266+
ll_arr[i,:] .= convert_osgb36_to_ll(en[i,1], en[i,2])
267267
end
268268
return ll_arr
269269
end
@@ -289,7 +289,7 @@ function convert_osgb36_to_etrs89(E::T, N::T) where {T<:Real}
289289
end
290290
x = E - dx
291291
y = N - dy
292-
return [x y]
292+
return x, y
293293
end
294294

295295
"""

0 commit comments

Comments
 (0)