A project stores its background layers either as one GeoPackage per layer
under background_layers/ or as a single background_layers.gpkg - see
rfp-layout. This is the single place that resolution happens, and it is
exported so a consumer outside rfp reads a project the way rfp does instead
of hardcoding one of the two shapes.
Arguments
- path
Character. Project directory.
- dir_layers
Character. Directory holding per-layer GeoPackages.
NULL(default) resolvesgetOption("rfp.dir_layers").- file_gpkg
Character. Single-GeoPackage file name.
NULL(default) resolvesgetOption("rfp.file_gpkg").- layout
Character.
"split","monolith", orNULL(default) to detect from disk. An explicit value skips detection entirely, which is what project creation needs - nothing exists yet to detect.- fn_layer_file
Function mapping a layer name to its file name under the split layout.
NULL(default) resolvesgetOption("rfp.fn_layer_file").
Value
A list - the layout spec - with kind ("split"/"monolith"),
path, dir_layers, file_gpkg, dir (layers directory, split), gpkg
(single file, monolith) and fn_layer_file. Pass it to
rfp_layout_layers() and rfp_layout_layer_path().
Details
Three things a reimplementation gets wrong, which is why this is shared
rather than copied. Every name resolves argument, then session option, then
package default. With layout = NULL the layout is read from disk, and a
project holding both warns and resolves to the directory rather than
silently picking one - the mid-migration case. And fn_layer_file is a
function, so <schema>.<table>.gpkg stays a convention rather than a rule.
See also
rfp-layout for what the two layouts are and why.
Other manifest:
rfp-layout,
rfp_layout_layer_path(),
rfp_layout_layers(),
rfp_manifest_create(),
rfp_manifest_read(),
rfp_manifest_types(),
rfp_project_audit(),
rfp_project_slim(),
rfp_project_split(),
rfp_project_update()
Examples
project <- file.path(tempdir(), "layout_example")
dir.create(project)
# Nothing on disk falls back to the historical single-GeoPackage layout, so
# a caller keeps producing its existing "no GeoPackage here" error.
rfp_layout(project)$kind
#> [1] "monolith"
dir.create(file.path(project, "background_layers"))
spec <- rfp_layout(project)
spec$kind
#> [1] "split"
spec$dir
#> /tmp/RtmpfSNDuG/layout_example/background_layers
unlink(project, recursive = TRUE)
