big refactor #53
Replies: 1 comment
-
trip2 Refactor: Status SnapshotUpdated: 2026-02-26 Executive SummaryModernizing the Dependency Pipeline Status
Critical Path (updated)Completed: traipse geosphere -> geographiclib MigrationWhat changedFive geosphere call sites replaced:
Internal vectorization helper (no new CRAN release of geographiclib needed): .geodesic_inverse <- function(lon1, lat1, lon2, lat2) {
geographiclib::geodesic_inverse(cbind(lon1, lat1), cbind(lon2, lat2))
}This works because geodesic_inverse already accepts matrices and vectorizes through geodesic_inverse_cpp internally. The helper just smooths the 4-vector call signature. track_intermediate migration details
README example migration# Old:
dest <- geosphere::destPoint(metric[1:10, c("x", "y")],
b = metric$bearing[1:10], d = metric$distance[2:11])
# New:
dest <- geographiclib::geodesic_direct(
metric$x[1:10], metric$y[1:10],
metric$bearing[1:10], metric$distance[2:11]
)Bug found and fixedtrack_angle() errored on length < 3 input (subscript out of bounds in xy[2:(n-1), ]). Added early return guard: Behavioural noteIdentical points: geographiclib::geodesic_inverse returns azi1=180 for zero-distance pairs. This matches geosphere::bearing behaviour (also returns 180), so no change in track_bearing output for stationary points. Test Suite228 tests across 12 contexts, zero failures. Test files created:
Diagnostic output (pre-swap, confirming numerical identity): (Machine epsilon — confirms geosphere::bearing already uses Karney internally via PROJ) Next Steps
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
trip2 Refactor: Status Snapshot
Updated: 2026-02-26
Executive Summary
Modernizing the
tripR package (animal tracking data) from sp-based S4 classes to a hypertidy stack built on grouped tibbles and dplyr. The traipse geosphere->geographiclib migration is complete with 228 tests passing. Next: CRAN submissions for vaster and wkpool, then traipse CRAN update, then build trip2.Dependency Pipeline Status
Critical Path (updated)
Completed: traipse geosphere -> geographiclib Migration
What changed
Five geosphere call sites replaced:
Internal vectorization helper (no new CRAN release of geographiclib needed):
This works because geodesic_inverse already accepts matrices and vectorizes through geodesic_inverse_cpp internally. The helper just smooths the 4-vector call signature.
track_intermediate migration details
README example migration
Bug found and fixed
track_angle() errored on length < 3 input (subscript out of bounds in xy[2:(n-1), ]). Added early return guard:
if (n < 3L) return(rep(NA_real_, n)). track_turn() already handled short input correctly.Behavioural note
Identical points: geographiclib::geodesic_inverse returns azi1=180 for zero-distance pairs. This matches geosphere::bearing behaviour (also returns 180), so no change in track_bearing output for stationary points.
Test Suite
228 tests across 12 contexts, zero failures.
Test files created:
test-geosphere-migration.R(106 tests) — three-section design:test-traipse-geosphere-equivalence.R(99 tests) — parallel comprehensive test filecapture-reference-values.R— one-shot script to dump geosphere reference values at 10 decimal places for trips0 id1 (20 pts), antimeridian track, polar track, cardinal bearings, and track_intermediate by distance and durationDiagnostic output (pre-swap, confirming numerical identity):
(Machine epsilon — confirms geosphere::bearing already uses Karney internally via PROJ)
Next Steps
1. traipse CRAN update (0.4.0 -> 0.5.0)
2. vaster CRAN submission
3. wkpool CRAN submission
4. trip2 build
Once traipse (updated), vaster, wkpool are all on CRAN:
Data model: grouped tibble with column role attributes (like tsibble's index/key). No S4, no sp, no bespoke spatial classes. "Spatial is not special."
Architecture: How the Packages Compose
Each package does one thing:
trip2 is the composition layer: "here's how to organize tracking data as a tibble, and here are convenience functions that compose the above."
Design Principles
From the original architecture review:
Segments as primitive: Trip data is inherently dual-view — vertex pool {x,y,t} and segment pairs with duration. wkpool provides this naturally. The segment view is just
lead()/lag()within groups.No bespoke classes: A trip is a grouped tibble. The constructor validates and tags column roles. All operations via dplyr. The TimeOrderedRecords S4 slot from trip v1 becomes a simple attribute.
traipse IS the engine:
group_by(id) |> mutate(speed = track_speed(x, y, time))replaces all of trip's metric/filter S4 methods.Thin wrappers: Each hypertidy package is a thin wrapper over a core algorithm (Karney for geodesics, PROJ for CRS, Bresenham for gridding). No heavy abstraction layers.
Related Packages
Beta Was this translation helpful? Give feedback.
All reactions