Skip to content

Commit

Permalink
Add missing construtor & Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eliascarv committed Oct 28, 2024
1 parent 2f866d1 commit 1b19bf6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/crs/projected/albers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ 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{latₒ,lat₁,lat₂}(args...) where {latₒ,lat₁,lat₂} = Albers{latₒ,lat₁,lat₂,WGS84Latest}(args...)

Base.convert(
::Type{Albers{latₒ,lat₁,lat₂,Datum,Shift,M}},
coords::Albers{latₒ,lat₁,lat₂,Datum,Shift}
Expand Down
8 changes: 4 additions & 4 deletions test/crs/constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -625,21 +625,21 @@
end

@testset "Albers" begin
A = Albers{23.0°,29.5°,45.5°,NAD83}
A = Albers{23.0°,29.5°,45.5°}
@test A(T(1), T(1)) == A(T(1) * m, T(1) * m)
@test A(T(1) * m, 1 * m) == A(T(1) * m, T(1) * m)
@test A(T(1) * km, T(1) * km) == A(T(1000) * m, T(1000) * m)

c = A(T(1), T(1))
@test sprint(show, c) == "Albers{NAD83}(x: 1.0 m, y: 1.0 m)"
@test sprint(show, c) == "Albers{WGS84Latest}(x: 1.0 m, y: 1.0 m)"
if T === Float32
@test sprint(show, MIME("text/plain"), c) == """
Albers{NAD83} coordinates
Albers{WGS84Latest} coordinates
├─ x: 1.0f0 m
└─ y: 1.0f0 m"""
else
@test sprint(show, MIME("text/plain"), c) == """
Albers{NAD83} coordinates
Albers{WGS84Latest} coordinates
├─ x: 1.0 m
└─ y: 1.0 m"""
end
Expand Down
2 changes: 1 addition & 1 deletion test/crs/domains.jl
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
@testset "Albers Forward" begin
AlbersUS = CoordRefSystems.shift(Albers{23.0°,29.5°,45.5°,NAD83}, lonₒ=-96.0°)
for lat in T.(-90:90), lon in T.(-180:180)
c1 = LatLon(lat, lon)
c1 = LatLon{NAD83}(lat, lon)
if indomain(AlbersUS, c1)
c2 = convert(AlbersUS, c1)
@test isfinite(c2.x)
Expand Down
3 changes: 2 additions & 1 deletion test/crs/rand.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
randtest(OrthoSouth{WGS84Latest})
randtest(OrthoSouth)

randtest(CoordRefSystems.get(EPSG{5070}))
randtest(Albers{23.0°,29.5°,45.5°,WGS84Latest})
randtest(Albers{23.0°,29.5°,45.5°})
end
end

0 comments on commit 1b19bf6

Please sign in to comment.