Skip to contents

Drops attribute columns not listed in the project's column keep-list sidecar (rfp_manifest_columns.csv, columns source_layer,column). Keep-list semantics: listed columns are kept (fid + geometry always kept implicitly); everything else is dropped. Fail-closed by design - new fat columns arriving upstream don't reach field devices until deliberately added to the sidecar (rtj#178).

Usage

rfp_project_slim(
  path,
  sidecar = NULL,
  dry_run = TRUE,
  path_hold = NULL,
  dir_layers = NULL,
  file_gpkg = NULL,
  layout = NULL
)

Arguments

path

Character. Path to the project directory containing background_layers.gpkg.

sidecar

NULL (default), a path to a sidecar CSV, or a data frame with columns source_layer,column. NULL reads rfp_manifest_columns.csv at the project root.

dry_run

Logical. Default TRUE - print the plan and exit.

path_hold

Character. Root directory for the pre-slim backup. Default NULL uses a hold/ directory NEXT TO the project (never inside it).

dir_layers

Character. Directory holding one GeoPackage per layer. NULL (default) resolves getOption("rfp.dir_layers").

file_gpkg

Character. Single-GeoPackage file name for projects that have not been split. NULL (default) resolves getOption("rfp.file_gpkg").

layout

Character. "split", "monolith", or NULL (default) to detect from the project directory.

Value

Invisibly, a list with plan (kept columns per layer to slim) and office (office-companion columns per layer).

Details

Dropped columns are NOT discarded: they're written with join keys (fid, plus segmented_stream_id / aggregated_crossings_id when present) to an attribute-only table in ignore_mobile/background_layers_office.gpkg (rtj#180). Writing the office companion requires selective sync configured in mergin-config.json (input-selective-sync: true, input-selective-sync-dir: "ignore_mobile") - enforced fail-closed on execute, or the office gpkg (exactly the bytes this tool exists to keep off devices) would sync to the field.

Note: refresh re-fattens - the source passes re-download all columns, so slim runs after every refresh of a slimmed layer until column selection moves to download time (#12 Phase 3).

DRY-RUN by default; on execute the gpkg is backed up to path_hold, each layer is rewritten in place (two-hop ogr2ogr via a temp gpkg with -preserve_fid on both hops so the office rejoin stays valid), feature counts are verified, and the file is VACUUMed. Push stays manual, as ever.

Examples

if (FALSE) { # \dontrun{
# Review the plan, then execute
rfp_project_slim("~/Projects/gis/sern_peace_fwcp_2023")
rfp_project_slim("~/Projects/gis/sern_peace_fwcp_2023", dry_run = FALSE)
} # }