[GRASS-SVN] r34805 - grass/branches/develbranch_6/vector/v.mkgrid
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Dec 8 14:49:56 EST 2008
Author: neteler
Date: 2008-12-08 14:49:56 -0500 (Mon, 08 Dec 2008)
New Revision: 34805
Modified:
grass/branches/develbranch_6/vector/v.mkgrid/description.html
grass/branches/develbranch_6/vector/v.mkgrid/main.c
Log:
Ivan Shmakov: point support instead of areas
Modified: grass/branches/develbranch_6/vector/v.mkgrid/description.html
===================================================================
--- grass/branches/develbranch_6/vector/v.mkgrid/description.html 2008-12-08 14:26:04 UTC (rev 34804)
+++ grass/branches/develbranch_6/vector/v.mkgrid/description.html 2008-12-08 19:49:56 UTC (rev 34805)
@@ -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>
Modified: grass/branches/develbranch_6/vector/v.mkgrid/main.c
===================================================================
--- grass/branches/develbranch_6/vector/v.mkgrid/main.c 2008-12-08 14:26:04 UTC (rev 34804)
+++ grass/branches/develbranch_6/vector/v.mkgrid/main.c 2008-12-08 19:49:56 UTC (rev 34805)
@@ -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 Flag *q;
+ struct Flag *points_fl;
+ int points_p;
struct GModule *module;
struct line_pnts *Points;
@@ -110,6 +111,12 @@
_("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;
+
/* please, remove before GRASS 7 released */
q = G_define_flag();
q->key = 'q';
@@ -127,6 +134,8 @@
}
+ points_p = points_fl->answer;
+
/* get the current window */
G_get_window(&window);
@@ -243,7 +252,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..."));
@@ -253,6 +265,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;
@@ -265,7 +278,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,
More information about the grass-commit
mailing list