aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2021-06-02 22:51:31 +0200
committerEven Rouault <even.rouault@spatialys.com>2021-06-03 11:29:16 +0200
commit9ce2d6fc0e1d7591d0d588a16ab6589910092cfc (patch)
treeb8646a32db80e86020b7fa2ecb397b837a2acf5a /src
parente0a1b88e828b28445a3e45ad0936f5480cfcd1ce (diff)
downloadPROJ-9ce2d6fc0e1d7591d0d588a16ab6589910092cfc.tar.gz
PROJ-9ce2d6fc0e1d7591d0d588a16ab6589910092cfc.zip
Make proj_context_set_autoclose_database() a no-op as it would defeat the purpose of the new database connection sharing
Diffstat (limited to 'src')
-rw-r--r--src/ctx.cpp11
-rw-r--r--src/iso19111/c_api.cpp91
-rw-r--r--src/proj_internal.h1
3 files changed, 8 insertions, 95 deletions
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);