<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hi,</p>
    <p>The WMS cache (which is used underneath by the WMTS driver)
      writes each tiles in a separate file. So if you use
      multi-threaded, as long as you read in parallel different
      GDALDataset* object on the WMTS filename, and read disjoint areas,
      that should be fine. There might be a slight risk of things going
      bad if you happened to read the same tile from different
      GDALDataset* object at the same time, as it could potentially read
      a partially written cached tile, or concurrently write the tile in
      the cache and corrupt it. The logic is in
      frmts/wms/gdalwmscache.cpp<br>
    </p>
    <p>Even<br>
    </p>
    <div class="moz-cite-prefix">Le 29/05/2024 à 10:14, Michał Kowalczuk
      via gdal-dev a écrit :<br>
    </div>
    <blockquote type="cite"
cite="mid:CAP+FqQByOka92rtC94P7+6yTLEK5aoSmcfPjxorHkx=AygPLoA@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="auto">Because this is not clear in documentation,
        especially in WMTS driver docs, my question is strictly about
        this issue to programmers who have already explored this topic.</div>
      <div dir="auto"><br>
      </div>
      <div dir="auto">Regards</div>
      <div dir="auto">Michal</div>
      <div><br>
        <div class="gmail_quote">
          <div dir="ltr" class="gmail_attr">W dniu śr., 29.05.2024 o
            10:04 Rahkonen Jukka <<a
              href="mailto:jukka.rahkonen@maanmittauslaitos.fi"
              moz-do-not-send="true" class="moz-txt-link-freetext">jukka.rahkonen@maanmittauslaitos.fi</a>>
            napisał(a):<br>
          </div>
          <blockquote class="gmail_quote"
style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div link="blue" vlink="purple" style="word-wrap:break-word"
              lang="FI">
              <div class="m_4834396856744026984WordSection1">
                <p class="MsoNormal"><span lang="EN-US">Hi,</span></p>
                <p class="MsoNormal"><span lang="EN-US"> </span></p>
                <p class="MsoNormal"><span lang="EN-US">No, I am not
                    sure because I do not program myself. Reading this
                    document
                    <a href="https://gdal.org/user/multithreading.html"
                      target="_blank" moz-do-not-send="true"
                      class="moz-txt-link-freetext">https://gdal.org/user/multithreading.html</a>
                    makes me feel that it is possible to do some things
                    in parallel, but the programmer must know how to do
                    it right.</span></p>
                <p class="MsoNormal"><span lang="EN-US"> </span></p>
                <p class="MsoNormal"><span lang="EN-US">-Jukka Rahkonen-</span></p>
                <p class="MsoNormal"><span lang="EN-US"> </span></p>
                <div
style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
                  <p class="MsoNormal"><b><span lang="EN-US">Lähettäjä:</span></b><span
                      lang="EN-US"> Javier Jimenez Shaw <<a
                        href="mailto:j1@jimenezshaw.com" target="_blank"
                        moz-do-not-send="true"
                        class="moz-txt-link-freetext">j1@jimenezshaw.com</a>>
                      <br>
                      <b>Lähetetty:</b> keskiviikko 29. toukokuuta 2024
                      10.41<br>
                      <b>Vastaanottaja:</b> Rahkonen Jukka <<a
