
Apply rfp's Project Settings to a Project
Source:R/rfp_project_settings.R
rfp_project_settings_apply.RdWrites the settings in rfp_project_settings() into a project's .qgs
project properties and its mergin-config.json, then reports what changed.
Surgical and idempotent: only the named keys are touched, and a project that
already matches is left byte-for-byte alone.
Arguments
- path
Character. Path to the project directory.
- settings
A settings data frame, or
NULL(default) forrfp_project_settings(). Supply a subset to apply part of the convention - e.g.rfp_project_settings("mergin_config").- backup
Logical. Copy the
.qgsto<name>.qgs.bakbefore writing. DefaultTRUE. No backup is taken when nothing needs writing.
Value
Invisibly, a data frame of every setting with its status before the
run (ok, drift, absent) - so the return value describes what was
found, and the messages describe what was done.
Details
Use it to bring an existing project up to convention.
rfp_project_create() runs it on every new project, so a project made by rfp
cannot start wrong, and rfp_project_audit() reports drift without changing
anything.
What it will not do
It refuses a project below QGIS 4.0. QGIS 4.0 moved project properties
from element tags to nested <properties>, and rfp writes the newer encoding
only (#68). Reading stays tolerant of both, so rfp_project_audit() still
reports on a 3.x project - it just cannot repair one.
It writes only the keys the lookup names. Everything else in the properties block - WMS service configuration, labelling engine settings, Mergin's per-field photo naming - is left as found, whether or not rfp knows what it is.
The ellipsoid is not a blind backfill
Changing Measure/Ellipsoid changes every measured length and area in the
project. On a project that has been collecting data, decide it deliberately
and record what the value was before, rather than sweeping the fleet.
See also
rfp_project_settings() for the settings themselves and the
evidence behind each.
Other project:
rfp_project_settings(),
rfp_project_subset()
Examples
# A copy of a shipped template stands in for a project
project <- file.path(tempdir(), "settings_example")
dir.create(project)
file.copy(
system.file("templates", "bcfishpass_mobile.qgs", package = "rfp"),
file.path(project, "settings_example.qgs")
)
#> [1] TRUE
# The template captures photos at original size - 11 MB each in the field
before <- rfp_project_settings_apply(project, backup = FALSE)
#>
#> ── Settings: /tmp/RtmpfSNDuG/settings_example ──
#>
#> ✔ Mergin/PhotoQuality = 3 (was 0)
#> ✔ mergin-config.json: input-selective-sync = true
#> ✔ mergin-config.json: input-selective-sync-dir = ignore_mobile
#> ℹ ignore_mobile/ is now held back from field devices.
before[before$key == "Mergin/PhotoQuality", c("key", "current_value", "status")]
#> # A tibble: 1 × 3
#> key current_value status
#> <chr> <chr> <chr>
#> 1 Mergin/PhotoQuality 0 drift
# Running it again finds nothing to do
rfp_project_settings_apply(project, backup = FALSE)
#>
#> ── Settings: /tmp/RtmpfSNDuG/settings_example ──
#>
#> ℹ settings_example.qgs: 3 settings already correct.
#> ℹ mergin-config.json: 2 settings already correct.
unlink(project, recursive = TRUE)