From 18c3acbc4939679d959e31a3be9e068989e91a38 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Thu, 12 Jan 2023 17:27:21 +0100 Subject: [PATCH] proj.ini: do not set 'only_best_default' at all; and when set to on/off, disable related warnings --- data/proj.ini | 7 ++++--- src/4D_api.cpp | 2 +- src/ctx.cpp | 1 + src/filemanager.cpp | 2 ++ src/proj_internal.h | 1 + 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/data/proj.ini b/data/proj.ini index 9267cdf64b..252fa00301 100644 --- a/data/proj.ini +++ b/data/proj.ini @@ -16,13 +16,14 @@ cache_size_MB = 300 cache_ttl_sec = 86400 ; Can be set to on so that by default the lack of a known resource files needed -; for the best transformation PROJ would normally use causes an error. This -; default value itself is overriden by the PROJ_ONLY_BEST_DEFAULT environment +; for the best transformation PROJ would normally use causes an error, or off +; to accept missing resource files without errors or warnings. +; This default value itself is overriden by the PROJ_ONLY_BEST_DEFAULT environment ; variable if set, and then by the ONLY_BEST setting that can be ; passed to the proj_create_crs_to_crs() method, or with the --only-best ; option of the cs2cs program. ; (added in PROJ 9.2) -only_best_default = off +; only_best_default = on ; Filename of the Certificate Authority (CA) bundle. ; Can be overriden with the PROJ_CURL_CA_BUNDLE / CURL_CA_BUNDLE environment variable. diff --git a/src/4D_api.cpp b/src/4D_api.cpp index afcf1ce218..98030df50c 100644 --- a/src/4D_api.cpp +++ b/src/4D_api.cpp @@ -1942,7 +1942,7 @@ PJ *proj_create_crs_to_crs_from_pj (PJ_CONTEXT *ctx, const PJ *source_crs, cons double accuracy = -1; bool allowBallparkTransformations = true; bool forceOver = false; - bool warnIfBestTransformationNotAvailable = true; + bool warnIfBestTransformationNotAvailable = ctx->warnIfBestTransformationNotAvailableDefault; bool errorIfBestTransformationNotAvailable = ctx->errorIfBestTransformationNotAvailableDefault; for (auto iter = options; iter && iter[0]; ++iter) { const char *value; diff --git a/src/ctx.cpp b/src/ctx.cpp index fed66a1eac..78dcabe373 100644 --- a/src/ctx.cpp +++ b/src/ctx.cpp @@ -151,6 +151,7 @@ pj_ctx::pj_ctx(const pj_ctx& other) : last_errno(0), debug_level(other.debug_level), errorIfBestTransformationNotAvailableDefault(other.errorIfBestTransformationNotAvailableDefault), + warnIfBestTransformationNotAvailableDefault(other.warnIfBestTransformationNotAvailableDefault), logger(other.logger), logger_app_data(other.logger_app_data), cpp_context(other.cpp_context ? other.cpp_context->clone(this) : nullptr), diff --git a/src/filemanager.cpp b/src/filemanager.cpp index 11c2fa8062..9ee255dffe 100644 --- a/src/filemanager.cpp +++ b/src/filemanager.cpp @@ -1823,6 +1823,7 @@ void pj_load_ini(PJ_CONTEXT *ctx) { // from environment first const char *proj_only_best_default = getenv("PROJ_ONLY_BEST_DEFAULT"); if (proj_only_best_default && proj_only_best_default[0] != '\0') { + ctx->warnIfBestTransformationNotAvailableDefault = false; ctx->errorIfBestTransformationNotAvailableDefault = ci_equal(proj_only_best_default, "ON") || ci_equal(proj_only_best_default, "YES") || @@ -1890,6 +1891,7 @@ void pj_load_ini(PJ_CONTEXT *ctx) { ctx->ca_bundle_path = value; } else if (proj_only_best_default == nullptr && key == "only_best_default") { + ctx->warnIfBestTransformationNotAvailableDefault = false; ctx->errorIfBestTransformationNotAvailableDefault = ci_equal(value, "ON") || ci_equal(value, "YES") || diff --git a/src/proj_internal.h b/src/proj_internal.h index 43c67c5d60..203dca98e3 100644 --- a/src/proj_internal.h +++ b/src/proj_internal.h @@ -697,6 +697,7 @@ struct pj_ctx{ int last_errno = 0; int debug_level = PJ_LOG_ERROR; bool errorIfBestTransformationNotAvailableDefault = false; + bool warnIfBestTransformationNotAvailableDefault = true; void (*logger)(void *, int, const char *) = nullptr; void *logger_app_data = nullptr; struct projCppContext* cpp_context = nullptr; /* internal context for C++ code */