Skip to content

Commit ddac546

Browse files
kylebeggsKyle Beggsjuliohmeliascarv
authored
Handle different CRS and length units in sideof (#1014)
* add length convert to sideof * use Proj * Update src/sideof.jl Co-authored-by: Júlio Hoffimann <[email protected]> * fix test for sideof with different units * More adjustments * Update compat * Refactor withcrs * Revert changes --------- Co-authored-by: Kyle Beggs <[email protected]> Co-authored-by: Júlio Hoffimann <[email protected]> Co-authored-by: Elias Carvalho <[email protected]>
1 parent e6c59de commit ddac546

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ MeshesMakieExt = "Makie"
3131
Bessels = "0.2"
3232
CircularArrays = "1.3"
3333
Colorfy = "0.1"
34-
CoordRefSystems = "0.10"
34+
CoordRefSystems = "0.11"
3535
DelaunayTriangulation = "1.0"
3636
Distances = "0.10"
3737
LinearAlgebra = "1.9"

src/sideof.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@ Possible results are `IN`, `OUT` or `ON` the `ring`.
5858
"""
5959
function sideof(point::Point, ring::Ring)
6060
assertion(CoordRefSystems.ncoords(crs(point)) == 2, "points must have 2 coordinates")
61+
point′ = point |> Proj(crs(ring))
6162
if nvertices(ring) 1000 || Threads.nthreads() == 1
62-
_sideofserial(point, ring)
63+
_sideofserial(point, ring)
6364
else
64-
_sideofthreads(point, ring)
65+
_sideofthreads(point, ring)
6566
end
6667
end
6768

test/sideof.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
pts = [p1, p2, p3]
1616
@test sideof(pts, c) == [IN, OUT, ON]
1717

18+
c′ = c |> LengthUnit(Unitful.mm)
19+
@test sideof(p1, c′) == IN
20+
@test sideof(p2, c′) == OUT
21+
@test sideof(p3, c′) == ON
22+
pts = [p1, p2, p3]
23+
@test sideof(pts, c′) == [IN, OUT, ON]
24+
1825
p1, p2, p3 = merc(0.5, 0.5), merc(1.5, 0.5), merc(1, 1)
1926
c = Ring([merc(0, 0), merc(1, 0), merc(1, 1), merc(0, 1)])
2027
@test sideof(p1, c) == IN

0 commit comments

Comments
 (0)