Hamish wrote:
> > format->options =
> > "AAIGrid,BMP,BSB,DTED,ELAS,ENVI,FIT,GIF,GTiff,HFA,JPEG,MEM,MFF,MF
> > F2, NITF,PAux,PNG,PNM,VRT,XPM";
>
> don't hardcode the available formats. They will depend on the local
> installation of GDAL, and what configure flags it was built with,
> and as such options will vary widely. If you hard code it you impose
> an artificial barrier to optional and future raster formats.
>
> depend on "r.out.gdal -l" and examples (GTiff) instead.
Vytautas wrote:
List of avaible formats in format options is now generated dynamicly.
G_gisinit (argv[0]);
+ /* Init GDAL */
+ GDALAllRegister();
+
module = G_define_module();
[..]
+
+ supported_formats(&gdal_formats);
+
format = G_define_option();
format->key = "format";
format->type = TYPE_STRING;
format->description = _("GIS format to write (case sensitive, see also -l flag)");
- format->options = "AAIGrid,BMP,BSB,DTED,ELAS,ENVI,FIT,GIF,GTiff,HFA,JPEG,MEM,MFF,MFF2,N
ITF,PAux,PNG,PNM,VRT,XPM";
+ /* format->options = "AAIGrid,BMP,BSB,DTED,ELAS,ENVI,FIT,GIF,GTiff,HFA,JPEG,MEM,MFF,MFF
2,NITF,PAux,PNG,PNM,VRT,XPM"; */
+ if (gdal_formats)
+ format->options = G_store (gdal_formats);
+ else
+ G_fatal_error (_("Unknown GIS formats"));
+
format->answer = "GTiff";
format->required = NO;
[..]
if (G_parser(argc,argv)) exit(EXIT_FAILURE);
it is bad to put any non parser code before G_parser():
http://article.gmane.org/gmane.comp.gis.grass.devel/12473/
http://article.gmane.org/gmane.comp.gis.grass.devel/5224
http://article.gmane.org/gmane.comp.gis.grass.devel/12446/
http://article.gmane.org/gmane.comp.gis.grass.devel/7169
...
Hamish