[gdal-dev] Multiple extensions in GDAL_DMD_EXTENSION ?

Etienne Tourigny etourigny.dev at gmail.com
Wed Feb 20 06:30:21 PST 2013


On Tue, Feb 19, 2013 at 12:59 PM, Frank Warmerdam <warmerdam at pobox.com> wrote:
> On Tue, Feb 19, 2013 at 9:39 AM, Etienne Tourigny
> <etourigny.dev at gmail.com> wrote:
>> It would be nice to be able to specify many extensions in a
>> comma-separated list such as "nc,cdf,nc4". It can probably be done
>> (metadata is just a string), but isn't standard.
>>
>> The Gdal driver tutorial states:
>> GDAL_DMD_EXTENSION: The extension used for files of this type. If more
>> than one pick the primary extension, or none at all. (optional)
>>
>> It could be beneficial to extend this definition for multiple
>> extensions separated by comma.
>
> Etienne,
>
> The challenge is to do this without breaking lots of applications that
> expect it to be a single extension.  If we were to pursue this, I'd
> almost prefer to add GDAL_DMD_EXTENSION_LIST as a list of extensions
> that relate to this driver, and GDAL_DMD_EXTENSION would be the
> primary or preferred extension.
>
> But I'm still not all that keen.  I see the GDAL_DMD_EXTENSION as
> existing primarily so that applications can prepare a reasonable
> default filename when creating a file.  For this having a list of
> extensions is not helpful.
>
> People *usually* want a list of extensions so they can automatically
> categorize the format of files on disk or to filter to only show
> extensions they think GDAL supports.  I find this practice abhorrent!
>  GDAL is based on the idea that file formats are discovered by
> inspecting file contents rather than based on extension and I don't
> want to make it too easy for applications to ignore this principle and
> revert to extensions.

Frank,

thanks for you thorough response.

I agree that GDAL's detection is rather efficient, but sometimes it
can be relatively slow when scanning many files in a GUI.

This is admittedly a worst-case scenario, but is the reason why I
chose to optionally scan files by extension (rather than content) in
QGis - this can be enabled for specific directories.

>
> One other use that extensions are used for is to make it easy for a
> user to filter down files in a file browser to just one format.  I
> can't think of any time I've found this useful.  But with GDAL there
> are so many formats that these "list of formats" filter dohickyies are
> usually completely unusable.

Applications tend to have these, with ad-hoc rules for formats which
use various extensions (e.g. the QGis raster open dialog). This would
be simpler and more unified if extensions are reported by GDAL.

In short, I'd support a new GDAL_DMD_EXTENSION_LIST that supplements
existing GDAL_DMD_EXTENSION . I could commit such a feature in the
netcdf driver and gdalinfo output and update the docs if you agree.

Cheers
Etienne

>
> 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 Software Developer


More information about the gdal-dev mailing list