aboutsummaryrefslogtreecommitdiff
path: root/src/4D_api.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2019-08-19 20:57:07 +0200
committerEven Rouault <even.rouault@spatialys.com>2019-08-20 13:26:54 +0200
commit15d6475b8caeb169fd2c060076738db75fc527b3 (patch)
treec50d03ac81b1e10e0d4356234757126a708e9ac1 /src/4D_api.cpp
parent2c9c015a6529548f5a5d448c78bc9b565d751590 (diff)
downloadPROJ-15d6475b8caeb169fd2c060076738db75fc527b3.tar.gz
PROJ-15d6475b8caeb169fd2c060076738db75fc527b3.zip
C API: add proj_context_set_autoclose_database() to automatically close database (fixes #1565)
Diffstat (limited to 'src/4D_api.cpp')
-rw-r--r--src/4D_api.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/4D_api.cpp b/src/4D_api.cpp
index 9f445d88..07ccfd91 100644
--- a/src/4D_api.cpp
+++ b/src/4D_api.cpp
@@ -231,13 +231,19 @@ similarly, but prefers the 2D resp. 3D interfaces if available.
// with the input coordinate, then goes through again the list, and
// use the first operation that does not require grids.
i = 0;
+ NS_PROJ::io::DatabaseContextPtr dbContext;
+ try
+ {
+ if( P->ctx->cpp_context ) {
+ dbContext = P->ctx->cpp_context->getDatabaseContext().as_nullable();
+ }
+ }
+ catch( const std::exception& ) {}
for( const auto &alt: P->alternativeCoordinateOperations ) {
auto coordOperation = dynamic_cast<
NS_PROJ::operation::CoordinateOperation*>(alt.pj->iso_obj.get());
if( coordOperation ) {
- if( coordOperation->gridsNeeded(P->ctx->cpp_context ?
- P->ctx->cpp_context->databaseContext.as_nullable() :
- nullptr).empty() ) {
+ if( coordOperation->gridsNeeded(dbContext).empty() ) {
if( P->iCurCoordOp != i ) {
std::string msg("Using coordinate operation ");
msg += alt.name;