[GRASS-SVN] r66978 - grass/branches/releasebranch_7_0/vector/v.in.ogr
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Nov 29 05:28:56 PST 2015
Author: martinl
Date: 2015-11-29 05:28:56 -0800 (Sun, 29 Nov 2015)
New Revision: 66978
Modified:
grass/branches/releasebranch_7_0/vector/v.in.ogr/main.c
Log:
v.in.ogr: backport -j flag from trunk (used by v.import)
Modified: grass/branches/releasebranch_7_0/vector/v.in.ogr/main.c
===================================================================
--- grass/branches/releasebranch_7_0/vector/v.in.ogr/main.c 2015-11-28 22:03:21 UTC (rev 66977)
+++ grass/branches/releasebranch_7_0/vector/v.in.ogr/main.c 2015-11-29 13:28:56 UTC (rev 66978)
@@ -9,7 +9,7 @@
*
* PURPOSE: Import OGR vectors
*
- * COPYRIGHT: (C) 2003-2014 by the GRASS Development Team
+ * COPYRIGHT: (C) 2003-2015 by the GRASS Development Team
*
* This program is free software under the GNU General
* Public License (>=v2). Read the file COPYING that
@@ -56,8 +56,8 @@
} param;
struct _flag {
struct Flag *list, *no_clean, *force2d, *notab,
- *region;
- struct Flag *over, *extend, *formats, *tolower, *no_import;
+ *region, *over, *extend, *formats, *tolower, *no_import,
+ *proj;
} flag;
char *desc;
@@ -278,6 +278,13 @@
flag.over->description =
_("Override dataset projection (use location's projection)");
+ flag.proj = G_define_flag();
+ flag.proj->key = 'j';
+ flag.proj->description =
+ _("Perform projection check only and exit");
+ flag.proj->suppress_required = YES;
+ G_option_requires(flag.proj, param.dsn, NULL);
+
flag.region = G_define_flag();
flag.region->key = 'r';
flag.region->guisection = _("Selection");
@@ -518,7 +525,7 @@
G_warning(_("All available OGR layers will be imported into vector map <%s>"), output);
}
- if (!param.outloc->answer) { /* Check if the map exists */
+ if (!param.outloc->answer && !flag.proj->answer) { /* Check if the map exists */
if (G_find_vector2(output, G_mapset()) && !overwrite)
G_fatal_error(_("Vector map <%s> already exists"),
output);
@@ -615,7 +622,8 @@
}
else {
int err = 0;
-
+ void (*msg_fn)(const char *, ...);
+
/* Projection only required for checking so convert non-interactively */
if (GPJ_osr_to_grass(&cellhd, &proj_info,
&proj_units, Ogr_projection, 0) < 0)
@@ -641,7 +649,7 @@
G_compare_projections(loc_proj_info, loc_proj_units,
proj_info, proj_units)) != TRUE) {
int i_value;
-
+
strcpy(error_msg,
_("Projection of dataset does not"
" appear to match current location.\n\n"));
@@ -707,16 +715,27 @@
sprintf(error_msg + strlen(error_msg),
_("\nIn case of no significant differences in the projection definitions,"
" use the -o flag to ignore them and use"
- " current location definition.\n"),
- G_program_name());
+ " current location definition.\n"));
strcat(error_msg,
_("Consider generating a new location with 'location' parameter"
" from input data set.\n"));
- G_fatal_error("%s", error_msg);
+ if (flag.proj->answer)
+ msg_fn = G_message;
+ else
+ msg_fn = G_fatal_error;
+ msg_fn(error_msg);
+ if (flag.proj->answer)
+ exit(EXIT_FAILURE);
}
else {
- G_verbose_message(_("Projection of input dataset and current location "
- "appear to match"));
+ if (flag.proj->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.proj->answer)
+ exit(EXIT_SUCCESS);
}
}
More information about the grass-commit
mailing list