Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: gdalraster
Title: Bindings to 'GDAL'
Version: 2.5.0.9012
Version: 2.5.0.9013
Authors@R: c(
person("Chris", "Toney", email = "jctoney@gmail.com",
role = c("aut", "cre"), comment = c(ORCID = "0000-0001-5734-6510")),
Expand Down
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# gdalraster 2.5.0.9012 (dev)
# gdalraster 2.5.0.9013 (dev)

* complete formatting console messages with **cli** (#942) (2026-04-02)

* `gdal_run()`: add arguments `close` and `quiet` (#941) (2026-04-02)

Expand Down
2 changes: 1 addition & 1 deletion R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -1938,7 +1938,7 @@ vsi_read_dir <- function(path, max_files = 0L, recursive = FALSE, all_files = FA
#' * `one.tif`
#' * `my_subdir/two.tif`
#' * `my_subdir/subsubdir/three.tif`
#'
#'
#' ```
#' vsi_glob("one.tif")
#' # returns ("one.tif")
Expand Down
17 changes: 9 additions & 8 deletions R/ogr_define.R
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,8 @@ ogr_def_field_domain <- function(domain_type, domain_name, description = NULL,
glob = "") {

if (gdal_version_num() <= gdal_compute_version(3, 3, 0)) {
warning("GDAL >= 3.3 is required for writing field domains",
call. = FALSE)
cli::cli_alert_warning(
"GDAL >= 3.3 is required for writing field domains.")
}

defn <- list()
Expand All @@ -394,8 +394,9 @@ ogr_def_field_domain <- function(domain_type, domain_name, description = NULL,
if (!(tolower(domain_type) %in%
c("coded", "range", "rangedatetime", "glob"))) {

cat("valid domain types are:\n")
cat(" \"Coded\", \"Range\", \"RangeDateTime\", \"GLOB\"\n")
cli::cli_alert(paste0("Valid domain types: {.str Coded}, ",
"{.str Range}, {.str RangeDateTime}, ",
"{.str GLOB}"))
stop("invalid 'domain_type'", call. = FALSE)
}
defn$type <- domain_type
Expand Down Expand Up @@ -441,8 +442,8 @@ ogr_def_field_domain <- function(domain_type, domain_name, description = NULL,
if (!(toupper(split_policy) %in%
c("DEFAULT_VALUE", "DUPLICATE", "GEOMETRY_RATIO"))) {

cat("valid split policies are:\n")
cat(" \"DEFAULT_VALUE\", \"DUPLICATE\", \"GEOMETRY_RATIO\"\n")
cli::cli_alert(paste0("Valid split policies: {.str DEFAULT_VALUE} ",
"{.str DUPLICATE}, {.str GEOMETRY_RATIO}"))
stop("invalid 'split_policy'", call. = FALSE)
}
defn$split_policy <- toupper(split_policy)
Expand All @@ -457,8 +458,8 @@ ogr_def_field_domain <- function(domain_type, domain_name, description = NULL,
if (!(toupper(merge_policy) %in%
c("DEFAULT_VALUE", "SUM", "GEOMETRY_WEIGHTED"))) {

cat("valid merge policies are:\n")
cat(" \"DEFAULT_VALUE\", \"SUM\", \"GEOMETRY_WEIGHTED\"\n")
cli::cli_alert(paste0("Valid merge policies: {.str DEFAULT_VALUE}, ",
"{.str SUM}, {.str GEOMETRY_WEIGHTED}"))
stop("invalid 'merge_policy'", call. = FALSE)
}
defn$merge_policy <- toupper(merge_policy)
Expand Down
4 changes: 2 additions & 2 deletions R/ogr_manage.R
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ ogr_ds_add_field_domain <- function(dsn, fld_dom_defn) {
if (ogr_ds_test_cap(dsn)$AddFieldDomain) {
return(.ogr_ds_add_field_domain(dsn, fld_dom_defn))
} else {
message("the dataset does not support AddFieldDomain")
cli::cli_alert_danger("dataset does not support AddFieldDomain")
return(FALSE)
}
}
Expand All @@ -554,7 +554,7 @@ ogr_ds_delete_field_domain <- function(dsn, domain_name) {
if (ogr_ds_test_cap(dsn)$DeleteFieldDomain) {
return(.ogr_ds_delete_field_domain(dsn, domain_name))
} else {
message("the dataset does not support DeleteFieldDomain")
cli::cli_alert_danger("dataset does not support DeleteFieldDomain")
return(FALSE)
}
}
Expand Down
9 changes: 5 additions & 4 deletions R/ogr_proc.R
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,11 @@ ogr_proc <- function(mode,

if (!ogr_ds_exists(out_dsn, with_update = TRUE)) {
if (ogr_ds_exists(out_dsn) && !overwrite) {
msg <- "'out_dsn' exists but cannot be updated.\n"
msg <- paste0(msg, "You may need to remove it first, ")
msg <- paste0(msg, "or use 'overwrite = TRUE'.")
stop(msg, call. = FALSE)
cli::cli_alert_danger(
paste0("{.arg out_dsn} exists but cannot be updated. You ",
"may need to remove it first, or use ",
"{.code overwrite = TRUE}."))
stop("cannot update the output data source", call. = FALSE)
}
}

Expand Down
9 changes: 5 additions & 4 deletions R/ogr_reproject.R
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,11 @@ ogr_reproject <- function(src_dsn, src_layer, out_dsn, out_srs,

if (!ogr_ds_exists(out_dsn, with_update = TRUE)) {
if (ogr_ds_exists(out_dsn) && !overwrite) {
msg <- "'out_dsn' exists but cannot be updated.\n"
msg <- paste0(msg, "You may need to remove it first, ")
msg <- paste0(msg, "or use 'overwrite = TRUE'.")
stop(msg, call. = FALSE)
cli::cli_alert_danger(
paste0("{.arg out_dsn} exists but cannot be updated. You ",
"may need to remove it first, or use ",
"{.code overwrite = TRUE}."))
stop("cannot update the output data source", call. = FALSE)
}
}

Expand Down
6 changes: 4 additions & 2 deletions R/s3_methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ print.OGRFeatureSet <- function(x, ...) {
#' @method plot OGRFeature
plot.OGRFeature <- function(x, xlab = "x", ylab = "y", main = "", ...) {
if (!requireNamespace("vctrs", quietly = TRUE))
cat("wk::wk_plot() requires suggested package 'vctrs'\n")
cli::cli_alert_warning(
"{.fn wk::wk_plot} requires suggested package {.pkg vctrs}")

geom_column <- NULL
if (length(attr(x, "gis")$geom_column) == 0)
Expand Down Expand Up @@ -175,7 +176,8 @@ plot.OGRFeature <- function(x, xlab = "x", ylab = "y", main = "", ...) {
#' @method plot OGRFeatureSet
plot.OGRFeatureSet <- function(x, xlab = "x", ylab = "y", main = "", ...) {
if (!requireNamespace("vctrs", quietly = TRUE))
cat("wk::wk_plot() requires suggested package 'vctrs'\n")
cli::cli_alert_warning(
"{.fn wk::wk_plot} requires suggested package {.pkg vctrs}")

if (length(attr(x, "gis")$geom_column) == 0)
stop("no geometry column")
Expand Down
8 changes: 6 additions & 2 deletions src/cmb_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

#include "rcpp_util.h"

using std::string_literals::operator""s;

CmbTable::CmbTable()
: CmbTable(1, Rcpp::CharacterVector::create()) {}

Expand Down Expand Up @@ -140,8 +142,10 @@ void CmbTable::show() const {
for (const auto& s : m_var_names) {
out += (" " + s);
}
Rcpp::Rcout << "C++ object of class CmbTable\n";
Rcpp::Rcout << " Columns: " << out.c_str() << "\n";
cli_text_("C++ object of class {.cls CmbTable}");
cli_ul_();
cli_li_("{.emph Columns}: "s + out);
cli_end_();
}

RCPP_MODULE(mod_cmb_table) {
Expand Down
17 changes: 11 additions & 6 deletions src/gdal_exp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@
#include "cmb_table.h"
#include "ogr_util.h"
#include "srs_api.h"
#include "rcpp_util.h"
#include "transform.h"

using std::string_literals::operator""s;

//' Get GDAL version
//'
//' `gdal_version()` returns a character vector of GDAL runtime version
Expand Down Expand Up @@ -1697,9 +1700,10 @@ Rcpp::DataFrame combine(const Rcpp::CharacterVector &src_files,
if (!quiet) {
pfnProgress(0, nullptr, nullptr);
if (nrasters == 1)
Rcpp::Rcout << "scanning raster...\n";
cli_alert_("scanning raster...");
else
Rcpp::Rcout << "combining " << nrasters << " rasters...\n";
cli_alert_("combining "s + std::to_string(nrasters) +
" rasters...");
}

for (int y = 0; y < nrows; ++y) {
Expand Down Expand Up @@ -2151,7 +2155,7 @@ Rcpp::LogicalVector isLineOfSightVisible(const GDALRaster* const &ds,

if (srsA != "") {
if (!quiet)
Rcpp::Rcout << "transforming 'ptsA'...\n";
cli_alert_("transforming {.arg ptsA}...");

if (srs_is_vertical(srsA) && zA_interp_dem_relative)
Rcpp::stop("CRS is vertical but Z values are not actual heights");
Expand All @@ -2161,7 +2165,7 @@ Rcpp::LogicalVector isLineOfSightVisible(const GDALRaster* const &ds,

if (srsB != "") {
if (!quiet)
Rcpp::Rcout << "transforming 'ptsB'...\n";
cli_alert_("transforming {.arg ptsB}...");

if (srs_is_vertical(srsB) && zB_interp_dem_relative)
Rcpp::stop("CRS is vertical but Z values are not actual heights");
Expand Down Expand Up @@ -2193,7 +2197,7 @@ Rcpp::LogicalVector isLineOfSightVisible(const GDALRaster* const &ds,
GDALProgressFunc pfnProgress = GDALTermProgressR;

if (!quiet) {
Rcpp::Rcout << "checking line-of-sight...\n";
cli_alert_("checking line-of-sight...");
pfnProgress(0, nullptr, nullptr);
}

Expand Down Expand Up @@ -3071,7 +3075,8 @@ bool warp(const Rcpp::List &src_datasets,
GDALRaster *ds = src_datasets[i];
GDALDatasetH hDS = ds->getGDALDatasetH_();
if (hDS == nullptr) {
Rcpp::Rcout << "error on source " << (i + 1) << "\n";
cli_alert_danger_(
"source index: "s + std::to_string(i + 1));
for (R_xlen_t j = 0; j < i; ++j)
GDALClose(src_hDS[j]);
Rcpp::stop("open source raster failed");
Expand Down
8 changes: 5 additions & 3 deletions src/gdal_mdim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
Copyright (c) 2023-2025 gdalraster authors
*/

#include <Rcpp.h>

#include <gdal.h>
#include <cpl_conv.h>
#include <gdal_utils.h>

#include <Rcpp.h>

#include <memory>
#include <string>
#include <vector>

#include "gdalraster.h"
#include "rcpp_util.h"


// Return a view of an MDArray as a "classic" GDALDataset (i.e., 2D)
Expand Down Expand Up @@ -262,7 +263,8 @@ std::string mdim_info(

std::string limit_str;
if (limit > 0 && !detailed) {
Rcpp::Rcout << "'limit' only taken into account if 'detailed = TRUE'\n";
cli_alert_warning_(
"{.arg limit} only taken into account if {.code detailed = TRUE}");
}
else if (limit > 0) {
limit_str = std::to_string(limit);
Expand Down
6 changes: 3 additions & 3 deletions src/gdal_vsi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ Rcpp::CharacterVector vsi_read_dir(const Rcpp::CharacterVector &path,
//' * `one.tif`
//' * `my_subdir/two.tif`
//' * `my_subdir/subsubdir/three.tif`
//'
//'
//' ```
//' vsi_glob("one.tif")
//' # returns ("one.tif")
Expand Down Expand Up @@ -336,7 +336,7 @@ Rcpp::CharacterVector vsi_glob(const Rcpp::CharacterVector &pattern,
#else
const std::string pattern_in =
Rcpp::as<std::string>(check_gdal_filename(pattern));

const CPLStringList aosNames(
VSIGlob(pattern_in.c_str(),
nullptr,
Expand Down Expand Up @@ -796,7 +796,7 @@ SEXP vsi_stat(const Rcpp::CharacterVector &filename,
return Rcpp::wrap(ret);
}

Rcpp::Rcout << "invalid value for 'info'\n";
cli_alert_danger_("invalid value for {.arg info}");
return R_NilValue;
}

Expand Down
4 changes: 2 additions & 2 deletions src/gdalraster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -793,8 +793,8 @@ Rcpp::NumericMatrix GDALRaster::pixel_extract(const Rcpp::RObject &xy,

for (R_xlen_t band_idx = 0; band_idx < num_bands; ++band_idx) {
if (!quiet) {
cli_alert_info_("extracting from band {.val "s +
std::to_string(bands_in[band_idx]) + "}");
cli_alert_info_("extracting from band "s +
std::to_string(bands_in[band_idx]));

pfnProgress(0, nullptr, nullptr);
}
Expand Down
Loading
Loading