[gdal-dev] OSRSetPROJSearchPaths in multithreaded application

Even Rouault even.rouault at spatialys.com
Wed Jul 17 06:14:15 PDT 2019


On mercredi 17 juillet 2019 14:52:55 CEST Dirk Vanden Boer wrote:
> After migrating to gdal 3 I'm having problems performing coordinate
> transformations in a multi-threaded application.
> 
> My proj.db is in a nonstandard location so I call the
> OSRSetPROJSearchPaths once on the main thread before the call to
> GDALAllRegister()
> 
> I can do coordinate transformations on my main thread, but on worker
> threads I get the proj error "Cannot find proj.db".

Hum, this is supposed to work. I've just enhanced the following test to check that and it works:

https://github.com/OSGeo/gdal/blob/master/autotest/cpp/test_osr_set_proj_search_paths.cpp

> 
> Calling OSRSetPROJSearchPaths in each worker thread does not seem to
> work either.

You don't even need that. There's logic to handle that automagically.

To debug this, you could set a breakpoint to OSRGetProjTLSContext() and see if
it calls proj_context_set_search_paths() at least once per thread.

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list