diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2021-03-15 15:37:44 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2021-03-15 16:16:32 +0100 |
| commit | 72f4f49bf3a2f95e4c2f4571205aa0925f20449a (patch) | |
| tree | 409d2ed5356c2f70c4ca2414f9197ad1b63d0f8d /src | |
| parent | eda2311513a67d274d67f5ae8fb3042d78fe3b96 (diff) | |
| download | PROJ-72f4f49bf3a2f95e4c2f4571205aa0925f20449a.tar.gz PROJ-72f4f49bf3a2f95e4c2f4571205aa0925f20449a.zip | |
Add support for PROJ_AUX_DB environment variable to set the path to one or several auxiliary DBs
Diffstat (limited to 'src')
| -rw-r--r-- | src/ctx.cpp | 9 | ||||
| -rw-r--r-- | src/iso19111/factory.cpp | 23 |
2 files changed, 26 insertions, 6 deletions
diff --git a/src/ctx.cpp b/src/ctx.cpp index 097633ae..cc9df6c3 100644 --- a/src/ctx.cpp +++ b/src/ctx.cpp @@ -91,13 +91,16 @@ pj_ctx pj_ctx::createDefault() ctx.logger = pj_stderr_logger; NS_PROJ::FileManager::fillDefaultNetworkInterface(&ctx); - if( getenv("PROJ_DEBUG") != nullptr ) + const char* projDebug = getenv("PROJ_DEBUG"); + if( projDebug != nullptr ) { - if( atoi(getenv("PROJ_DEBUG")) >= -PJ_LOG_TRACE ) - ctx.debug_level = atoi(getenv("PROJ_DEBUG")); + const int debugLevel = atoi(projDebug); + if( debugLevel >= -PJ_LOG_TRACE ) + ctx.debug_level = debugLevel; else ctx.debug_level = PJ_LOG_TRACE; } + return ctx; } diff --git a/src/iso19111/factory.cpp b/src/iso19111/factory.cpp index af9736e6..421cdb88 100644 --- a/src/iso19111/factory.cpp +++ b/src/iso19111/factory.cpp @@ -2482,6 +2482,11 @@ DatabaseContext::DatabaseContext() : d(internal::make_unique<Private>()) {} * string for the default rules to locate the default proj.db * @param auxiliaryDatabasePaths Path and filename of auxiliary databases. * Might be empty. + * Starting with PROJ 8.1, if this parameter is an empty array, + * the PROJ_AUX_DB environment variable will be used, if set. + * It must contain one or several paths. If several paths are + * provided, they must be separated by the colon (:) character on Unix, and + * on Windows, by the semi-colon (;) character. * @param ctx Context used for file search. * @throw FactoryException */ @@ -2493,9 +2498,21 @@ DatabaseContext::create(const std::string &databasePath, auto dbCtxPrivate = dbCtx->getPrivate(); dbCtxPrivate->open(databasePath, ctx); dbCtxPrivate->checkDatabaseLayout(databasePath, std::string()); - if (!auxiliaryDatabasePaths.empty()) { - dbCtxPrivate->attachExtraDatabases(auxiliaryDatabasePaths); - dbCtxPrivate->auxiliaryDatabasePaths_ = auxiliaryDatabasePaths; + auto auxDbs(auxiliaryDatabasePaths); + if (auxDbs.empty()) { + const char *auxDbStr = getenv("PROJ_AUX_DB"); + if (auxDbStr) { +#ifdef _WIN32 + const char *delim = ";"; +#else + const char *delim = ":"; +#endif + auxDbs = split(auxDbStr, delim); + } + } + if (!auxDbs.empty()) { + dbCtxPrivate->attachExtraDatabases(auxDbs); + dbCtxPrivate->auxiliaryDatabasePaths_ = auxDbs; } dbCtxPrivate->self_ = dbCtx.as_nullable(); return dbCtx; |
