فهرست منبع

Force input= filename to be an absolute path
Add source= option for non-file data sources


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@32968 15284696-431f-4ddb-bdfa-cd5b030d7da7

Glynn Clements 17 سال پیش
والد
کامیت
789e17e01d
1فایلهای تغییر یافته به همراه26 افزوده شده و 5 حذف شده
  1. 26 5
      raster/r.external/main.c

+ 26 - 5
raster/r.external/main.c

@@ -442,6 +442,7 @@ static void create_map(const char *input, int band, const char *output,
 int main(int argc, char *argv[])
 int main(int argc, char *argv[])
 {
 {
     char *input;
     char *input;
+    char *source;
     char *output;
     char *output;
     char *title;
     char *title;
     struct Cell_head cellhd;
     struct Cell_head cellhd;
@@ -449,7 +450,7 @@ int main(int argc, char *argv[])
     GDALRasterBandH hBand;
     GDALRasterBandH hBand;
     struct GModule *module;
     struct GModule *module;
     struct {
     struct {
-	struct Option *input, *output, *band, *title;
+	struct Option *input, *source, *output, *band, *title;
     } parm;
     } parm;
     struct Flag *flag_o, *flag_f, *flag_e, *flag_r;
     struct Flag *flag_o, *flag_f, *flag_e, *flag_r;
     int band;
     int band;
@@ -464,9 +465,15 @@ int main(int argc, char *argv[])
 
 
     parm.input = G_define_standard_option(G_OPT_F_INPUT);
     parm.input = G_define_standard_option(G_OPT_F_INPUT);
     parm.input->description = _("Raster file to be linked");
     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.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 = G_define_standard_option(G_OPT_R_OUTPUT);
     parm.output->required = NO;	/* not required because of -f flag */
     parm.output->required = NO;	/* not required because of -f flag */
     parm.output->guisection = _("Required");
     parm.output->guisection = _("Required");
@@ -515,7 +522,7 @@ int main(int argc, char *argv[])
     }
     }
 
 
     input = parm.input->answer;
     input = parm.input->answer;
-
+    source = parm.source->answer;
     output = parm.output->answer;
     output = parm.output->answer;
 
 
     if (parm.title->answer) {
     if (parm.title->answer) {
@@ -530,12 +537,26 @@ int main(int argc, char *argv[])
     else
     else
 	band = 1;
 	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)
     if (!output)
 	G_fatal_error(_("Name for output raster map not specified"));
 	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);
     hDS = GDALOpen(input, GA_ReadOnly);
     if (hDS == NULL)
     if (hDS == NULL)
 	return 1;
 	return 1;