[gdal-dev] Global state for datum grid access?

Even Rouault even.rouault at spatialys.com
Thu Sep 14 05:30:48 PDT 2023


Edzer,

Le 14/09/2023 à 13:52, Edzer Pebesma a écrit :
> This came up here: https://github.com/r-spatial/sf/issues/2166
>
> It seems to me that GDAL queries PROJ's ability to access the network 
> for datum grids once, and remembers that. That means that applications 
> can't switch this on and off on demand and expect GDAL to follow. Is 
> this the case? If this is the case, is there a way applications can 
> ask GDAL what this state is?

The first time, per thread, GDAL uses PROJ it will inherit the network 
settings from PROJ when creating its per-thread PROJ context.

The current status can be queried with OSRGetPROJEnableNetwork(): 
https://gdal.org/api/ogr_srs_api.html#_CPPv423OSRGetPROJEnableNetworkv

and changed with OSRSetPROJEnableNetwork(): 
https://gdal.org/api/ogr_srs_api.html#_CPPv423OSRSetPROJEnableNetworki


I see that sf_proj_network() calls CPL_enable_network() 
(https://github.com/r-spatial/sf/blob/f36bd2f7273ace6d244e401b760291a3dc195c3c/src/proj.cpp#L193) 
which calls proj_context_set_enable_network() on the default PROJ 
context. If this is done before any GDAL use (or more exactly any use of 
PROJ by GDAL), then it is OK. But if it is called afterwards, GDAL will 
have created its own PROJ context, and later changes to the default PROJ 
context will not affect it anymore. Presumably sf_proj_network() or 
CPL_enable_network() should call OSRSetPROJEnableNetwork() as well if 
the intent if that this affects both pure-PROJ and PROJ-through-GDAL uses.

Even

-- 
http://www.spatialys.com
My software is free, but my time generally not.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20230914/f9c7a310/attachment.htm>


More information about the gdal-dev mailing list