[gdal-dev] gdal & WMS

Even Rouault even.rouault at spatialys.com
Thu Jun 17 08:47:08 PDT 2021


A OGRLayer is a *vector* layer, not a raster one. So you should rather 
look at the raster API: https://gdal.org/tutorials/raster_api_tut.html

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 


Le 17/06/2021 à 17:41, Ming Chin a écrit :
> 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 
> <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
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev

My software is free, but my time generally not.

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

More information about the gdal-dev mailing list