[GRASS-SVN] r43621 -
grass/branches/releasebranch_6_4/vector/v.mkgrid
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Sep 22 12:14:25 EDT 2010
Author: neteler
Date: 2010-09-22 16:14:25 +0000 (Wed, 22 Sep 2010)
New Revision: 43621
Modified:
grass/branches/releasebranch_6_4/vector/v.mkgrid/local_proto.h
grass/branches/releasebranch_6_4/vector/v.mkgrid/main.c
grass/branches/releasebranch_6_4/vector/v.mkgrid/write_grid.c
Log:
backport: add option to increase num horiz vertices per cell; e.g. for reprojection to polar stereographic (merge from devbr6)
Modified: grass/branches/releasebranch_6_4/vector/v.mkgrid/local_proto.h
===================================================================
--- grass/branches/releasebranch_6_4/vector/v.mkgrid/local_proto.h 2010-09-22 16:10:12 UTC (rev 43620)
+++ grass/branches/releasebranch_6_4/vector/v.mkgrid/local_proto.h 2010-09-22 16:14:25 UTC (rev 43621)
@@ -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/branches/releasebranch_6_4/vector/v.mkgrid/main.c
===================================================================
--- grass/branches/releasebranch_6_4/vector/v.mkgrid/main.c 2010-09-22 16:10:12 UTC (rev 43620)
+++ grass/branches/releasebranch_6_4/vector/v.mkgrid/main.c 2010-09-22 16:14:25 UTC (rev 43621)
@@ -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 Flag *q;
struct Flag *points_fl;
int points_p;
@@ -111,11 +111,19 @@
_("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");
/* please, remove before GRASS 7 released */
q = G_define_flag();
@@ -126,6 +134,7 @@
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
+
/* please, remove before GRASS 7 released */
if (q->answer) {
putenv("GRASS_VERBOSE=0");
@@ -151,6 +160,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)
@@ -254,7 +265,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/branches/releasebranch_6_4/vector/v.mkgrid/write_grid.c
===================================================================
--- grass/branches/releasebranch_6_4/vector/v.mkgrid/write_grid.c 2010-09-22 16:10:12 UTC (rev 43620)
+++ grass/branches/releasebranch_6_4/vector/v.mkgrid/write_grid.c 2010-09-22 16:14:25 UTC (rev 43621)
@@ -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