[GRASS-SVN] r61552 - grass/trunk/vector/v.mkgrid

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Aug 6 08:51:00 PDT 2014


Author: lucadelu
Date: 2014-08-06 08:51:00 -0700 (Wed, 06 Aug 2014)
New Revision: 61552

Modified:
   grass/trunk/vector/v.mkgrid/main.c
   grass/trunk/vector/v.mkgrid/write_grid.c
Log:
v.mkgrid: added breaks for vertical lines (ticket #1686)

Modified: grass/trunk/vector/v.mkgrid/main.c
===================================================================
--- grass/trunk/vector/v.mkgrid/main.c	2014-08-06 13:53:09 UTC (rev 61551)
+++ grass/trunk/vector/v.mkgrid/main.c	2014-08-06 15:51:00 UTC (rev 61552)
@@ -6,9 +6,9 @@
  *               Upgrade to 5.7 Radim Blazek 10/2004
  *               Hamish Bowman <hamish_b yahoo.com>,
  *               Jachym Cepicky <jachym les-ejk.cz>, Markus Neteler <neteler itc.it>
- *               Ivan Shevlakov: points support -p                
- *               Luca Delucchi: lines support -l
- * PURPOSE:      
+ *               Ivan Shevlakov: points support -p
+ *               Luca Delucchi: lines support -l, vertical breaks
+ * PURPOSE:
  * COPYRIGHT:    (C) 1999-2014 by the GRASS Development Team
  *
  *               This program is free software under the GNU General
@@ -125,7 +125,7 @@
     breaks->type = TYPE_INTEGER;
     breaks->required = NO;
     breaks->description =
-	_("Number of horizontal vertex points per grid cell");
+	_("Number of vertex points per grid cell");
     breaks->options = "0-60";
     breaks->answer = "3";
 

Modified: grass/trunk/vector/v.mkgrid/write_grid.c
===================================================================
--- grass/trunk/vector/v.mkgrid/write_grid.c	2014-08-06 13:53:09 UTC (rev 61551)
+++ grass/trunk/vector/v.mkgrid/write_grid.c	2014-08-06 15:51:00 UTC (rev 61552)
@@ -11,7 +11,7 @@
     int i, k, j;
     int rows, cols;
     int num_v_rows, num_v_cols;
-    double x, y, x_len;
+    double x, y, x_len, y_len;
     double sx, sy;
     double width, length;
     double next_x, next_y;
@@ -36,10 +36,10 @@
      * line is less than half way around the globe
      */
      x_len = length / (1. * nbreaks + 1);
+     y_len = width / (1. * nbreaks + 1);
 
     /* write out all the vector lengths (x vectors) of the entire grid  */
     G_verbose_message(_("Writing out vector rows..."));
-
     y = grid_info->origin_y;
     for (i = 0; i < num_v_rows; ++i) {
 	double startx;
@@ -79,29 +79,37 @@
     /* write out all the vector widths (y vectors) of the entire grid  */
     G_verbose_message(_("Writing out vector columns..."));
     x = grid_info->origin_x;
-    for (k = 0; k < num_v_cols; ++k) {
-	y = grid_info->origin_y;
-	G_percent(k, num_v_cols, 2);
+    for (i = 0; i < num_v_cols; ++i) {
+        double starty;
+	starty = grid_info->origin_y;
+	G_percent(i, num_v_cols, 2);
 
-	i = 0;
-        do {
-	    next_y = y + width;
+	for (k = 0; k < rows; k++) {
+	  y = starty;
+	  j = 0;
+	  do {
+	      if (j < nbreaks)
+		  next_y = y + y_len;
+	      else
+		  next_y = starty + width;
 
-	    sx = x;
-	    sy = y;
-	    snext_y = next_y;
-	    dum = x;
-	    rotate(&x, &y, grid_info->origin_x, grid_info->origin_y, angle);
-	    rotate(&dum, &next_y, grid_info->origin_x, grid_info->origin_y,
-		   angle);
+	      sx = x;
+	      sy = y;
+	      snext_y = next_y;
+	      dum = x;
+	      rotate(&x, &y, grid_info->origin_x, grid_info->origin_y, angle);
+	      rotate(&dum, &next_y, grid_info->origin_x, grid_info->origin_y,
+		    angle);
 
-	    write_vect(x, y, dum, next_y, Map, Points, out_type);
+	      write_vect(x, y, dum, next_y, Map, Points, out_type);
 
-	    x = sx;
-	    y = next_y = snext_y;
-            i++;
-	} while (i < rows);
-	/* To get exactly the same coordinates as above, x+=length is wrong */
+	      x = sx;
+	      y = next_y = snext_y;
+	      j++;
+	  } while (j <= nbreaks);
+	  /* To get exactly the same coordinates as above, y+=width is wrong */
+	  starty += width;
+	}
 	x += length;
     }
 



More information about the grass-commit mailing list