aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2019-11-12 12:33:47 +0000
committerEven Rouault <even.rouault@spatialys.com>2019-11-12 16:05:03 +0100
commitf970636daa814be26586bba1cfaa9fbb132da2df (patch)
treee2fe3a810b6f093ec2ead197b6e266e185ea112e /src
parent67ee557a665a9d502e08a4455b223edc2e6ab646 (diff)
downloadPROJ-f970636daa814be26586bba1cfaa9fbb132da2df.tar.gz
PROJ-f970636daa814be26586bba1cfaa9fbb132da2df.zip
Fix proj_assign_context()/pj_set_ctx() with pipelines and alternative coord operations
Fixes https://github.com/OSGeo/gdal/issues/1989 pj_set_ctx() only changes the context to the main object. It should also recurse down to the steps of the pipeline and the alternative coordinate operations hold in alternativeCoordinateOperations In the GDAL use case with multithreaded reprojection, and objects being transferred between thread, this would cause a failed coordinate transformation to affect an unrelated transformation of another thread...
Diffstat (limited to 'src')
-rw-r--r--src/ctx.cpp8
-rw-r--r--src/pipeline.cpp7
-rw-r--r--src/proj_internal.h2
3 files changed, 16 insertions, 1 deletions
diff --git a/src/ctx.cpp b/src/ctx.cpp
index 622a814d..bcb6e1cc 100644
--- a/src/ctx.cpp
+++ b/src/ctx.cpp
@@ -60,6 +60,14 @@ void pj_set_ctx( projPJ pj, projCtx ctx )
if (pj==nullptr)
return;
pj->ctx = ctx;
+ if( pj->is_pipeline )
+ {
+ pj_pipeline_assign_context_to_steps(pj, ctx);
+ }
+ for( const auto &alt: pj->alternativeCoordinateOperations )
+ {
+ pj_set_ctx(alt.pj, ctx);
+ }
}
/************************************************************************/
diff --git a/src/pipeline.cpp b/src/pipeline.cpp
index afa3b19a..76ffc98e 100644
--- a/src/pipeline.cpp
+++ b/src/pipeline.cpp
@@ -105,6 +105,7 @@ Thomas Knudsen, thokn@sdfe.dk, 2016-05-20
#include "geodesic.h"
#include "proj.h"
#include "proj_internal.h"
+#include "proj_experimental.h"
PROJ_HEAD(pipeline, "Transformation pipeline manager");
PROJ_HEAD(pop, "Retrieve coordinate value from pipeline stack");
@@ -136,7 +137,11 @@ static PJ_LPZ pipeline_reverse_3d (PJ_XYZ xyz, PJ *P);
static PJ_XY pipeline_forward (PJ_LP lp, PJ *P);
static PJ_LP pipeline_reverse (PJ_XY xy, PJ *P);
-
+void pj_pipeline_assign_context_to_steps( PJ* P, PJ_CONTEXT* ctx )
+{
+ for (int i = 1; i <= static_cast<struct pj_opaque*>(P->opaque)->steps; i++)
+ proj_assign_context(static_cast<struct pj_opaque*>(P->opaque)->pipeline[i], ctx);
+}
static PJ_COORD pipeline_forward_4d (PJ_COORD point, PJ *P) {
diff --git a/src/proj_internal.h b/src/proj_internal.h
index 4a126e98..77c4ba17 100644
--- a/src/proj_internal.h
+++ b/src/proj_internal.h
@@ -926,6 +926,8 @@ std::string pj_double_quote_string_param_if_needed(const std::string& str);
PJ *pj_create_internal (PJ_CONTEXT *ctx, const char *definition);
PJ *pj_create_argv_internal (PJ_CONTEXT *ctx, int argc, char **argv);
+void pj_pipeline_assign_context_to_steps( PJ* P, PJ_CONTEXT* ctx );
+
/* classic public API */
#include "proj_api.h"