[GRASS-SVN] r32968 - grass/trunk/raster/r.external
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Aug 21 08:53:05 EDT 2008
Author: glynn
Date: 2008-08-21 08:53:05 -0400 (Thu, 21 Aug 2008)
New Revision: 32968
Modified:
grass/trunk/raster/r.external/main.c
Log:
Force input= filename to be an absolute path
Add source= option for non-file data sources
Modified: grass/trunk/raster/r.external/main.c
===================================================================
--- grass/trunk/raster/r.external/main.c 2008-08-21 11:57:06 UTC (rev 32967)
+++ grass/trunk/raster/r.external/main.c 2008-08-21 12:53:05 UTC (rev 32968)
@@ -442,6 +442,7 @@
int main(int argc, char *argv[])
{
char *input;
+ char *source;
char *output;
char *title;
struct Cell_head cellhd;
@@ -449,7 +450,7 @@
GDALRasterBandH hBand;
struct GModule *module;
struct {
- struct Option *input, *output, *band, *title;
+ struct Option *input, *source, *output, *band, *title;
} parm;
struct Flag *flag_o, *flag_f, *flag_e, *flag_r;
int band;
@@ -464,9 +465,15 @@
parm.input = G_define_standard_option(G_OPT_F_INPUT);
parm.input->description = _("Raster file to be linked");
- parm.input->required = NO; /* not required because of -f flag */
+ parm.input->required = NO;
parm.input->guisection = _("Required");
+ parm.source = G_define_option();
+ parm.source->key = "source";
+ parm.source->description = _("Name of non-file GDAL data source");
+ parm.source->required = NO;
+ parm.source->type = TYPE_STRING;
+
parm.output = G_define_standard_option(G_OPT_R_OUTPUT);
parm.output->required = NO; /* not required because of -f flag */
parm.output->guisection = _("Required");
@@ -515,7 +522,7 @@
}
input = parm.input->answer;
-
+ source = parm.source->answer;
output = parm.output->answer;
if (parm.title->answer) {
@@ -530,12 +537,26 @@
else
band = 1;
- if (!input)
- G_fatal_error(_("Name for input raster map not specified"));
+ if (!input && !source)
+ G_fatal_error(_("Name for input source not specified"));
+ if (input && source)
+ G_fatal_error(_("input= and source= are mutually exclusive"));
+
if (!output)
G_fatal_error(_("Name for output raster map not specified"));
+ if (input && !G_is_absolute_path(input)) {
+ char path[GPATH_MAX];
+ getcwd(path, sizeof(path));
+ strcat(path, "/");
+ strcat(path, input);
+ input = G_store(path);
+ }
+
+ if (!input)
+ input = source;
+
hDS = GDALOpen(input, GA_ReadOnly);
if (hDS == NULL)
return 1;
More information about the grass-commit
mailing list