[GRASS-SVN] r61729 - in grass/branches/releasebranch_7_0: . vector/v.generalize
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Aug 24 15:00:26 PDT 2014
Author: neteler
Date: 2014-08-24 15:00:26 -0700 (Sun, 24 Aug 2014)
New Revision: 61729
Modified:
grass/branches/releasebranch_7_0/
grass/branches/releasebranch_7_0/vector/v.generalize/main.c
Log:
v.generalize: create optionally error vector map (trac #2373, trunk r61507)
Property changes on: grass/branches/releasebranch_7_0
___________________________________________________________________
Added: svn:mergeinfo
+ /grass/trunk:61507,61718
Modified: grass/branches/releasebranch_7_0/vector/v.generalize/main.c
===================================================================
--- grass/branches/releasebranch_7_0/vector/v.generalize/main.c 2014-08-24 21:17:33 UTC (rev 61728)
+++ grass/branches/releasebranch_7_0/vector/v.generalize/main.c 2014-08-24 22:00:26 UTC (rev 61729)
@@ -42,12 +42,12 @@
int main(int argc, char *argv[])
{
- struct Map_info In, Out;
+ struct Map_info In, Out, Error;
struct line_pnts *Points;
struct line_cats *Cats;
int i, type, iter;
struct GModule *module; /* GRASS module for parsing arguments */
- struct Option *map_in, *map_out, *thresh_opt, *method_opt,
+ struct Option *map_in, *map_out, *error_out, *thresh_opt, *method_opt,
*look_ahead_opt;
struct Option *iterations_opt, *cat_opt, *alpha_opt, *beta_opt, *type_opt;
struct Option *field_opt, *where_opt, *reduction_opt, *slide_opt;
@@ -93,6 +93,11 @@
map_out = G_define_standard_option(G_OPT_V_OUTPUT);
+ error_out = G_define_standard_option(G_OPT_V_OUTPUT);
+ error_out->key = "error";
+ error_out->required = NO;
+ error_out->description =
+ _("Error map of all lines and boundaries not being generalized due to topology issues or over-simplification");
method_opt = G_define_option();
method_opt->key = "method";
@@ -324,7 +329,14 @@
G_fatal_error(_("Unable to create vector map <%s>"), map_out->answer);
}
+ if(error_out->answer)
+ if (0 > Vect_open_new(&Error, error_out->answer, with_z)) {
+ Vect_close(&In);
+ G_fatal_error(_("Unable to create error vector map <%s>"), error_out->answer);
+ }
+
+
Vect_copy_head_data(&In, &Out);
Vect_hist_copy(&In, &Out);
Vect_hist_command(&Out);
@@ -533,12 +545,16 @@
if (Points->n_points < 2) {
after = APoints->n_points;
n_oversimplified++;
+ if(error_out->answer)
+ Vect_write_line(&Error, type, APoints, Cats);
}
/* check for topology corruption */
else if (type == GV_BOUNDARY) {
if (!check_topo(&Out, i, APoints, Points, Cats)) {
after = APoints->n_points;
not_modified_boundaries++;
+ if(error_out->answer)
+ Vect_write_line(&Error, type, APoints, Cats);
}
else
after = Points->n_points;
@@ -561,12 +577,18 @@
/* make sure that clean topo is built at the end */
Vect_build_partial(&Out, GV_BUILD_NONE);
+ if(error_out->answer)
+ Vect_build_partial(&Error, GV_BUILD_NONE);
}
Vect_build(&Out);
+ if(error_out->answer)
+ Vect_build(&Error);
Vect_close(&In);
Vect_close(&Out);
+ if(error_out->answer)
+ Vect_close(&Error);
G_message("-----------------------------------------------------");
if (total_input != 0 && total_input != total_output)
More information about the grass-commit
mailing list