Skip to content

Commit f6276b4

Browse files
committed
hotfix bug in crw_in_polygon with non-default initPos and missing cartesianCRS; fixes 277
1 parent 503cb29 commit f6276b4

File tree

5 files changed

+58
-3
lines changed

5 files changed

+58
-3
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ Package: glatos
22
Type: Package
33
Title: A package for the Great Lakes Acoustic Telemetry Observation System
44
Description: Functions useful to members of the Great Lakes Acoustic Telemetry Observation System https://glatos.org; many more broadly relevant to simulating, processing, analysing, and visualizing acoustic telemetry data.
5-
Version: 0.9.4
6-
Date: 2026-02-13
5+
Version: 0.9.5
6+
Date: 2026-03-25
77
Depends: R (>= 3.6.0)
88
Imports:
99
av,

NEWS.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
----
22

3+
# glatos 0.9.5 (2026-03-25)
4+
5+
6+
### Bug fixes
7+
8+
- Fixed bug in `crw_in_polygon()` that caused failure with error with
9+
non-default initPos and missing cartesianCRS arguments when crs of input
10+
polyg is cartesian.
11+
- fixes [issue #277](https://github.com/ocean-tracking-network/glatos/issues/277)
12+
13+
14+
----
15+
316
# glatos 0.9.4 (2026-02-13)
417

518

R/sim-crw_in_polygon.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ crw_in_polygon <- function(
217217
crs_cartesian <- sf::st_crs(cartesianCRS)
218218

219219
# Set crs_cartesian = crs_input if Cartesian and cartesianCRS missing
220-
if (is.na(crs_cartesian) & isTRUE(crs_in$IsGeographic)) {
220+
if (is.na(crs_cartesian) & isFALSE(crs_in$IsGeographic)) {
221221
crs_cartesian <- crs_in
222222
}
223223

tests/testthat/_snaps/crw_in_polygon.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,21 @@
9191
5 POINT (-87.83445 48.69117)
9292
6 POINT (-87.95955 48.72632)
9393

94+
# sf input, sf output gives expected result with non-default init_pos and missing cartesianCRS (issue 277)
95+
96+
Code
97+
sfin_sfout
98+
Output
99+
Simple feature collection with 6 features and 0 fields
100+
Geometry type: POINT
101+
Dimension: XY
102+
Bounding box: xmin: 832597 ymin: 1024974 xmax: 857297.5 ymax: 1056453
103+
Projected CRS: NAD83 / Great Lakes and St Lawrence Albers
104+
geometry
105+
1 POINT (832597 1048244)
106+
2 POINT (838307.6 1056453)
107+
3 POINT (847638.5 1052857)
108+
4 POINT (853177.5 1044531)
109+
5 POINT (854868.4 1034675)
110+
6 POINT (857297.5 1024974)
111+

tests/testthat/test-crw_in_polygon.r

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,30 @@ test_that("sf input, sf output gives expected result", {
158158
})
159159

160160

161+
test_that("sf input, sf output gives expected result with non-default init_pos and missing cartesianCRS (issue 277)", {
162+
set.seed(30)
163+
164+
expect_s3_class(
165+
sfin_sfout <- crw_in_polygon(
166+
polyg = sf::st_transform(great_lakes_polygon, crs = 3175),
167+
theta = c(0, 25),
168+
stepLen = 10000,
169+
initPos = c(832597, 1048244),
170+
nsteps = 5,
171+
sp_out = TRUE,
172+
show_progress = FALSE
173+
),
174+
"sf"
175+
)
176+
177+
expect_equal(dim(sfin_sfout), c(6, 1))
178+
179+
expect_snapshot(
180+
sfin_sfout
181+
)
182+
})
183+
184+
161185
##### TEST NON-EXPORTED FUNCTIONS ####
162186

163187
test_that("internal function crosses_boundary gives expected result", {

0 commit comments

Comments
 (0)