Skip to content

Commit

Permalink
Merge branch 'JC_add5070_albers' of https://github.com/souma4/CoordRe…
Browse files Browse the repository at this point in the history
…fSystems.jl into JC_add5070_albers
  • Loading branch information
souma4 committed Oct 28, 2024
2 parents 42b57de + 3d26c03 commit 312f5a0
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions src/crs/projected/eqareaalbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,9 @@
# ------------------------------------------------------------------

"""
Albers{latₒ, lat₁, lat₂, Datum, Shift}
Albers{latₒ,lat₁,lat₂,Datum,Shift}
Albers CRS with latitude origin latₒ standard parallels `lat₁` and `lat₂`, `Datum` and `Shift`.
## Examples
```julia
Albers(1, 1) # add default units
Albers(1m, 1m) # integers are converted converted to floats
Albers(1.0km, 1.0km) # length quantities are converted to meters
Albers(1.0m, 1.0m)
Albers{NAD83}(1.0m, 1.0m)
```
See [EPSG:5070](https://epsg.io/5070).
Albers Conic Equal Area CRS with latitude origin `latₒ` standard parallels `lat₁` and `lat₂`, `Datum` and `Shift`.
"""
struct Albers{latₒ,lat₁,lat₂,Datum,Shift,M<:Met} <: Projected{Datum,Shift}
x::M
Expand All @@ -35,8 +23,6 @@ Albers{latₒ,lat₁,lat₂,Datum,Shift}(x::Number, y::Number) where {latₒ,lat

Albers{latₒ,lat₁,lat₂,Datum}(args...) where {latₒ,lat₁,lat₂,Datum} = Albers{latₒ,lat₁,lat₂,Datum,Shift()}(args...)

Albers(args...) = Albers{NAD83}(args...)

Base.convert(
::Type{Albers{latₒ,lat₁,lat₂,Datum,Shift,M}},
coords::Albers{latₒ,lat₁,lat₂,Datum,Shift}
Expand All @@ -63,7 +49,24 @@ lentype(::Type{<:Albers{latₒ,lat₁,lat₂,Datum,Shift,M}}) where {latₒ,lat
# Authors of the original algorithm: Gerald Evenden and Thomas Knudsen
# reference code: https://github.com/OSGeo/PROJ/blob/master/src/projections/aea.cpp

inbounds(::Type{<:Albers}, λ, ϕ) = -2π λ 2π && -π ϕ π
function inbounds(::Type{<:Albers{latₒ,lat₁,lat₂,Datum}}, λ, ϕ) where {latₒ,lat₁,lat₂,Datum}
🌎 = ellipsoid(Datum)
e = oftype(λ, eccentricity(🌎))
= oftype(λ, eccentricity²(🌎))
ϕₒ = oftype(λ, ustrip(deg2rad(latₒ)))
ϕ₁ = oftype(λ, ustrip(deg2rad(lat₁)))
ϕ₂ = oftype(λ, ustrip(deg2rad(lat₂)))

m₁ = hm(ϕ₁, e, e²)
m₂ = hm(ϕ₂, e, e²)
α₁ = (ϕ₁, e, e²)
α₂ = (ϕ₂, e, e²)
n = (m₁^2 - m₂^2) / (α₂ - α₁)
C = m₁^2 + n * α₁

ρ = sqrt(C - n * (ϕ, e, e²)) / n
ρ 0
end

function formulas(::Type{<:Albers{latₒ,lat₁,lat₂,Datum}}, ::Type{T}) where {latₒ,lat₁,lat₂,Datum,T}
🌎 = ellipsoid(Datum)
Expand Down

0 comments on commit 312f5a0

Please sign in to comment.