aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/source/usage/environmentvars.rst12
-rw-r--r--src/ctx.cpp9
-rw-r--r--src/iso19111/factory.cpp23
-rwxr-xr-xtest/cli/testprojinfo9
-rw-r--r--test/cli/testprojinfo_out.dist31
5 files changed, 78 insertions, 6 deletions
diff --git a/docs/source/usage/environmentvars.rst b/docs/source/usage/environmentvars.rst
index 0717a9fa..304b9276 100644
--- a/docs/source/usage/environmentvars.rst
+++ b/docs/source/usage/environmentvars.rst
@@ -51,6 +51,18 @@ done by setting the variable with no content::
:envvar:`PROJ_LIB` to allow for multiple versions of PROJ
resource files on your system without conflicting.
+
+.. envvar:: PROJ_AUX_DB
+
+ .. versionadded:: 8.1.0
+
+ To set the path to one or several auxiliary SQLite3 databases of structure
+ identical to the main ``proj.db`` database and that can contain additional
+ object (CRS, transformation, ...) definitions. If several paths are
+ provided, they must be separated by the colon (:) character on Unix, and
+ on Windows, by the semi-colon (;) character.
+
+
.. envvar:: PROJ_DEBUG
Set the debug level of PROJ. The default debug level is zero, which results
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;
diff --git a/test/cli/testprojinfo b/test/cli/testprojinfo
index adbebeec..20c14a8e 100755
--- a/test/cli/testprojinfo
+++ b/test/cli/testprojinfo
@@ -296,6 +296,15 @@ echo "Testing projinfo --dump-db-structure --output-id HOBU:XXXX EPSG:4326 | tai
$EXE --dump-db-structure --output-id HOBU:XXXX EPSG:4326 | tail -n 4 >>${OUT}
echo "" >>${OUT}
+echo "Testing PROJ_AUX_DB environment variable" >> ${OUT}
+rm -f tmp_projinfo_aux.db
+$EXE --dump-db-structure --output-id HOBU:XXXX EPSG:4326 | sqlite3 tmp_projinfo_aux.db
+export PROJ_AUX_DB=tmp_projinfo_aux.db
+$EXE HOBU:XXXX >>${OUT}
+unset PROJ_AUX_DB
+rm -f tmp_projinfo_aux.db
+echo "" >>${OUT}
+
# do 'diff' with distribution results
echo "diff ${OUT} with testprojinfo_out.dist"
diff -u ${OUT} ${TEST_CLI_DIR}/testprojinfo_out.dist
diff --git a/test/cli/testprojinfo_out.dist b/test/cli/testprojinfo_out.dist
index d4ee5774..8137b513 100644
--- a/test/cli/testprojinfo_out.dist
+++ b/test/cli/testprojinfo_out.dist
@@ -1559,3 +1559,34 @@ INSERT INTO metadata VALUES('DATABASE.LAYOUT.VERSION.MINOR',0);
INSERT INTO geodetic_crs VALUES('HOBU','XXXX','WGS 84','','geographic 2D','EPSG','6422','EPSG','6326',NULL,0);
INSERT INTO usage VALUES('HOBU','USAGE_GEODETIC_CRS_XXXX','geodetic_crs','HOBU','XXXX','EPSG','1262','EPSG','1183');
+Testing PROJ_AUX_DB environment variable
+PROJ.4 string:
++proj=longlat +datum=WGS84 +no_defs +type=crs
+
+WKT2:2019 string:
+GEOGCRS["WGS 84",
+ ENSEMBLE["World Geodetic System 1984 ensemble",
+ MEMBER["World Geodetic System 1984 (Transit)"],
+ MEMBER["World Geodetic System 1984 (G730)"],
+ MEMBER["World Geodetic System 1984 (G873)"],
+ MEMBER["World Geodetic System 1984 (G1150)"],
+ MEMBER["World Geodetic System 1984 (G1674)"],
+ MEMBER["World Geodetic System 1984 (G1762)"],
+ ELLIPSOID["WGS 84",6378137,298.257223563,
+ LENGTHUNIT["metre",1]],
+ ENSEMBLEACCURACY[2.0]],
+ PRIMEM["Greenwich",0,
+ ANGLEUNIT["degree",0.0174532925199433]],
+ CS[ellipsoidal,2],
+ AXIS["geodetic latitude (Lat)",north,
+ ORDER[1],
+ ANGLEUNIT["degree",0.0174532925199433]],
+ AXIS["geodetic longitude (Lon)",east,
+ ORDER[2],
+ ANGLEUNIT["degree",0.0174532925199433]],
+ USAGE[
+ SCOPE["Horizontal component of 3D system."],
+ AREA["World."],
+ BBOX[-90,-180,90,180]],
+ ID["HOBU","XXXX"]]
+