Get osmconf.ini file in synch with GDAL - #304
Conversation
Merge branch 'master' into synch_osmconf_ini # Conflicts: # .github/workflows/R-CMD-check.yaml
Merge branch 'master' into synch_osmconf_ini # Conflicts: # .github/workflows/R-CMD-check.yaml
skip ci
There was a problem hiding this comment.
Pull request overview
Updates how osmextract locates/uses osmconf.ini so the default GDAL OSM CONFIG stays aligned with the one shipped by the local GDAL/sf installation, with a package-bundled fallback; documentation and CI are updated accordingly.
Changes:
- Add
get_default_osmconf_ini()(exported) and updateoe_vectortranslate()to use it as the defaultCONFIGsource. - Replace hard-coded
osmconf.iniline indices with heuristics to locate per-layerattributes=rows. - Update vignette/docs/NEWS and expand CI matrix to include macOS.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
vignettes/osmextract.Rmd |
Updates vignette text/examples to reflect new default osmconf.ini discovery. |
R/vectortranslate.R |
Implements default osmconf.ini discovery + new parsing helpers; wires into oe_vectortranslate(). |
R/get-key-values.R |
Switches default-field detection to use the newly detected default osmconf.ini. |
NEWS.md |
Adds release note about synced CONFIG handling. |
NAMESPACE |
Exports get_default_osmconf_ini(). |
man/oe_vectortranslate.Rd |
Regenerates docs for updated oe_vectortranslate() behavior. |
man/get_default_osmconf_ini.Rd |
Adds generated man page for new exported function. |
.github/workflows/R-CMD-check.yaml |
Expands checks to a macOS job and adjusts matrix strategy. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # I cannot simply use grep(value = TRUE) since that matches the whole row, not | ||
| # only the part which I'm interested in. I need regexpr + regmatch | ||
| m = regexpr( | ||
| pattern = "(?<=^attributes=)\\S*", | ||
| text = file, | ||
| perl = TRUE | ||
| ) | ||
| keys <- regmatches(x = file, m = m) | ||
| # The output of regmatches is a (character vector) which includes the matched | ||
| # substrings. It has a syntax like | ||
| # [1] a,b,c,d | ||
| # [2] a,d,e,f | ||
| # [3] b,f,g | ||
| # ... | ||
| # I need to split such sequence of keys using "," as a delimiter. | ||
| keys <- strsplit(keys, ",") | ||
| # I assume there are 5 layers specified according to the following order: | ||
| stopifnot(length(keys) == 5L) | ||
| stopifnot(layer %in% c("points", "lines", "multipolygons", "multilinestrings", "other_relations")) |
There was a problem hiding this comment.
get_fields_default() currently uses regexpr() + regmatches() on the full file vector. For non-matching lines regmatches() returns empty strings, so keys <- strsplit(keys, ',') produces a list as long as file (not 5), making stopifnot(length(keys) == 5L) fail and breaking oe_vectortranslate() whenever extra_tags is used. Filter to only the matching attributes= lines (e.g., via grep('^attributes=', ..., value=TRUE) and sub('^attributes=', '', ...)) before splitting, or subset by m != -1L before calling regmatches()/strsplit().
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/ropensci/osmextract/sessions/9e85765d-d47f-467d-9b44-46ce0ed06b6c Co-authored-by: agila5 <22221146+agila5@users.noreply.github.com>
Agent-Logs-Url: https://github.com/ropensci/osmextract/sessions/adfe9c4c-65e4-4918-a5b5-7d715bcce65f Co-authored-by: agila5 <22221146+agila5@users.noreply.github.com>
Fixes #261