aboutsummaryrefslogtreecommitdiff
path: root/src/iso19111/factory.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2020-01-13 22:30:59 +0100
committerEven Rouault <even.rouault@spatialys.com>2020-01-14 23:33:16 +0100
commit9cb40a8322f4ccbf8305daf368308783969d1c94 (patch)
tree1702a990752eae1c3f41ab67e9eba2843adb3f2a /src/iso19111/factory.cpp
parent034238e5014ae965a7dbd1e2bf26f7227196e987 (diff)
downloadPROJ-9cb40a8322f4ccbf8305daf368308783969d1c94.tar.gz
PROJ-9cb40a8322f4ccbf8305daf368308783969d1c94.zip
Add proj_context_set_fileapi() and proj_context_set_sqlite3_vfs_name() (fixes #866)
Diffstat (limited to 'src/iso19111/factory.cpp')
-rw-r--r--src/iso19111/factory.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/iso19111/factory.cpp b/src/iso19111/factory.cpp
index 7fb248c6..6345ecf4 100644
--- a/src/iso19111/factory.cpp
+++ b/src/iso19111/factory.cpp
@@ -491,7 +491,10 @@ void DatabaseContext::Private::cache(const std::string &code,
void DatabaseContext::Private::open(const std::string &databasePath,
PJ_CONTEXT *ctx) {
- setPjCtxt(ctx ? ctx : pj_get_default_ctx());
+ if (!ctx) {
+ ctx = pj_get_default_ctx();
+ }
+ setPjCtxt(ctx);
std::string path(databasePath);
if (path.empty()) {
path.resize(2048);
@@ -503,23 +506,26 @@ void DatabaseContext::Private::open(const std::string &databasePath,
}
}
+ std::string vfsName;
#ifdef ENABLE_CUSTOM_LOCKLESS_VFS
- vfs_ = SQLite3VFS::create(false, true, true);
- if (vfs_ == nullptr ||
- sqlite3_open_v2(path.c_str(), &sqlite_handle_,
- SQLITE_OPEN_READONLY | SQLITE_OPEN_NOMUTEX,
- vfs_->name()) != SQLITE_OK ||
- !sqlite_handle_) {
- throw FactoryException("Open of " + path + " failed");
+ if (ctx->custom_sqlite3_vfs_name.empty()) {
+ vfs_ = SQLite3VFS::create(false, true, true);
+ if (vfs_ == nullptr) {
+ throw FactoryException("Open of " + path + " failed");
+ }
+ vfsName = vfs_->name();
+ } else
+#endif
+ {
+ vfsName = ctx->custom_sqlite3_vfs_name;
}
-#else
if (sqlite3_open_v2(path.c_str(), &sqlite_handle_,
SQLITE_OPEN_READONLY | SQLITE_OPEN_NOMUTEX,
- nullptr) != SQLITE_OK ||
+ vfsName.empty() ? nullptr : vfsName.c_str()) !=
+ SQLITE_OK ||
!sqlite_handle_) {
throw FactoryException("Open of " + path + " failed");
}
-#endif
databasePath_ = path;
registerFunctions();