<div dir="ltr">Hi, thank you for your replies!<br>As I'm still a newbie especially with WMTS. I need to take a step back to the basics. Let's forget about multithreading for now.<div><ul><li>I'm in the stage that I can open a dataset using WMTS service path from data provider</li><li>I can list subdatasets and open the selected layer as a new dataset using path from <b>SUBDATASET_id_NAME</b>.</li><li>This dataset reports large height and width values, which is obvious.</li><li>The first question is how to read any fragment from this dataset using <b>GDALDatasetRasterIO</b>.<br>Is there a similar way to <b>SpatialFIlter </b>from vector layers?<br>I see in the docs there is a <b><DataWindow></b> tag for a local service descriptions which defines extents of the data. Does it mean that for each map extent change I need to create a new local XML file and open a new dataset to read demanded bbox?<br>Is this the only way for doing it?</li><li>From other site I noticed that QGIS downloads tiles separately? But how it knows which row/col and zoom should be used in GET request? Does it use GDAL for WMTS reading at all?<br><img src="cid:ii_lwuo6shc1" alt="image.png" width="562" height="79"></li></ul>I will be grateful for any tip and trucks for a newbie ;-)</div><div><br></div><div>Regards,</div><div>Michal  </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">śr., 29 maj 2024 o 12:41 Even Rouault <<a href="mailto:even.rouault@spatialys.com">even.rouault@spatialys.com</a>> napisał(a):<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>

  
    
  
  <div>
    <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>Le 29/05/2024 à 10:14, Michał Kowalczuk
      via gdal-dev a écrit :<br>
    </div>
    <blockquote type="cite">
      
      <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" target="_blank">jukka.rahkonen@maanmittauslaitos.fi</a>>
            napisał(a):<br>
          </div>
          <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
            <div style="overflow-wrap: break-word;" lang="FI">
              <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">No, I am not
                    sure because I do not program myself. Reading this
                    document
                    <a href="https://gdal.org/user/multithreading.html" target="_blank">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-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(225,225,225);padding:3pt 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">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">jukka.rahkonen@maanmittauslaitos.fi</a>><br>
                      <b>Kopio:</b> Michał Kowalczuk <<a href="mailto:michkowalczuk@gmail.com" target="_blank">michkowalczuk@gmail.com</a>>;
                      <a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">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 style="overflow-wrap: break-word;" lang="FI">
              <div>
                <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"><span lang="EN-US">gdal-dev@lists.osgeo.org</span></a><span lang="EN-US">> wrote:</span></p>
                    </div>
                    <blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin:5pt 0cm 5pt 4.8pt">
                      <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"><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"><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-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin:5pt 0cm 5pt 4.8pt">
                      <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-right:none currentcolor;border-bottom:none currentcolor;border-left:none currentcolor;border-top:1pt solid currentcolor;padding:3pt 0cm 0cm">
                              <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"><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"><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"><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"><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"><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></fieldset>
      <pre>_______________________________________________
gdal-dev mailing list
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a>
<a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
    </blockquote>
    <pre cols="72">-- 
<a href="http://www.spatialys.com" target="_blank">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
  </div>

</blockquote></div>