working on local version - #2
Conversation
There was a problem hiding this comment.
If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.
Once extra usage is available, comment @claude review on this pull request, or push a new commit, to trigger a review.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Critical export, indexing, compatibility, and cache-build issues remain unresolved.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 6
Open (7)
Regenerate NAMESPACE to export new public functions · New Build and validate the GADM index during local setup · New Support declared R versions in gvs_cache_dir · New Force SQLite dialect for window-function index queries · New Preserve terra streaming handles across write operations · New Exclude terra extract IDs when selecting raster values · New Normalize NULL sources to the documented centroid default · New
What changed in this PR
Adds an offline GVS workflow using cached GADM data, centroid calculations, raster indexing, and historical validation.
Changes:
- Adds local cache, build, status, and removal utilities.
- Implements offline coordinate validation and centroid lookups.
- Adds tests and supporting spatial dependencies.
| File | Summary and findings |
|---|---|
tests/testthat/test-local-gvs.R |
Adds tests for local validation and historical behavior. |
R/GVS_local.R |
Adds offline validation helpers. Critical (3 votes): exports are missing from NAMESPACE. Moderate (1 vote each): historical cache artifacts are not built; antipodal distances can produce invalid centroid results. |
R/local_build.R |
Builds GADM and centroid data. Critical (3 votes): does not build or verify the required index. Moderate (1 vote): historical data artifacts are missing from the build lifecycle. |
R/local_cache.R |
Adds cache management APIs. Critical (3 votes): R_user_dir() is incompatible with the declared R versions. Moderate (3 votes): sources = NULL does not select the documented default. Moderate (1 vote): index artifacts are not removed during cleanup. |
R/local_index.R |
Adds raster index construction. Critical (3 votes): raster extraction selects the ID column instead of the cell value. Critical (1 vote each): SQLite window SQL is not explicitly selected; terra streaming return values are discarded. |
DESCRIPTION |
Adds supporting spatial and local-validation dependencies. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| #' @param tolerance_years Tolerance either side of a historical version's dates | ||
| #' when \code{date} is given. | ||
| #' @return A data.frame, one row per input row. | ||
| #' @export |
| if (needs_geometry) { | ||
| gvs_build_centroids(gpkg, gadm_layer, dir = dir, quiet = quiet) |
| gvs_cache_dir <- function(create = FALSE) { | ||
| dir <- getOption( | ||
| "GVS.cache_dir", | ||
| getOption("GNRS.cache_dir", tools::R_user_dir("GNRS", which = "cache")) |
| blank <- function(col) sprintf("(%s IS NULL OR %s IN ('', 'NA'))", col, col) | ||
| key_sql <- sprintf("CASE WHEN NOT %s THEN GID_2 WHEN NOT %s THEN GID_1 ELSE GID_0 END", | ||
| blank("GID_2"), blank("GID_1")) | ||
| unit_sql <- sprintf("DENSE_RANK() OVER (ORDER BY %s)", key_sql) |
| b <- terra::writeStart(tmpl, edges_tif, overwrite = TRUE, | ||
| wopt = list(datatype = "INT1U", names = "edge", | ||
| gdal = c("COMPRESS=DEFLATE", "TILED=YES", "BIGTIFF=YES"))) |
| unit[ok] <- as.integer(terra::extract(ru, xy)[, 1]) | ||
| unit[ok & unit %in% 0L] <- NA_integer_ | ||
| edge[ok] <- as.integer(terra::extract(re, xy)[, 1]) %in% 1L |
| GVS_local_remove <- function(dir = gvs_cache_dir(), sources = "centroids", | ||
| shared = FALSE, ask = interactive()) { |


No description provided.