Skip to content

Commit

Permalink
revise output arg dimension
Browse files Browse the repository at this point in the history
  • Loading branch information
hydrocoast committed May 3, 2021
1 parent 9087392 commit 8d1edd8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/latlon2yx.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,21 @@ function latlon2yx(φ₀, λ₀, φ, λ)
N =*(ξ′ + sum([αj[j]sin(2j*ξ′)cosh(2j*η′) for j=1:5])) - S̅φ₀
E =*(η′ + sum([αj[j]cos(2j*ξ′)sinh(2j*η′) for j=1:5]))

return [N, E]
return [N E]
end
# -------------------------------------
"""
E, N = lonlat2xy(λ₀, φ₀, λ, φ)
See [`lanlon2yx`](@ref)
"""
lonlat2xy(λ₀, φ₀, λ, φ) = reverse(latlon2yx(φ₀, λ₀, φ, λ))
lonlat2xy(λ₀, φ₀, λ, φ) = reverse(latlon2yx(φ₀, λ₀, φ, λ), dims=2)

# -------------------------------------
function latlon2yx_ja(zone::Integer, φ, λ)
!(0 < zone < 20) && error("zone ID must be a integer in the range of 1 to 19.")
return latlon2yx(Origin_LatLon_Japan[zone,:]..., φ, λ)
end
# -------------------------------------
lonlat2xy_ja(zone::Integer, λ, φ) = reverse(latlon2yx_ja(zone, φ, λ))
lonlat2xy_ja(zone::Integer, λ, φ) = reverse(latlon2yx_ja(zone, φ, λ), dims=2)
# -------------------------------------
6 changes: 3 additions & 3 deletions src/yx2latlon.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,20 @@ function yx2latlon(φ₀, λ₀, N, E)
m = m₀*A₀*(1/(1+n))*sqrt( (cos(ξ′)^2+sinh(η′)^2)/(σ′^2+τ′^2) * (1+((1-n)tan(φ)/(1+n))^2) )
=#

return, λ]
return [φ λ]
end
# -------------------------------------
"""
λ, φ = xy2lonlat(λ₀, φ₀, E, N)
See [`yx2latlon`](@ref)
"""
xy2lonlat(λ₀, φ₀, E, N) = reverse(yx2latlon(φ₀, λ₀, N, E))
xy2lonlat(λ₀, φ₀, E, N) = reverse(yx2latlon(φ₀, λ₀, N, E), dims=2)
# -------------------------------------
function yx2latlon_ja(zone::Integer, N, E)
!(0 < zone < 20) && error("zone ID must be a integer in the range of 1 to 19.")
return yx2latlon(Origin_LatLon_Japan[zone,:]..., N, E)
end
# -------------------------------------
xy2lonlat_ja(zone::Integer, E, N) = reverse(yx2latlon_ja(zone, N, E))
xy2lonlat_ja(zone::Integer, E, N) = reverse(yx2latlon_ja(zone, N, E), dims=2)
# -------------------------------------
4 changes: 2 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ using Test
@test (abs(y - 11543.6883) < 1e-4) & (abs(x - 22916.2436) < 1e-4)

# args in reverse order
@test yx2latlon_ja(9, northing, easting) == reverse(xy2lonlat_ja(9, easting, northing))
@test latlon2yx_ja(9, lat, lon) == reverse(lonlat2xy_ja(9, lon, lat))
@test yx2latlon_ja(9, northing, easting) == reverse(xy2lonlat_ja(9, easting, northing), dims=2)
@test latlon2yx_ja(9, lat, lon) == reverse(lonlat2xy_ja(9, lon, lat), dims=2)
end

0 comments on commit 8d1edd8

Please sign in to comment.