[GRASS-SVN] r31902 - grass-addons/vector/v.parallel2

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jun 30 14:15:40 EDT 2008


Author: rmatev
Date: 2008-06-30 14:15:40 -0400 (Mon, 30 Jun 2008)
New Revision: 31902

Modified:
   grass-addons/vector/v.parallel2/main.c
   grass-addons/vector/v.parallel2/vlib_buffer.c
Log:
Added feature: parallel lines on both sides; fixed minor bug;

Modified: grass-addons/vector/v.parallel2/main.c
===================================================================
--- grass-addons/vector/v.parallel2/main.c	2008-06-30 15:27:31 UTC (rev 31901)
+++ grass-addons/vector/v.parallel2/main.c	2008-06-30 18:15:40 UTC (rev 31902)
@@ -76,8 +76,8 @@
     side_opt->required = YES;
     side_opt->answer = "right";
     side_opt->multiple = NO;
-    side_opt->options = "left,right";
-    side_opt->description = _("left;Parallel line is on the left;right;Parallel line is on the right;");
+    side_opt->options = "left,right,both";
+    side_opt->description = _("left;Parallel line is on the left;right;Parallel line is on the right;both;Parallel lines on both sides");
 
     tol_opt = G_define_option();
     tol_opt->key = "tolerance";
@@ -120,6 +120,8 @@
         side = 1;
     else if (strcmp(side_opt->answer, "left") == 0)
         side = -1;
+    else
+        side = 0;
 
     Vect_set_open_level (2); 
     Vect_open_old (&In, in_opt->answer, ""); 
@@ -143,8 +145,16 @@
         
         if ( ltype & GV_LINES ) {
             if (!(buf_flag->answer)) {
-                Vect_line_parallel2(Points, da, db, dalpha, side, round_flag->answer, tolerance, Points2);
-                Vect_write_line(&Out, ltype, Points2, Cats);
+                if (side != 0) {
+                    Vect_line_parallel2(Points, da, db, dalpha, side, round_flag->answer, tolerance, Points2);
+                    Vect_write_line(&Out, ltype, Points2, Cats);
+                }
+                else {
+                    Vect_line_parallel2(Points, da, db, dalpha, 1, round_flag->answer, tolerance, Points2);
+                    Vect_write_line(&Out, ltype, Points2, Cats);
+                    Vect_line_parallel2(Points, da, db, dalpha, -1, round_flag->answer, tolerance, Points2);
+                    Vect_write_line(&Out, ltype, Points2, Cats);
+                }   
             }
             else {
                 parallel_line_b(Points, da, db, dalpha, round_flag->answer, 1, tolerance, &oPoints, &iPoints, &inner_count);

Modified: grass-addons/vector/v.parallel2/vlib_buffer.c
===================================================================
--- grass-addons/vector/v.parallel2/vlib_buffer.c	2008-06-30 15:27:31 UTC (rev 31901)
+++ grass-addons/vector/v.parallel2/vlib_buffer.c	2008-06-30 18:15:40 UTC (rev 31902)
@@ -493,8 +493,11 @@
         wx = vx;
         wy = vy;        
     }
-    i = nPoints->n_points - 1;
-    Vect_line_insert_point(nPoints, 0, nPoints->x[i], nPoints->y[i], 0); 
+    
+    if (looped) {
+        i = nPoints->n_points - 1;
+        Vect_line_insert_point(nPoints, 0, nPoints->x[i], nPoints->y[i], 0);
+    }
     Vect_line_prune ( nPoints );
 }
 



More information about the grass-commit mailing list