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

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Dec 8 14:52:51 EST 2008


Author: neteler
Date: 2008-12-08 14:52:51 -0500 (Mon, 08 Dec 2008)
New Revision: 34806

Modified:
   grass/trunk/vector/v.mkgrid/main.c
   grass/trunk/vector/v.mkgrid/v.mkgrid.html
Log:
Ivan Shmakov: point support instead of areas

Modified: grass/trunk/vector/v.mkgrid/main.c
===================================================================
--- grass/trunk/vector/v.mkgrid/main.c	2008-12-08 19:49:56 UTC (rev 34805)
+++ grass/trunk/vector/v.mkgrid/main.c	2008-12-08 19:52:51 UTC (rev 34806)
@@ -1,4 +1,3 @@
-
 /****************************************************************************
  *
  * MODULE:       v.mkgrid
@@ -45,6 +44,8 @@
     struct Map_info Map;
     struct Option *vectname, *grid, *coord, *box, *angle, *position_opt;
     struct GModule *module;
+    struct Flag *points_fl;
+    int points_p;
 
     struct line_pnts *Points;
     struct line_cats *Cats;
@@ -109,9 +110,17 @@
 	_("Angle of rotation (in degrees counter-clockwise)");
     angle->answer = "0";
 
+    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;
+
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
+    points_p = points_fl->answer;
+
     /* get the current window  */
     G_get_window(&window);
 
@@ -228,7 +237,10 @@
 	G_fatal_error(_("Unable to grant privileges on table <%s>"),
 		      Fi->table);
 
-    write_grid(&grid_info, &Map);
+    if (! points_p) {
+	/* create areas */
+	write_grid(&grid_info, &Map);
+    }
 
     /* Create a grid of label points at the centres of the grid cells */
     G_verbose_message(_("Creating centroids..."));
@@ -238,6 +250,7 @@
     for (i = 0; i < grid_info.num_rows; ++i) {
 	for (j = 0; j < grid_info.num_cols; ++j) {
 	    double x, y;
+	    const int point_type = points_p ? GV_POINT : GV_CENTROID;
 
 	    x = grid_info.origin_x + (0.5 + j) * grid_info.length;
 	    y = grid_info.origin_y + (0.5 + i) * grid_info.width;
@@ -250,7 +263,7 @@
 
 	    Vect_append_point(Points, x, y, 0.0);
 	    Vect_cat_set(Cats, 1, attCount + 1);
-	    Vect_write_line(&Map, GV_CENTROID, Points, Cats);
+	    Vect_write_line(&Map, point_type, Points, Cats);
 
 	    if (grid_info.num_rows < 27 && grid_info.num_cols < 27) {
 		sprintf(buf,

Modified: grass/trunk/vector/v.mkgrid/v.mkgrid.html
===================================================================
--- grass/trunk/vector/v.mkgrid/v.mkgrid.html	2008-12-08 19:49:56 UTC (rev 34805)
+++ grass/trunk/vector/v.mkgrid/v.mkgrid.html	2008-12-08 19:52:51 UTC (rev 34806)
@@ -1,6 +1,7 @@
 <H2>DESCRIPTION</H2>
 
 <EM>v.mkgrid</EM> will create a vector map representation of a regular coordinate grid.
+Both point and area vector grids can be created.
 
 <H2>NOTES</H2>
 



More information about the grass-commit mailing list