Skip to content

Commit c7e0a0c

Browse files
authored
Fix paramdim of primitives over ellipsoid (#1001)
1 parent 6203323 commit c7e0a0c

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

src/geometries/primitives/ball.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ Ball(center::Point) = Ball(center, oneunit(lentype(center)))
2323

2424
Ball(center::Tuple) = Ball(Point(center))
2525

26-
paramdim(B::Type{<:Ball}) = embeddim(B)
26+
paramdim(::Type{<:Ball{𝔼{Dim}}}) where {Dim} = Dim
27+
28+
paramdim(::Type{<:Ball{🌐}}) = 2
2729

2830
center(b::Ball) = b.center
2931

src/geometries/primitives/box.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ Box(min::Point{M,C}, max::Point{M,C}) where {M<:Manifold,C<:CRS} = Box{M,C}(min,
4141

4242
Box(min::Tuple, max::Tuple) = Box(Point(min), Point(max))
4343

44-
paramdim(B::Type{<:Box}) = embeddim(B)
44+
paramdim(::Type{<:Box{𝔼{Dim}}}) where {Dim} = Dim
45+
46+
paramdim(::Type{<:Box{🌐}}) = 2
4547

4648
Base.minimum(b::Box) = b.min
4749

src/geometries/primitives/sphere.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ end
6060

6161
Sphere(p1::Tuple, p2::Tuple, p3::Tuple, p4::Tuple) = Sphere(Point(p1), Point(p2), Point(p3), Point(p4))
6262

63-
paramdim(S::Type{<:Sphere}) = embeddim(S) - 1
63+
paramdim(::Type{<:Sphere{𝔼{Dim}}}) where {Dim} = Dim - 1
64+
65+
paramdim(::Type{<:Sphere{🌐}}) = 1
6466

6567
center(s::Sphere) = s.center
6668

test/primitives.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,10 @@
399399
@test maximum(b) == cart(1, 1, 1)
400400
@test extrema(b) == (cart(0, 0, 0), cart(1, 1, 1))
401401

402+
b = Box(latlon(0, 0), latlon(45, 90))
403+
@test embeddim(b) == 3
404+
@test paramdim(b) == 2
405+
402406
b = Box(cart(0, 0), cart(1, 1))
403407
equaltest(b)
404408
isapproxtest(b)
@@ -512,6 +516,10 @@
512516
@test Meshes.center(b) == cart(1, 2, 3)
513517
@test radius(b) == T(5) * u"m"
514518

519+
b = Ball(latlon(0, 0), T(5))
520+
@test embeddim(b) == 3
521+
@test paramdim(b) == 2
522+
515523
b = Ball(cart(0, 0), T(1))
516524
equaltest(b)
517525
isapproxtest(b)
@@ -589,6 +597,10 @@
589597
@test isnothing(boundary(s))
590598
@test perimeter(s) == zero(ℳ)
591599

600+
s = Sphere(latlon(0, 0), T(1))
601+
@test embeddim(s) == 3
602+
@test paramdim(s) == 1
603+
592604
s = Sphere(cart(0, 0), T(1))
593605
equaltest(s)
594606
isapproxtest(s)

0 commit comments

Comments
 (0)