[gdal-dev] gdal & WMS

Ming Chin mingchin.st at gmail.com
Thu Jun 17 08:41:31 PDT 2021


Hello GDAL devs,

I am a GDAL rookie, and I am trying to add WMS support to an existing GDAL
(2.2.4) implementation.

I saw in this example:

https://gis.stackexchange.com/questions/67416/using-gdal-to-connect-to-a-wfs

that its possible to provide OGRSFDriverRegistrar::Open(sURL,  FALSE );

with a url and use it to open an OGRDataSource.

And in other examples I see that OGRSFDriverRegistrar::Open() has been
deprecated and that GDALOpen() should be used instead.

So I did that, adding cURL to our GDAL build, and then in my
implementation, I provided GDALOpen() with a URL like this:

GDALDataset *pDataset = (GDALDataset*)::GDALOpen(sURL, GA_ReadOnly);
if( pDataset  )
{
    int nLayers =  pDataset->GetLayerCount();
    OGRLayer *pLayer =  pDataset->GetLayerByName(sLayerName);
}

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;

The above call returns nLayers = 0, and  pLayer=NULL

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.

What am I missing?  Why am I unable to retrieve useful data from the
dataset?

Ming
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20210617/c0d4da76/attachment.html>


More information about the gdal-dev mailing list