Skip to content

Commit a9b2511

Browse files
authored
Fix Rotate and Scale of RegularGrid (#1071)
1 parent e5d3d51 commit a9b2511

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

src/transforms/rotate.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ applycoord(t::Rotate, b::Box) = TransformedGeometry(b, t)
6060

6161
applycoord(t::Rotate, e::Ellipsoid) = Ellipsoid(radii(e), applycoord(t, center(e)), t.rot * rotation(e))
6262

63-
applycoord(t::Rotate, g::CartesianGrid) = TransformedGrid(g, t)
63+
applycoord(t::Rotate, g::RegularGrid) = TransformedGrid(g, t)
6464

6565
applycoord(t::Rotate, g::RectilinearGrid) = TransformedGrid(g, t)
6666

src/transforms/scale.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ function applycoord(t::Scale, g::CartesianGrid)
7676
CartesianGrid(dims, orig, spac, offs)
7777
end
7878

79+
applycoord(t::Scale, g::RegularGrid) = TransformedGrid(g, t)
80+
7981
applycoord(t::Scale, g::RectilinearGrid) =
8082
RectilinearGrid{manifold(g),crs(g)}(ntuple(i -> t.factors[i] * xyz(g)[i], paramdim(g)))
8183

test/transforms.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,16 @@
182182
@test r SimpleMesh(f.(vertices(d)), topology(d))
183183
@test TB.revert(f, r, c) d
184184

185+
# ------------
186+
# REGULARGRID
187+
# ------------
188+
189+
f = Rotate(Angle2d(T/ 2)))
190+
d = RegularGrid(merc(0, 0), merc(1, 1), dims=(10, 10))
191+
r, c = TB.apply(f, d)
192+
@test r SimpleMesh(f.(vertices(d)), topology(d))
193+
@test TB.revert(f, r, c) d
194+
185195
# ----------------
186196
# RECTILINEARGRID
187197
# ----------------
@@ -851,6 +861,16 @@ end
851861
@test r CartesianGrid(cart(1, 2), cart(11, 22), dims=(10, 10))
852862
@test TB.revert(f, r, c) d
853863

864+
# ------------
865+
# REGULARGRID
866+
# ------------
867+
868+
f = Scale(T(1), T(2))
869+
d = RegularGrid(merc(1, 1), merc(11, 11), dims=(10, 10))
870+
r, c = TB.apply(f, d)
871+
@test r RegularGrid(merc(1, 2), merc(11, 22), dims=(10, 10))
872+
@test TB.revert(f, r, c) d
873+
854874
# ----------------
855875
# RECTILINEARGRID
856876
# ----------------

0 commit comments

Comments
 (0)