From 9a23a23ef20f6f5bd10e5dd4b16fa6c03ba40895 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 12 Nov 2019 13:33:47 +0100 Subject: 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... --- src/ctx.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/ctx.cpp') 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); + } } /************************************************************************/ -- cgit v1.2.3