<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Ming,</p>
<p>A OGRLayer is a *vector* layer, not a raster one. So you should
rather look at the raster API:
<a class="moz-txt-link-freetext" href="https://gdal.org/tutorials/raster_api_tut.html">https://gdal.org/tutorials/raster_api_tut.html</a></p>
<p>Depending on the kind of URL you provide to GDAL, you may get
directly a workable dataset, or just a placeholder that links to
real datasets with the subdataset (which can be seen as a king of
raster layer) mechanism, using
GDALDataset::GetMetadata("SUBDATASETS") to get the list of
subdatasets, and then pass to GDALOpen() the value of one of the
SUBDATASET_xx_NAME item<br>
</p>
<p>Even<br>
</p>
<div class="moz-cite-prefix">Le 17/06/2021 à 17:41, Ming Chin a
écrit :<br>
</div>
<blockquote type="cite"
cite="mid:CANuOYTHhpat6Ds26CXtO2i7u5ytDuixXKBioN6VJ2MO+K_hgQw@mail.gmail.com">
<div dir="ltr"><br>
<div>Hello GDAL devs,</div>
<div><br>
</div>
<div>I am a GDAL rookie, and I am trying to add WMS support to
an existing GDAL (2.2.4) implementation.</div>
<div><br>
</div>
<div>I saw in this example:</div>
<div><br>
</div>
<div><a
href="https://gis.stackexchange.com/questions/67416/using-gdal-to-connect-to-a-wfs"
moz-do-not-send="true">https://gis.stackexchange.com/questions/67416/using-gdal-to-connect-to-a-wfs</a></div>
<div><br>
</div>
<div>that its possible to provide <span>OGRSFDriverRegistrar::</span><span
class="gmail-hljs-built_in">Open(sURL, </span><span> FALSE
);</span></div>
<div><span><br>
</span></div>
<div><span>with a url and use it to open an OGRDataSource.</span></div>
<div><span><br>
</span></div>
<div>And in other examples I see that <span>OGRSFDriverRegistrar::</span><span
class="gmail-hljs-built_in">Open() has been deprecated and
that GDALOpen() should be used instead.</span></div>
<div><span class="gmail-hljs-built_in"><br>
</span></div>
<div><span class="gmail-hljs-built_in">So I did that, adding
cURL to our GDAL build, and then in my implementation, I
provided GDALOpen() with a URL like this:</span></div>
<div><span class="gmail-hljs-built_in"><br>
</span></div>
<div><span class="gmail-hljs-built_in">GDALDataset *pDataset
= (GDALDataset*)::GDALOpen(sURL, GA_ReadOnly);<br>
</span></div>
<div><span class="gmail-hljs-built_in">if( pDataset )</span></div>
<div><span class="gmail-hljs-built_in">{</span></div>
<div><span class="gmail-hljs-built_in"> int nLayers =
pDataset->GetLayerCount();</span></div>
<div><span class="gmail-hljs-built_in"> OGRLayer *pLayer =
pDataset->GetLayerByName(sLayerName);</span></div>
<div><span class="gmail-hljs-built_in">}</span></div>
<div><span class="gmail-hljs-built_in"><br>
</span></div>
<div><span class="gmail-hljs-built_in">This seems to partially
work, in the sense that the
GDALOpen function returns a non-NULL pointer to a
GDALDataset, but when I try to call the member functions of
the resulting GDALDataset, everything seems to return zeros
or nulls;</span></div>
<div><span class="gmail-hljs-built_in"><br>
</span></div>
<div>The above call returns nLayers = 0, and
pLayer=NULL</div>
<div><br>
</div>
<div>but if I feed the same sURL into my web browser (Chrome),
the browser receives a properly formatted xml file that
clearly has <Layer>(s) defined in it.</div>
<div><br>
</div>
<div>What am I missing? Why am I unable to retrieve useful data
from the dataset?</div>
<div><br>
</div>
<div>Ming</div>
<div><br>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></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>