|
2 | 2 |
|
3 | 3 | #' Parse Activity File (FIT, TCX, or GPX) |
4 | 4 | #' |
5 | | -#' Internal function to parse activity files from Strava export data. |
| 5 | +#' Parse activity files from Strava export data. |
6 | 6 | #' Supports FIT, TCX, and GPX formats (including .gz compressed files). |
7 | 7 | #' |
8 | 8 | #' @param file_path Path to the activity file (can be .fit, .tcx, .gpx, or .gz compressed) |
|
12 | 12 | #' heart_rate, power, cadence, speed (all optional depending on file content) |
13 | 13 | #' |
14 | 14 | #' @importFrom utils read.csv |
15 | | -#' @keywords internal |
| 15 | +#' @export |
16 | 16 | parse_activity_file <- function(file_path, export_dir = NULL) { |
17 | 17 |
|
18 | 18 | # Resolve full path |
@@ -72,12 +72,16 @@ parse_activity_file <- function(file_path, export_dir = NULL) { |
72 | 72 | #' @keywords internal |
73 | 73 | parse_fit_file <- function(file_path) { |
74 | 74 | if (!requireNamespace("FITfileR", quietly = TRUE)) { |
75 | | - warning("Package 'FITfileR' is required to parse FIT files. Please install it.") |
| 75 | + warning("Package 'FITfileR' is required to parse FIT files. Please install it from GitHub: remotes::install_github('grimbough/FITfileR')") |
76 | 76 | return(NULL) |
77 | 77 | } |
78 | 78 |
|
79 | | - fit_data <- FITfileR::readFitFile(file_path) |
80 | | - records <- FITfileR::records(fit_data) |
| 79 | + # Use getFromNamespace to avoid R CMD check warnings about undeclared imports |
| 80 | + readFitFile <- getFromNamespace("readFitFile", "FITfileR") |
| 81 | + records_fn <- getFromNamespace("records", "FITfileR") |
| 82 | + |
| 83 | + fit_data <- readFitFile(file_path) |
| 84 | + records <- records_fn(fit_data) |
81 | 85 |
|
82 | 86 | if (is.null(records) || nrow(records) == 0) { |
83 | 87 | return(NULL) |
|
0 commit comments