aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/proj/internal/io_internal.hpp12
-rw-r--r--src/ctx.cpp11
-rw-r--r--src/iso19111/c_api.cpp91
-rw-r--r--src/proj_internal.h1
-rw-r--r--test/unit/test_c_api.cpp100
5 files changed, 8 insertions, 207 deletions
diff --git a/include/proj/internal/io_internal.hpp b/include/proj/internal/io_internal.hpp
index ccc3787e..a57ca5ce 100644
--- a/include/proj/internal/io_internal.hpp
+++ b/include/proj/internal/io_internal.hpp
@@ -173,7 +173,6 @@ struct projCppContext {
PJ_CONTEXT *ctx_ = nullptr;
std::string dbPath_{};
std::vector<std::string> auxDbPaths_{};
- bool autoCloseDb_ = false;
projCppContext(const projCppContext &) = delete;
projCppContext &operator=(const projCppContext &) = delete;
@@ -201,17 +200,6 @@ struct projCppContext {
return auxDbPaths_;
}
- void setAutoCloseDb(bool autoClose) {
- autoCloseDb_ = autoClose;
- autoCloseDbIfNeeded();
- }
- inline bool getAutoCloseDb() const { return autoCloseDb_; }
-
- // cppcheck-suppress functionStatic
- void closeDb();
-
- void autoCloseDbIfNeeded();
-
NS_PROJ::io::DatabaseContextNNPtr getDatabaseContext();
};
diff --git a/src/ctx.cpp b/src/ctx.cpp
index cc9df6c3..5ec10b9e 100644
--- a/src/ctx.cpp
+++ b/src/ctx.cpp
@@ -116,17 +116,6 @@ projCppContext* pj_ctx::get_cpp_context()
return cpp_context;
}
-/**************************************************************************/
-/* safeAutoCloseDbIfNeeded() */
-/**************************************************************************/
-
-void pj_ctx::safeAutoCloseDbIfNeeded()
-{
- if (cpp_context) {
- cpp_context->autoCloseDbIfNeeded();
- }
-}
-
/************************************************************************/
/* set_search_paths() */
/************************************************************************/
diff --git a/src/iso19111/c_api.cpp b/src/iso19111/c_api.cpp
index 2431f734..ace699e4 100644
--- a/src/iso19111/c_api.cpp
+++ b/src/iso19111/c_api.cpp
@@ -153,24 +153,11 @@ projCppContext::toVector(const char *const *auxDbPaths) {
projCppContext *projCppContext::clone(PJ_CONTEXT *ctx) const {
projCppContext *newContext =
new projCppContext(ctx, getDbPath().c_str(), getAuxDbPaths());
- newContext->setAutoCloseDb(getAutoCloseDb());
return newContext;
}
// ---------------------------------------------------------------------------
-void projCppContext::closeDb() { databaseContext_ = nullptr; }
-
-// ---------------------------------------------------------------------------
-
-void projCppContext::autoCloseDbIfNeeded() {
- if (getAutoCloseDb()) {
- closeDb();
- }
-}
-
-// ---------------------------------------------------------------------------
-
NS_PROJ::io::DatabaseContextNNPtr projCppContext::getDatabaseContext() {
if (databaseContext_) {
return NN_NO_CHECK(databaseContext_);
@@ -215,7 +202,6 @@ static PJ *pj_obj_create(PJ_CONTEXT *ctx, const IdentifiedObjectNNPtr &objIn) {
ctx->defer_grid_opening = false;
if (pj) {
pj->iso_obj = objIn;
- ctx->safeAutoCloseDbIfNeeded();
return pj;
}
} catch (const std::exception &) {
@@ -249,7 +235,6 @@ static PJ *pj_obj_create(PJ_CONTEXT *ctx, const IdentifiedObjectNNPtr &objIn) {
} catch (const std::exception &) {
}
}
- ctx->safeAutoCloseDbIfNeeded();
return pj;
}
//! @endcond
@@ -289,19 +274,19 @@ PJ_OBJ_LIST::~PJ_OBJ_LIST() = default;
// ---------------------------------------------------------------------------
-/** \brief Set if the database must be closed after each C API call where it
- * has been opened, and automatically re-opened when needed.
+/** \brief Starting with PROJ 8.1, this function does nothing.
*
- * The default value is FALSE, that is the database remains open until the
- * context is destroyed.
+ * If you want to take into account changes to the PROJ database, you need to
+ * re-create a new context.
*
- * @param ctx PROJ context, or NULL for default context
- * @param autoclose Boolean parameter
+ * @param ctx Ignored
+ * @param autoclose Ignored
* @since 6.2
+ * @deprecated Since 8.1
*/
void proj_context_set_autoclose_database(PJ_CONTEXT *ctx, int autoclose) {
- SANITIZE_CTX(ctx);
- ctx->get_cpp_context()->setAutoCloseDb(autoclose != FALSE);
+ (void)ctx;
+ (void)autoclose;
}
// ---------------------------------------------------------------------------
@@ -330,27 +315,22 @@ int proj_context_set_database_path(PJ_CONTEXT *ctx, const char *dbPath,
(void)options;
std::string osPrevDbPath;
std::vector<std::string> osPrevAuxDbPaths;
- bool autoCloseDb = false;
if (ctx->cpp_context) {
osPrevDbPath = ctx->cpp_context->getDbPath();
osPrevAuxDbPaths = ctx->cpp_context->getAuxDbPaths();
- autoCloseDb = ctx->cpp_context->getAutoCloseDb();
}
delete ctx->cpp_context;
ctx->cpp_context = nullptr;
try {
ctx->cpp_context = new projCppContext(
ctx, dbPath, projCppContext::toVector(auxDbPaths));
- ctx->cpp_context->setAutoCloseDb(autoCloseDb);
ctx->cpp_context->getDatabaseContext();
- ctx->safeAutoCloseDbIfNeeded();
return true;
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
delete ctx->cpp_context;
ctx->cpp_context =
new projCppContext(ctx, osPrevDbPath.c_str(), osPrevAuxDbPaths);
- ctx->cpp_context->setAutoCloseDb(autoCloseDb);
return false;
}
}
@@ -372,7 +352,6 @@ const char *proj_context_get_database_path(PJ_CONTEXT *ctx) {
// ctx->cpp_context
auto osPath(getDBcontext(ctx)->getPath());
ctx->get_cpp_context()->lastDbPath_ = osPath;
- ctx->safeAutoCloseDbIfNeeded();
return ctx->cpp_context->lastDbPath_.c_str();
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
@@ -404,11 +383,9 @@ const char *proj_context_get_database_metadata(PJ_CONTEXT *ctx,
// ctx->cpp_context
auto osVal(getDBcontext(ctx)->getMetadata(key));
if (osVal == nullptr) {
- ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
ctx->get_cpp_context()->lastDbMetadataItem_ = osVal;
- ctx->safeAutoCloseDbIfNeeded();
return ctx->cpp_context->lastDbMetadataItem_.c_str();
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
@@ -437,7 +414,6 @@ proj_context_get_database_structure(PJ_CONTEXT *ctx,
(void)options;
try {
auto ret = to_string_list(getDBcontext(ctx)->getDatabaseStructure());
- ctx->safeAutoCloseDbIfNeeded();
return ret;
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
@@ -574,7 +550,6 @@ PJ *proj_create(PJ_CONTEXT *ctx, const char *text) {
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
- ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
@@ -697,7 +672,6 @@ PJ *proj_create_from_wkt(PJ_CONTEXT *ctx, const char *wkt,
proj_log_error(ctx, __FUNCTION__, e.what());
}
}
- ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
@@ -762,7 +736,6 @@ PJ *proj_create_from_database(PJ_CONTEXT *ctx, const char *auth_name,
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
- ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
@@ -848,12 +821,10 @@ int proj_uom_get_info_from_database(PJ_CONTEXT *ctx, const char *auth_name,
if (out_category) {
*out_category = get_unit_category(obj->name(), obj->type());
}
- ctx->safeAutoCloseDbIfNeeded();
return true;
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
- ctx->safeAutoCloseDbIfNeeded();
return false;
}
@@ -898,7 +869,6 @@ int PROJ_DLL proj_grid_get_info_from_database(
ctx->get_cpp_context()->lastGridPackageName_,
ctx->get_cpp_context()->lastGridUrl_, direct_download,
open_license, available)) {
- ctx->safeAutoCloseDbIfNeeded();
return false;
}
@@ -916,12 +886,10 @@ int PROJ_DLL proj_grid_get_info_from_database(
if (out_available)
*out_available = available ? 1 : 0;
- ctx->safeAutoCloseDbIfNeeded();
return true;
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
- ctx->safeAutoCloseDbIfNeeded();
return false;
}
@@ -957,12 +925,10 @@ PJ_OBJ_LIST *proj_query_geodetic_crs_from_datum(PJ_CONTEXT *ctx,
for (const auto &obj : res) {
objects.push_back(obj);
}
- ctx->safeAutoCloseDbIfNeeded();
return new PJ_OBJ_LIST(std::move(objects));
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
- ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
@@ -1141,12 +1107,10 @@ PJ_OBJ_LIST *proj_create_from_name(PJ_CONTEXT *ctx, const char *auth_name,
for (const auto &obj : res) {
objects.push_back(obj);
}
- ctx->safeAutoCloseDbIfNeeded();
return new PJ_OBJ_LIST(std::move(objects));
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
- ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
@@ -1296,12 +1260,10 @@ PJ_OBJ_LIST *proj_get_non_deprecated(PJ_CONTEXT *ctx, const PJ *obj) {
for (const auto &resObj : res) {
objects.push_back(resObj);
}
- ctx->safeAutoCloseDbIfNeeded();
return new PJ_OBJ_LIST(std::move(objects));
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
- ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
@@ -1352,9 +1314,6 @@ static int proj_is_equivalent_to_internal(PJ_CONTEXT *ctx, const PJ *obj,
other->iso_obj.get(), cppCriterion,
ctx ? getDBcontextNoException(ctx, "proj_is_equivalent_to_with_ctx")
: nullptr);
- if (ctx) {
- ctx->safeAutoCloseDbIfNeeded();
- }
return res;
}
@@ -1587,16 +1546,13 @@ const char *proj_as_wkt(PJ_CONTEXT *ctx, const PJ *obj, PJ_WKT_TYPE type,
std::string msg("Unknown option :");
msg += *iter;
proj_log_error(ctx, __FUNCTION__, msg.c_str());
- ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
}
obj->lastWKT = obj->iso_obj->exportToWKT(formatter.get());
- ctx->safeAutoCloseDbIfNeeded();
return obj->lastWKT.c_str();
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
- ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
}
@@ -1683,11 +1639,9 @@ const char *proj_as_proj_string(PJ_CONTEXT *ctx, const PJ *obj,
}
}
obj->lastPROJString = exportable->exportToPROJString(formatter.get());
- ctx->safeAutoCloseDbIfNeeded();
return obj->lastPROJString.c_str();
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
- ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
}
@@ -2089,7 +2043,6 @@ PJ *proj_crs_create_bound_crs_to_WGS84(PJ_CONTEXT *ctx, const PJ *crs,
std::string msg("Unknown option :");
msg += *iter;
proj_log_error(ctx, __FUNCTION__, msg.c_str());
- ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
}
@@ -2097,7 +2050,6 @@ PJ *proj_crs_create_bound_crs_to_WGS84(PJ_CONTEXT *ctx, const PJ *crs,
dbContext, allowIntermediateCRS));
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
- ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
}
@@ -2154,7 +2106,6 @@ PJ *proj_crs_create_bound_vertical_crs(PJ_CONTEXT *ctx, const PJ *vert_crs,
BoundCRS::create(nnCRS, nnHubCRS, transformation));
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
- ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
}
@@ -2585,14 +2536,12 @@ PJ_OBJ_LIST *proj_identify(PJ_CONTEXT *ctx, const PJ *obj,
*out_confidence = confidenceTemp;
confidenceTemp = nullptr;
}
- ctx->safeAutoCloseDbIfNeeded();
return ret.release();
} catch (const std::exception &e) {
delete[] confidenceTemp;
proj_log_error(ctx, __FUNCTION__, e.what());
}
}
- ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
@@ -2617,12 +2566,10 @@ PROJ_STRING_LIST proj_get_authorities_from_database(PJ_CONTEXT *ctx) {
SANITIZE_CTX(ctx);
try {
auto ret = to_string_list(getDBcontext(ctx)->getAuthorities());
- ctx->safeAutoCloseDbIfNeeded();
return ret;
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
- ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
@@ -2662,13 +2609,11 @@ PROJ_STRING_LIST proj_get_codes_from_database(PJ_CONTEXT *ctx,
}
auto ret = to_string_list(
factory->getAuthorityCodes(typeInternal, allow_deprecated != 0));
- ctx->safeAutoCloseDbIfNeeded();
return ret;
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
- ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
@@ -2708,7 +2653,6 @@ PROJ_CELESTIAL_BODY_INFO **proj_get_celestial_body_list_from_database(
ret[i] = nullptr;
if (out_result_count)
*out_result_count = i;
- ctx->safeAutoCloseDbIfNeeded();
return ret;
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
@@ -2719,7 +2663,6 @@ PROJ_CELESTIAL_BODY_INFO **proj_get_celestial_body_list_from_database(
if (out_result_count)
*out_result_count = 0;
}
- ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
@@ -2937,7 +2880,6 @@ proj_get_crs_info_list_from_database(PJ_CONTEXT *ctx, const char *auth_name,
ret[i] = nullptr;
if (out_result_count)
*out_result_count = i;
- ctx->safeAutoCloseDbIfNeeded();
return ret;
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
@@ -2948,7 +2890,6 @@ proj_get_crs_info_list_from_database(PJ_CONTEXT *ctx, const char *auth_name,
if (out_result_count)
*out_result_count = 0;
}
- ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
@@ -3030,7 +2971,6 @@ PROJ_UNIT_INFO **proj_get_units_from_database(PJ_CONTEXT *ctx,
ret[i] = nullptr;
if (out_result_count)
*out_result_count = i;
- ctx->safeAutoCloseDbIfNeeded();
return ret;
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
@@ -3041,7 +2981,6 @@ PROJ_UNIT_INFO **proj_get_units_from_database(PJ_CONTEXT *ctx,
if (out_result_count)
*out_result_count = 0;
}
- ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
@@ -3335,7 +3274,6 @@ PJ *proj_create_geographic_crs(PJ_CONTEXT *ctx, const char *crs_name,
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
- ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
@@ -3382,7 +3320,6 @@ PJ *proj_create_geographic_crs_from_datum(PJ_CONTEXT *ctx, const char *crs_name,
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
- ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
@@ -4029,7 +3966,6 @@ PJ *proj_crs_promote_to_3D(PJ_CONTEXT *ctx, const char *crs_3D_name,
dbContext));
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
- ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
}
@@ -4116,7 +4052,6 @@ PJ *proj_crs_create_projected_3D_crs_from_2D(PJ_CONTEXT *ctx,
cpp_projected_2D_crs->derivingConversion(), newCS));
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
- ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
} else {
@@ -4129,7 +4064,6 @@ PJ *proj_crs_create_projected_3D_crs_from_2D(PJ_CONTEXT *ctx,
dbContext));
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
- ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
}
@@ -4175,7 +4109,6 @@ PJ *proj_crs_demote_to_2D(PJ_CONTEXT *ctx, const char *crs_2D_name,
dbContext));
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
- ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
}
@@ -7187,10 +7120,8 @@ int proj_coordoperation_is_instantiable(PJ_CONTEXT *ctx,
dbContext, proj_context_is_network_enabled(ctx) != FALSE)
? 1
: 0;
- ctx->safeAutoCloseDbIfNeeded();
return ret;
} catch (const std::exception &) {
- ctx->safeAutoCloseDbIfNeeded();
return 0;
}
}
@@ -7525,11 +7456,9 @@ int proj_coordoperation_get_grid_used_count(PJ_CONTEXT *ctx,
coordoperation->gridsNeeded.emplace_back(gridDesc);
}
}
- ctx->safeAutoCloseDbIfNeeded();
return static_cast<int>(coordoperation->gridsNeeded.size());
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
- ctx->safeAutoCloseDbIfNeeded();
return 0;
}
}
@@ -7657,7 +7586,6 @@ proj_create_operation_factory_context(PJ_CONTEXT *ctx, const char *authority) {
std::string(authority ? authority : ""));
auto operationContext =
CoordinateOperationContext::create(authFactory, nullptr, 0.0);
- ctx->safeAutoCloseDbIfNeeded();
return new PJ_OPERATION_FACTORY_CONTEXT(
std::move(operationContext));
} else {
@@ -7669,7 +7597,6 @@ proj_create_operation_factory_context(PJ_CONTEXT *ctx, const char *authority) {
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
- ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
@@ -9195,12 +9122,10 @@ proj_get_geoid_models_from_database(PJ_CONTEXT *ctx, const char *auth_name,
const std::string codeStr(code);
auto factory = AuthorityFactory::create(getDBcontext(ctx), auth_name);
auto geoidModels = factory->getGeoidModels(codeStr);
- ctx->safeAutoCloseDbIfNeeded();
return to_string_list(std::move(geoidModels));
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
- ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
diff --git a/src/proj_internal.h b/src/proj_internal.h
index 28c084d6..582bb3c5 100644
--- a/src/proj_internal.h
+++ b/src/proj_internal.h
@@ -719,7 +719,6 @@ struct pj_ctx{
pj_ctx& operator= (const pj_ctx&) = delete;
projCppContext* get_cpp_context();
- void safeAutoCloseDbIfNeeded();
void set_search_paths(const std::vector<std::string>& search_paths_in);
void set_ca_bundle_path(const std::string& ca_bundle_path_in);
diff --git a/test/unit/test_c_api.cpp b/test/unit/test_c_api.cpp
index 99d91e3b..d9e731a7 100644
--- a/test/unit/test_c_api.cpp
+++ b/test/unit/test_c_api.cpp
@@ -4287,106 +4287,6 @@ TEST_F(CApi, proj_as_projjson) {
// ---------------------------------------------------------------------------
-struct Fixture_proj_context_set_autoclose_database : public CApi {
- void test(bool autoclose) {
- proj_context_set_autoclose_database(m_ctxt, autoclose);
-
- auto c_path = proj_context_get_database_path(m_ctxt);
- ASSERT_TRUE(c_path != nullptr);
- std::string path(c_path);
-
- FILE *f = fopen(path.c_str(), "rb");
- ASSERT_NE(f, nullptr);
- fseek(f, 0, SEEK_END);
- auto length = ftell(f);
- std::string content;
- content.resize(static_cast<size_t>(length));
- fseek(f, 0, SEEK_SET);
- auto read_bytes = fread(&content[0], 1, content.size(), f);
- ASSERT_EQ(read_bytes, content.size());
- fclose(f);
- const char *tempdir = getenv("TEMP");
- if (!tempdir) {
- tempdir = getenv("TMP");
- }
- if (!tempdir) {
- tempdir = "/tmp";
- }
- std::string tmp_filename(
- std::string(tempdir) +
- "/test_proj_context_set_autoclose_database.db");
- f = fopen(tmp_filename.c_str(), "wb");
- if (!f) {
- std::cerr << "Cannot create " << tmp_filename << std::endl;
- return;
- }
- fwrite(content.data(), 1, content.size(), f);
- fclose(f);
-
- {
- sqlite3 *db = nullptr;
- sqlite3_open_v2(tmp_filename.c_str(), &db, SQLITE_OPEN_READWRITE,
- nullptr);
- ASSERT_NE(db, nullptr);
- ASSERT_TRUE(sqlite3_exec(db,
- "UPDATE geodetic_crs SET name = 'foo' "
- "WHERE auth_name = 'EPSG' and code = "
- "'4326'",
- nullptr, nullptr, nullptr) == SQLITE_OK);
- sqlite3_close(db);
- }
-
- EXPECT_TRUE(proj_context_set_database_path(m_ctxt, tmp_filename.c_str(),
- nullptr, nullptr));
- {
- auto crs = proj_create_from_database(
- m_ctxt, "EPSG", "4326", PJ_CATEGORY_CRS, false, nullptr);
- ObjectKeeper keeper(crs);
- ASSERT_NE(crs, nullptr);
- EXPECT_EQ(proj_get_name(crs), std::string("foo"));
- }
-
- {
- sqlite3 *db = nullptr;
- sqlite3_open_v2(tmp_filename.c_str(), &db, SQLITE_OPEN_READWRITE,
- nullptr);
- ASSERT_NE(db, nullptr);
- ASSERT_TRUE(sqlite3_exec(db,
- "UPDATE geodetic_crs SET name = 'bar' "
- "WHERE auth_name = 'EPSG' and code = "
- "'4326'",
- nullptr, nullptr, nullptr) == SQLITE_OK);
- sqlite3_close(db);
- }
- {
- auto crs = proj_create_from_database(
- m_ctxt, "EPSG", "4326", PJ_CATEGORY_CRS, false, nullptr);
- ObjectKeeper keeper(crs);
- ASSERT_NE(crs, nullptr);
- EXPECT_EQ(proj_get_name(crs),
- std::string(autoclose ? "bar" : "foo"));
- }
-
- if (!autoclose) {
- proj_context_destroy(m_ctxt);
- m_ctxt = nullptr;
- }
- std::remove(tmp_filename.c_str());
- }
-};
-
-TEST_F(Fixture_proj_context_set_autoclose_database,
- proj_context_set_autoclose_database_true) {
- test(true);
-}
-
-TEST_F(Fixture_proj_context_set_autoclose_database,
- proj_context_set_autoclose_database_false) {
- test(false);
-}
-
-// ---------------------------------------------------------------------------
-
TEST_F(CApi, proj_context_copy_from_default) {
auto c_path = proj_context_get_database_path(m_ctxt);
ASSERT_TRUE(c_path != nullptr);