[GRASS-dev] r.out.gdal rewritten
Martin Landa
landa.martin at gmail.com
Wed Oct 25 12:42:27 EDT 2006
Hi,
2006/10/25, Hamish <hamish_nospam at yahoo.com>:
> > 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
> ...
OK, you are right, on the other hand I don't know how to set
format->options dynamically based on GDAL installation without coding
before G_parser () function. So might I ask you how to solve this
problem?
Thanks!, best regards Martin
--
Martin Landa <landa.martin at gmail.com> * http://gama.fsv.cvut.cz/~landa *
More information about the grass-dev
mailing list