[GRASS-SVN] r66478 - grass/branches/releasebranch_7_0/raster/r.in.gdal
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Oct 12 06:06:19 PDT 2015
Author: neteler
Date: 2015-10-12 06:06:19 -0700 (Mon, 12 Oct 2015)
New Revision: 66478
Modified:
grass/branches/releasebranch_7_0/raster/r.in.gdal/main.c
Log:
r.in.gdal: add -j flag to perform projection check only (used by r.import) (r65911, fixes r66466)
Modified: grass/branches/releasebranch_7_0/raster/r.in.gdal/main.c
===================================================================
--- grass/branches/releasebranch_7_0/raster/r.in.gdal/main.c 2015-10-12 11:10:48 UTC (rev 66477)
+++ grass/branches/releasebranch_7_0/raster/r.in.gdal/main.c 2015-10-12 13:06:19 UTC (rev 66478)
@@ -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. */
@@ -157,6 +158,13 @@
flag_o->description =
_("Override projection (use location's projection)");
+ 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");
@@ -189,7 +197,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
@@ -297,7 +304,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)
@@ -409,6 +416,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? */
@@ -508,11 +517,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);
}
}
}
@@ -817,8 +839,6 @@
G_message(_("Region for the current mapset updated"));
}
- G_done_msg(" ");
-
exit(EXIT_SUCCESS);
}
More information about the grass-commit
mailing list