Skip to contents

Read-only reconciliation of background_layers.gpkg against the project's intent record. In manifest mode (a manifest exists or is supplied) the categories are:

extra (gpkg-not-manifest)

needs a disposition - remove, or add to the manifest. Never touched automatically.

missing (manifest-not-gpkg)

informational - added on the next rfp_project_update() execute run.

frozen

kept deliberately, never refreshed. A frozen layer missing from the gpkg is flagged loudly - it has no re-downloadable source.

In registry mode (no manifest) the gpkg is compared against the template's registry layers instead. Both modes exclude the rfp whitelist tables (rfp_tracking, parameters_*) and the legacy unprefixed AOI layer (#71) from flagging.

Usage

rfp_project_audit(
  path,
  manifest = NULL,
  template = NULL,
  dir_layers = NULL,
  file_gpkg = NULL,
  layout = NULL
)

Arguments

path

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

manifest

NULL (default), a path to a manifest CSV, or a manifest data frame. NULL auto-discovers rfp_manifest.csv at the project root and falls back to registry mode when absent. The mode in use is always printed - no silent switch.

template

Character. Template for registry mode. NULL (default) uses the template recorded in the project's rfp_project.json, falling back to "bcfishpass_mobile" for a project created before that was written. An explicit value always wins.

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 mode, extra, missing, frozen_present + frozen_absent (manifest mode only), whitelisted, aoi_codes, settings (the project-settings status from rfp_project_settings(), or NULL when it could not be read), and tracking (position-tracking state from rfp_qgs_tracking_get(), plus fields - which added fields the GeoPackage and the project each carry), preview (layers whose preview expression names a column their data does not have, NULL when the project has no single .qgs), subset (layers carrying a provider filter, whether the project's two datasource surfaces agree about it, and whether it double-quotes a token that is not a column - repair with rfp_qgs_subset_set()), dead (layers whose datasource points at a project-local artifact that is demonstrably absent - repair with rfp_qgs_layer_rm()), sunk (layers drawing below an opaque basemap), and themes (buried - visible theme entries inside a group the theme leaves unchecked, so they draw nothing; and dangling - group references naming no group in the tree. Repair both with rfp_qgs_theme_unbury()).

Examples

project <- file.path(tempdir(), "audit_example")
dir.create(project)
file.copy(
  system.file("testdata", "subset_fixture", "parent",
              "background_layers.gpkg", package = "rfp"),
  project
)
#> [1] TRUE
rfp_manifest_create(project)
#>  Wrote /tmp/RtmpfSNDuG/audit_example/rfp_manifest.csv
#>   bcdata: 1
#>   fwa: 0
#>   aws: 0
#>   osm: 0
#>   url: 0
#>   stac: 0
#>   frozen: 4
#>  4 layers landed as 'frozen' (not in the bcfishpass_mobile registry) - a curation placeholder. Edit the CSV to flip any that have a live download identifier.
result <- rfp_project_audit(project)
#> 
#> ── Audit: /tmp/RtmpfSNDuG/audit_example (background_layers.gpkg) ──
#> 
#>  AOI watershed groups: <none - whse_basemapping.fwa_watershed_groups_poly absent>
#>  Mode: manifest (/tmp/RtmpfSNDuG/audit_example/rfp_manifest.csv) - 5 layers | 4 gpkg layers
#> gpkg-not-manifest (assign disposition): none
#> manifest-not-gpkg (informational - added on next update execute):
#> - whse_basemapping.fwa_watershed_groups_poly
#> frozen (kept deliberately, never refreshed):
#> * lakes
#> * roads
#> * streams
#> * unused_sentinel
#>  whitelist present: none
#>  settings: no single project file - QGIS properties not checked
#> settings drift (fix with rfp_project_settings_apply()):
#> - Measure/Ellipsoid: not set, expected EPSG:7019
#> - Mergin/PhotoQuality: not set, expected 3
#> - Mergin/Snapping: not set, expected 0
#> - input-selective-sync: not set, expected true
#> - input-selective-sync-dir: not set, expected ignore_mobile
result$mode
#> [1] "manifest"
unlink(project, recursive = TRUE)