href="mailto:jukka.rahkonen@maanmittauslaitos.fi" target="_blank"
                        moz-do-not-send="true"
                        class="moz-txt-link-freetext">jukka.rahkonen@maanmittauslaitos.fi</a>><br>
                      <b>Kopio:</b> Michał Kowalczuk <<a
                        href="mailto:michkowalczuk@gmail.com"
                        target="_blank" moz-do-not-send="true"
                        class="moz-txt-link-freetext">michkowalczuk@gmail.com</a>>;
                      <a href="mailto:gdal-dev@lists.osgeo.org"
                        target="_blank" moz-do-not-send="true"
                        class="moz-txt-link-freetext">gdal-dev@lists.osgeo.org</a><br>
                      <b>Aihe:</b> Re: [gdal-dev] GDAL WMTS get tiles no
                      documentation</span></p>
                </div>
              </div>
            </div>
            <div link="blue" vlink="purple" style="word-wrap:break-word"
              lang="FI">
              <div class="m_4834396856744026984WordSection1">
                <p class="MsoNormal"><span lang="EN-US"> </span></p>
                <div>
                  <div>
                    <p class="MsoNormal"><span lang="EN-US"> </span></p>
                  </div>
                  <p class="MsoNormal"><span lang="EN-US"> </span></p>
                  <div>
                    <div>
                      <p class="MsoNormal"><span lang="EN-US">On Wed, 29
                          May 2024 at 08:59, Rahkonen Jukka via gdal-dev
                          <</span><a
                          href="mailto:gdal-dev@lists.osgeo.org"
                          target="_blank" moz-do-not-send="true"><span
                            lang="EN-US">gdal-dev@lists.osgeo.org</span></a><span
                          lang="EN-US">> wrote:</span></p>
                    </div>
                    <blockquote
style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt">
                      <div>
                        <div>
                          <div>
                            <p class="MsoNormal"><span lang="EN-US">Hi,</span></p>
                            <p class="MsoNormal"><span lang="EN-US"> </span></p>
                            <p class="MsoNormal"><span lang="EN-US">When
                                you have a RasterBand  from the WMTS
                                data source, it is abstracted and you
                                can read the raster data just like from
                                any other data source and raster band
                              </span><a
href="https://gdal.org/tutorials/raster_api_tut.html#reading-raster-data"
                                target="_blank" moz-do-not-send="true"><span
                                  lang="EN-US">https://gdal.org/tutorials/raster_api_tut.html#reading-raster-data</span></a><span
                                lang="EN-US"> “There are a few ways to
                                read raster data, but the most common is
                                via the GDALRasterBand::RasterIO()
                                method. This method will automatically
                                take care of data type conversion,
                                up/down sampling and windowing.” GDAL
                                knows which tiles to read.</span></p>
                            <p class="MsoNormal"><span lang="EN-US"> </span></p>
                            <p class="MsoNormal"><span lang="EN-US">I do
                                not know if the WMTS driver can do
                                parallel tile downloads. If not, it is
                                possible to run many RasterIO() at the
                                same time, each reading data from a
                                different window like in this rasterio
                                document </span><a
href="https://rasterio.readthedocs.io/en/latest/topics/concurrency.html"
                                target="_blank" moz-do-not-send="true"><span
                                  lang="EN-US">https://rasterio.readthedocs.io/en/latest/topics/concurrency.html</span></a><span
                                lang="EN-US">.</span></p>
                          </div>
                        </div>
                      </div>
                    </blockquote>
                    <div>
                      <p class="MsoNormal"><span lang="EN-US"> </span></p>
                    </div>
                    <div>
                      <p class="MsoNormal"><span lang="EN-US">Jukka, are
                          you sure you can run several RasterIO in
                          parallel (on the same dataset)? in GDAL
                          GeoTIFF you cannot: the cache may be
                          corrupted. In that case I open several
                          datasets over the same file. I do not know
                          about WMTS.</span></p>
                    </div>
                    <div>
                      <p class="MsoNormal"><span lang="EN-US"> </span></p>
                    </div>
                    <blockquote
style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt">
                      <div>
                        <div>
                          <div>
                            <p class="MsoNormal"><span lang="EN-US"> </span></p>
                            <p class="MsoNormal"><span lang="EN-US">-Jukka
                                Rahkonen-</span></p>
                            <p class="MsoNormal"><span lang="EN-US"> </span></p>
                            <div
style="border:none;border-top:solid windowtext 1.0pt;padding:3.0pt 0cm 0cm 0cm;border-color:currentcolor currentcolor">
                              <p class="MsoNormal"><b><span lang="EN-US">Lähettäjä:</span></b><span
                                  lang="EN-US"> gdal-dev <</span><a
