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/iso19111/factory.cpp | |
| 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/iso19111/factory.cpp')
| -rw-r--r-- | src/iso19111/factory.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
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; |
