Skip to content

Commit

Permalink
proj.ini: do not set 'only_best_default' at all; and when set to on/o…
Browse files Browse the repository at this point in the history
…ff, disable related warnings
  • Loading branch information
rouault committed Jan 12, 2023
1 parent e019046 commit 18c3acb
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
7 changes: 4 additions & 3 deletions data/proj.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/4D_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/ctx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 2 additions & 0 deletions src/filemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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") ||
Expand Down Expand Up @@ -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") ||
Expand Down
1 change: 1 addition & 0 deletions src/proj_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 18c3acb

Please sign in to comment.