[GRASS-SVN] r65911 - grass/trunk/raster/r.in.gdal
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Aug 12 04:55:19 PDT 2015
Author: martinl
Date: 2015-08-12 04:55:19 -0700 (Wed, 12 Aug 2015)
New Revision: 65911
Modified:
grass/trunk/raster/r.in.gdal/main.c
Log:
r.in.gdal: add -j flag to perform projection check only (used by r.import)
Modified: grass/trunk/raster/r.in.gdal/main.c
===================================================================
--- grass/trunk/raster/r.in.gdal/main.c 2015-08-12 11:11:34 UTC (rev 65910)
+++ grass/trunk/raster/r.in.gdal/main.c 2015-08-12 11:55:19 UTC (rev 65911)
@@ -75,7 +75,8 @@
struct Option *input, *output, *target, *title, *outloc, *band,
*memory, *offset, *rat;
} parm;
- struct Flag *flag_o, *flag_e, *flag_k, *flag_f, *flag_l, *flag_c, *flag_p;
+ struct Flag *flag_o, *flag_e, *flag_k, *flag_f, *flag_l, *flag_c, *flag_p,
+ *flag_j;
/* -------------------------------------------------------------------- */
/* Initialize. */
@@ -159,6 +160,13 @@
flag_o->description =
_("Assume that the dataset has same projection as the current location");
+ flag_j = G_define_flag();
+ flag_j->key = 'j';
+ flag_j->description =
+ _("Perform projection check only and exit");
+ flag_j->suppress_required = YES;
+ G_option_requires(flag_j, parm.input, NULL);
+
flag_e = G_define_flag();
flag_e->key = 'e';
flag_e->label = _("Extend region extents based on new dataset");
@@ -191,7 +199,6 @@
flag_p->key = 'p';
flag_p->description = _("Print number of bands and exit");
flag_p->suppress_required = YES;
-
G_option_requires(flag_p, parm.input, NULL);
/* The parser checks if the map already exists in current mapset, this is
@@ -299,7 +306,7 @@
exit(EXIT_SUCCESS);
}
- if (!parm.outloc->answer &&
+ if (output && !parm.outloc->answer &&
GDALGetRasterCount(hDS) == 1) { /* Check if the map exists */
if (G_find_raster2(output, G_mapset())) {
if (overwrite)
@@ -411,6 +418,8 @@
G_warning(_("Unable to convert input raster map projection information to "
"GRASS format for checking"));
else {
+ void (*msg_fn)(const char *, ...);
+
/* -------------------------------------------------------------------- */
/* Does the projection of the current location match the */
/* dataset? */
@@ -510,11 +519,24 @@
strcat(error_msg,
_("Consider generating a new location from the input dataset using "
"the 'location' parameter.\n"));
- G_fatal_error(error_msg);
+
+ if (flag_j->answer)
+ msg_fn = G_message;
+ else
+ msg_fn = G_fatal_error;
+ msg_fn(error_msg);
+ if (flag_j->answer)
+ exit(EXIT_FAILURE);
}
else {
- G_verbose_message(_("Projection of input dataset and current location "
- "appear to match"));
+ if (flag_j->answer)
+ msg_fn = G_message;
+ else
+ msg_fn = G_verbose_message;
+ msg_fn(_("Projection of input dataset and current location "
+ "appear to match"));
+ if (flag_j->answer)
+ exit(EXIT_SUCCESS);
}
}
}
@@ -819,8 +841,6 @@
G_message(_("Region for the current mapset updated"));
}
- G_done_msg(" ");
-
exit(EXIT_SUCCESS);
}
More information about the grass-commit
mailing list