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

svn_grass at osgeo.org svn_grass at osgeo.org
Mon May 25 07:30:47 EDT 2009


Author: hamish
Date: 2009-05-25 07:30:47 -0400 (Mon, 25 May 2009)
New Revision: 37464

Modified:
   grass/trunk/vector/v.mkgrid/local_proto.h
   grass/trunk/vector/v.mkgrid/main.c
   grass/trunk/vector/v.mkgrid/write_grid.c
Log:
add option to increase num horiz vertices per cell; e.g. for reprojection to polar stereographic (merge from devbr6)

Modified: grass/trunk/vector/v.mkgrid/local_proto.h
===================================================================
--- grass/trunk/vector/v.mkgrid/local_proto.h	2009-05-25 11:21:01 UTC (rev 37463)
+++ grass/trunk/vector/v.mkgrid/local_proto.h	2009-05-25 11:30:47 UTC (rev 37464)
@@ -2,6 +2,6 @@
 void rotate(double *, double *, double, double, double);
 
 /* write_grid.c */
-int write_grid(struct grid_description *, struct Map_info *);
+int write_grid(struct grid_description *, struct Map_info *, int);
 int write_vect(double, double, double, double, struct Map_info *,
 	       struct line_pnts *);

Modified: grass/trunk/vector/v.mkgrid/main.c
===================================================================
--- grass/trunk/vector/v.mkgrid/main.c	2009-05-25 11:21:01 UTC (rev 37463)
+++ grass/trunk/vector/v.mkgrid/main.c	2009-05-25 11:30:47 UTC (rev 37464)
@@ -4,7 +4,7 @@
  * AUTHOR(S):    Written by GRASS, Fall of 88, Michael Higgins CERL (original contributor)
  *               Updated <02 Jun 1992> by Darrell McCauley <mccauley at ecn.purdue.edu> angle option added.
  *               Upgrade to 5.7 Radim Blazek 10/2004
- *               Hamish Bowman <hamish_nospam yahoo.com>,
+ *               Hamish Bowman <hamish_b yahoo.com>,
  *               Jachym Cepicky <jachym les-ejk.cz>, Markus Neteler <neteler itc.it>
  * PURPOSE:      
  * COPYRIGHT:    (C) 1999-2007 by the GRASS Development Team
@@ -37,12 +37,12 @@
     char buf[2000];
 
     /* Other local variables */
-    int attCount;
+    int attCount, nbreaks;
 
     struct grid_description grid_info;
     struct Cell_head window;
     struct Map_info Map;
-    struct Option *vectname, *grid, *coord, *box, *angle, *position_opt;
+    struct Option *vectname, *grid, *coord, *box, *angle, *position_opt, *breaks;
     struct GModule *module;
     struct Flag *points_fl;
     int points_p;
@@ -110,15 +110,24 @@
 	_("Angle of rotation (in degrees counter-clockwise)");
     angle->answer = "0";
 
+    breaks = G_define_option();
+    breaks->key = "breaks";
+    breaks->type = TYPE_INTEGER;
+    breaks->required = NO;
+    breaks->description =
+	_("Number of horizontal vertex points per grid cell");
+    breaks->options = "3-30";
+    breaks->answer = "3";
+
     points_fl = G_define_flag ();
     points_fl->key = 'p';
-    points_fl->description = _("Create grid of points"
-			       " instead of areas and centroids");
-    points_fl->answer = 0;
+    points_fl->description =
+	_("Create grid of points instead of areas and centroids");
 
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
+
     points_p = points_fl->answer;
 
     /* get the current window  */
@@ -136,6 +145,8 @@
 
     grid_info.angle = M_PI / 180 * atof(angle->answer);
 
+    nbreaks = atoi(breaks->answer);
+
     /* Position */
     if (position_opt->answer[0] == 'r') {	/* region */
 	if (coord->answer)
@@ -239,7 +250,7 @@
 
     if (! points_p) {
 	/* create areas */
-	write_grid(&grid_info, &Map);
+	write_grid(&grid_info, &Map, nbreaks);
     }
 
     /* Create a grid of label points at the centres of the grid cells */

Modified: grass/trunk/vector/v.mkgrid/write_grid.c
===================================================================
--- grass/trunk/vector/v.mkgrid/write_grid.c	2009-05-25 11:21:01 UTC (rev 37463)
+++ grass/trunk/vector/v.mkgrid/write_grid.c	2009-05-25 11:30:47 UTC (rev 37464)
@@ -5,7 +5,7 @@
 #include "grid_structs.h"
 #include "local_proto.h"
 
-int write_grid(struct grid_description *grid_info, struct Map_info *Map)
+int write_grid(struct grid_description *grid_info, struct Map_info *Map, int nbreaks)
 {
 
     int i, k, j;
@@ -35,8 +35,8 @@
      * to make sure that each section of the grid
      * line is less than half way around the globe
      */
-    x_len = length / 3.;
-    x_cols = cols * 3.;
+    x_len = length / (1. * nbreaks);
+    x_cols = cols * (1. * nbreaks);
 
     /* write out all the vector lengths (x vectors) of the entire grid  */
     G_verbose_message(_("Writing out vector rows..."));
@@ -50,8 +50,8 @@
 
 	for (k = 0; k < cols; k++) {
 	    x = startx;
-	    for (j = 0; j < 3; j++) {
-		if (j < 2)
+	    for (j = 0; j < nbreaks; j++) {
+		if (j < nbreaks -1)
 		    next_x = x + x_len;
 		else
 		    next_x = startx + length;
@@ -113,8 +113,8 @@
 
 #define  NUM_POINTS  2
 
-int write_vect(double x1, double y1, double x2, double y2, struct Map_info *Map, struct line_pnts *Points	/* new with Vlib */
-    )
+int write_vect(double x1, double y1, double x2, double y2,
+	       struct Map_info *Map, struct line_pnts *Points) /* new with Vlib */
 {
     static struct line_cats *Cats = NULL;
 



More information about the grass-commit mailing list