<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Edzer,<br>
    </p>
    <div class="moz-cite-prefix">Le 14/09/2023 à 13:52, Edzer Pebesma a
      écrit :<br>
    </div>
    <blockquote type="cite"
      cite="mid:d94fd6d1-3e50-a413-9199-a2a17c0f1e2d@uni-muenster.de">This
      came up here: <a class="moz-txt-link-freetext" href="https://github.com/r-spatial/sf/issues/2166">https://github.com/r-spatial/sf/issues/2166</a>
      <br>
      <br>
      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?
      <br>
    </blockquote>
    <p>The first time, per thread, GDAL uses PROJ it will inherit the
      network settings from PROJ when creating its per-thread PROJ
      context.</p>
    <p>The current status can be queried with OSRGetPROJEnableNetwork():
<a class="moz-txt-link-freetext" href="https://gdal.org/api/ogr_srs_api.html#_CPPv423OSRGetPROJEnableNetworkv">https://gdal.org/api/ogr_srs_api.html#_CPPv423OSRGetPROJEnableNetworkv</a></p>
    <p>and changed with <span class="highlighted">OSRSetPROJEnableNetwork():
<a class="moz-txt-link-freetext" href="https://gdal.org/api/ogr_srs_api.html#_CPPv423OSRSetPROJEnableNetworki">https://gdal.org/api/ogr_srs_api.html#_CPPv423OSRSetPROJEnableNetworki</a></span></p>
    <p><span class="highlighted"><br>
      </span></p>
    <p><span class="highlighted">I see that sf_proj_network() calls
        CPL_enable_network()
(<a class="moz-txt-link-freetext" href="https://github.com/r-spatial/sf/blob/f36bd2f7273ace6d244e401b760291a3dc195c3c/src/proj.cpp#L193">https://github.com/r-spatial/sf/blob/f36bd2f7273ace6d244e401b760291a3dc195c3c/src/proj.cpp#L193</a>)
        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 </span><span class="highlighted">OSRSetPROJEnableNetwork()
        as well if the intent if that this affects both pure-PROJ and
        PROJ-through-GDAL uses.</span><span class="highlighted"></span></p>
    Even
    <pre class="moz-signature" cols="72">-- 
<a class="moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
  </body>
</html>