[Gdal-dev] Use of individual drivers

Frank Warmerdam warmerdam at pobox.com
Fri Nov 11 09:58:06 EST 2005


On 11/11/05, Kor de Jong <k.dejong at geo.uu.nl> wrote:
> This works, but I am looking for a way to use each GDAL driver individually.
> Each driver should correspond to one file format, like this:
>
> int driverId = ...; // GDAL file format driver id, could also be the name.
> GDALRasterDriver* driver = new GDALRasterDriver(driverId);
> Raster* raster = driver->open("dem.map");
>
> This way I can maintain a mapping of rasters and drivers used to read or write
> the data. Also GDAL doesn't need to search through its list of drivers each
> time new data is read. (As a hack I could store the id of the GDAL driver
> used to read the data the first time it is tried, but this conflicts with the
> overall design of my library in which GDALRasterDriver is just one of the
> drivers.)
>
> My first idea was to copy the few lines of code in the GDALOpen function in
> gdaldataset.cpp and use the GDAL drivers directly instead of calling GDALOpen
> for example. This could work if the procted poDriver member of GDALDataset
> was public or if my function, like GDALOpen, was declared a friend of
> GDALDataset. I guess for good reasons both will not happen so I wonder what
> my alternatives are.
>
> In short, is it possible to get around the high level GDAL functions and use
> the individual GDAL drivers directly? If not, does the design of GDAL allow
> it to be changed to allow such use?

Kor,

I can imagine a couple solutions.

1) I could implement a GDALOpenWithDriver() with an
   extra argument that is the driver that should be used (as
   opposed to scanling the GDALDriverManager list).

2) You could manipulate the GDALDriverManager ensuring
    that only the one driver at a time is registered.  That way
    only that driver would be used by GDALOpen().

If (2) is fine for you, then no core changes are required.  If not,
then I would be willing to implement option 1, which I have
occationally wished existed for other reasons.

Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent




More information about the Gdal-dev mailing list