href="mailto:gdal-dev-bounces@lists.osgeo.org" target="_blank"
                                  moz-do-not-send="true"><span
                                    lang="EN-US">gdal-dev-bounces@lists.osgeo.org</span></a><span
                                  lang="EN-US">>
                                  <b>Puolesta </b>Michal Kowalczuk via
                                  gdal-dev<br>
                                  <b>Lähetetty:</b> keskiviikko 29.
                                  toukokuuta 2024 9.08<br>
                                  <b>Vastaanottaja:</b> </span><a
                                  href="mailto:gdal-dev@lists.osgeo.org"
                                  target="_blank" moz-do-not-send="true"><span
                                    lang="EN-US">gdal-dev@lists.osgeo.org</span></a><span
                                  lang="EN-US"><br>
                                  <b>Aihe:</b> [gdal-dev] GDAL WMTS get
                                  tiles no documentation</span></p>
                            </div>
                            <p class="MsoNormal"><span lang="EN-US"> </span></p>
                            <div>
                              <p class="MsoNormal"><span lang="EN-US">Hi
                                  GDAL fellows</span></p>
                              <div>
                                <p class="MsoNormal"><span lang="EN-US">This
                                    is my first post on this mailing
                                    list, so I'm asking for
                                    understanding.</span></p>
                              </div>
                              <div>
                                <p class="MsoNormal"><span lang="EN-US"> </span></p>
                              </div>
                              <div>
                                <p class="MsoNormal"><span lang="EN-US">As
                                    all we know the purpose of using
                                    WMTS over WMS, I'd like to implement
                                    parallel downloading tiles from
                                    service using C API.</span></p>
                              </div>
                              <div>
                                <p class="MsoNormal"><span lang="EN-US">In
                                    my opinion GDAL documentation (</span><a
href="https://gdal.org/drivers/raster/wmts.html" target="_blank"
                                    moz-do-not-send="true"><span
                                      lang="EN-US">https://gdal.org/drivers/raster/wmts.html</span></a><span
                                    lang="EN-US">) says nothing on this
                                    topic.</span></p>
                              </div>
                              <div>
                                <p class="MsoNormal"><span lang="EN-US">I
                                    can get capabilities from WMTS, I
                                    can open the selected subdataset but
                                    how to get tiles for given extent? I
                                    could not find any information how
                                    to do it, even in the GDAL tests on
                                    github.</span></p>
                              </div>
                              <div>
                                <p class="MsoNormal"><span lang="EN-US"> </span></p>
                              </div>
                              <div>
                                <p class="MsoNormal"><span lang="EN-US">I
                                    am kindly asking for tips. It also
                                    can be in python. How using pure
                                    GDAL API fetch tiles to dynamically
                                    complete the displayed map. This is
                                    my goal.</span></p>
                              </div>
                              <div>
                                <p class="MsoNormal"><span lang="EN-US"> </span></p>
                              </div>
                              <div>
                                <p class="MsoNormal"><span lang="EN-US">Thank
                                    you!</span></p>
                              </div>
                              <div>
                                <p class="MsoNormal"><span lang="EN-US">Michal</span></p>
                              </div>
                            </div>
                          </div>
                        </div>
                        <p class="MsoNormal"><span lang="EN-US">_______________________________________________<br>
                            gdal-dev mailing list<br>
                          </span><a
                            href="mailto:gdal-dev@lists.osgeo.org"
                            target="_blank" moz-do-not-send="true"><span
                              lang="EN-US">gdal-dev@lists.osgeo.org</span></a><span
                            lang="EN-US"><br>
                          </span><a
href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank"
                            moz-do-not-send="true"><span lang="EN-US">https://lists.osgeo.org/mailman/listinfo/gdal-dev</span></a><span
                            lang="EN-US"></span></p>
                      </div>
                    </blockquote>
                  </div>
                </div>
              </div>
            </div>
          </blockquote>
        </div>
      </div>
      <br>
      <fieldset class="moz-mime-attachment-header"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
gdal-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
    </blockquote>
    <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>