[GRASS-SVN] r65446 - grass/trunk/vector/v.split

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jun 12 00:57:50 PDT 2015


Author: mlennert
Date: 2015-06-12 00:57:50 -0700 (Fri, 12 Jun 2015)
New Revision: 65446

Modified:
   grass/trunk/vector/v.split/main.c
Log:
added flag to impose fixed length segments


Modified: grass/trunk/vector/v.split/main.c
===================================================================
--- grass/trunk/vector/v.split/main.c	2015-06-12 03:31:56 UTC (rev 65445)
+++ grass/trunk/vector/v.split/main.c	2015-06-12 07:57:50 UTC (rev 65446)
@@ -36,13 +36,13 @@
     struct GModule *module;
     struct Option *in_opt, *layer_opt, *out_opt, *length_opt,
                   *units_opt, *vertices_opt;
-    struct Flag *nosplit_flag;
+    struct Flag *nosplit_flag, *fixedlength_flag;
     
     struct Map_info In, Out;
     struct line_pnts *Points, *Points2, *Points3;
     struct line_cats *Cats;
 
-    int line, nlines, layer, nosplit;
+    int line, nlines, layer, nosplit, fixedlength;
     double length = -1;
     int vertices = 0;
     double (*line_length) ();
@@ -92,6 +92,13 @@
     nosplit_flag->key = 'n';
     nosplit_flag->label = _("Add new vertices, but do not split");
     nosplit_flag->description = _("Applies only to 'length' option");
+
+    fixedlength_flag = G_define_flag();
+    fixedlength_flag->key = 'f';
+    fixedlength_flag->label = _("Force segments to be exactly of given length, except for last one");
+    fixedlength_flag->description = _("Applies only to 'length' option");
+
+
     
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
@@ -157,6 +164,7 @@
 	    G_fatal_error(_("Number of vertices must be at least 2"));
     }
     nosplit = nosplit_flag->answer;
+    fixedlength = fixedlength_flag->answer;
     
     Vect_set_open_level(2);
 
@@ -208,10 +216,17 @@
 		    G_debug(3, "l: %f, length: %f", l, length);
 
 		    n = ceil(l / length);
+
 		    if (geodesic)
 			l = Vect_line_length(Points);
 
-		    step = l / n;
+		    if (fixedlength) {
+			    step = length;
+		    }
+		    else {
+			    step = l / n;
+		    }
+
 		    from = 0.;
 		    
 		    G_debug(3, "n: %ld, step: %f", n, step);



More information about the grass-commit mailing list