Skip to content

Commit 2a99a5c

Browse files
eliascarvjuliohm
andauthored
Refactor withcrs (#1023)
* Refactor 'withcrs' * Apply suggestions from code review Co-authored-by: Júlio Hoffimann <[email protected]> --------- Co-authored-by: Júlio Hoffimann <[email protected]>
1 parent ddac546 commit 2a99a5c

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/transforms/shadow.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ _sort(dims) = sort(SVector(dims))
8383

8484
_shadow(v::Vec, dims) = v[dims]
8585

86-
_shadow(p::Point, dims) = withcrs(p, to(p)[dims])
86+
function _shadow(p::Point, dims)
87+
v = _shadow(to(p), dims)
88+
c = Cartesian{datum(crs(p))}(v...)
89+
Point(c)
90+
end
8791

8892
function _shadow(g::CartesianGrid, dims)
8993
sz = size(g)[dims]

src/utils/crs.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ Point at the end of the vector `v` with the same CRS of `g`.
99
"""
1010
function withcrs(g::GeometryOrDomain, v::StaticVector)
1111
C = crs(g)
12-
cart = Cartesian{datum(C)}(Tuple(v))
13-
ctor = CoordRefSystems.constructor(C)
14-
Point(convert(ctor, cart))
12+
D = datum(C)
13+
c = convert(C, Cartesian{D}(v...))
14+
Point(c)
1515
end
1616

1717
"""

test/intersections.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@
831831
b1 = Box((T(0) * u"cm", T(0) * u"cm"), (T(100) * u"cm", T(100) * u"cm"))
832832
b2 = Box((T(500) * u"mm", T(500) * u"mm"), (T(2000) * u"mm", T(2000) * u"mm"))
833833
@test intersection(b1, b2) |> type == Overlapping
834-
@test unit(Meshes.lentype(b1 b2)) == u"m"
834+
@test unit(Meshes.lentype(b1 b2)) == u"cm"
835835
@test b1 b2 == Box(cart(0.5, 0.5), cart(1, 1))
836836

837837
# type stability tests

0 commit comments

Comments
 (0)