Skip to contents

Selects layers via one of three mutually-exclusive selectors (themes, groups, layers) and writes a child project directory containing a trimmed .qgs plus table-trimmed copies of each referenced .gpkg. In-tree raster sidecars are copied verbatim; externally-rooted (..-rooted) datasource refs are skipped with a warning. Optionally adds empty form GPKGs via rfp_form_create().

Usage

rfp_project_subset(
  parent,
  themes = NULL,
  groups = NULL,
  layers = NULL,
  forms = NULL,
  path_out,
  dry_run = FALSE
)

Arguments

parent

Character. Path to the parent project directory. Must contain exactly one .qgs file.

themes

Character vector of theme (visibility-preset) names to keep. Mutually exclusive with groups / layers.

groups

Character vector of layer-tree group names to keep (descendants are included recursively). Mutually exclusive.

layers

Character vector of layer names (from <layername>) to keep. Mutually exclusive.

forms

Character vector of form types to add to the child (e.g. c("pscis", "fiss_site")). Each becomes a new form_<type>.gpkg via rfp_form_create(). NULL skips.

path_out

Character. Path to write the child directory to. Must not exist, or must be empty.

dry_run

Logical. If TRUE, return the manifest without writing anything to path_out. Default FALSE.

Value

A tibble with one row per file that would be written: path_rel (relative to path_out), sha256_file (sha256 of file bytes – best-effort), sha256_content (sha256 of structurally- normalised content; load-bearing for cron idempotency), and size_bytes.

Details

For the multi-theme themes = c("A", "B") case, the kept layer set is the union of layers referenced by each theme's preset, and both themes are preserved in the child .qgs so a downstream consumer (e.g. QWC2) can switch between them at runtime.

Returns a manifest tibble suitable for the daily-cron skip-push check: sha256_content is content-deterministic for the same input (same parent + same selector -> same hashes), even though file-level bytes (sha256_file) may shift slightly across runs because SQLite VACUUM is not byte-deterministic. Use sha256_content to decide whether to push.

Examples

parent <- system.file(
  "testdata", "subset_fixture", "parent", package = "rfp"
)
out <- file.path(tempdir(), "child_themea")
rfp_project_subset(parent, themes = "ThemeA", path_out = out)
#>  Wrote child project: /tmp/RtmptVQqyP/child_themea (2 files)
fs::dir_ls(out)
#> /tmp/RtmptVQqyP/child_themea/background_layers.gpkg
#> /tmp/RtmptVQqyP/child_themea/parent.qgs