[gdal-dev] gdalinfo and ogrinfo file formats
Even Rouault
even.rouault at mines-paris.org
Wed Jan 2 06:37:00 PST 2013
Selon Paul Meems <bontepaarden at gmail.com>:
> Hi Even,
>
> I'm not sure why I shouldn't use --format. If I can't use it why is it
> provided?
> Can I use --formats?
My message was that the output format of gdalinfo is primarly for humans, not to
be fed into other software. Well, this is my vision. You can do whatever you
want of course. (Hint: QGIS uses the C API to feed its Open raster dialog)
> Perhaps I should not handle this in my C#/WinForms but do this in our C++
> core.
You can probably use the GDAL C# API. This is basically just iterating over the
drivers and querying the relevant metadata keys. Should be pretty similar to the
C++ code.
> I think we can make a method that would return what I need based on
> gcore/gdal_misc.cpp but that would rely on hard-coded strings.
> I don't like that either ;)
By hard-coded strings, do you mean GDAL_DMD_EXTENSION and such strings ? Well,
they are part of the GDAL API, so they shouldn't change in the foreseable
future. They are also available in SWIG bindings (something like
Gdal.DMD_EXTENSION but I'm not sure, as I don't use the C# bindings myself)
>
> For the formats for ogr2ogr I understand I need to use a workaround so I
> could do that for the gdal formats as well.
> The whole idea is/was that when we upgrade to a newer version of GDAL/ORG
> or recompile it with some different settings our tools would automagically
> use the correct file formats.
Yes, I understood that. For OGR drivers, for now, you'll have to hardcode the
information (or put it into a config file with the relevant information). For
GDAL drivers, you can use the API to dynamically query the information.
More information about the gdal-dev
mailing list