[GRASS-SVN] r44929 - grass/trunk/vector/v.transform

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jan 10 08:20:57 EST 2011


Author: martinl
Date: 2011-01-10 05:20:57 -0800 (Mon, 10 Jan 2011)
New Revision: 44929

Modified:
   grass/trunk/vector/v.transform/local_proto.h
   grass/trunk/vector/v.transform/main.c
   grass/trunk/vector/v.transform/trans_digit.c
Log:
v.transform: flag to swap coordinates x,y


Modified: grass/trunk/vector/v.transform/local_proto.h
===================================================================
--- grass/trunk/vector/v.transform/local_proto.h	2011-01-10 11:12:49 UTC (rev 44928)
+++ grass/trunk/vector/v.transform/local_proto.h	2011-01-10 13:20:57 UTC (rev 44929)
@@ -21,4 +21,4 @@
 
 /* trans_digit.c */
 int transform_digit_file(struct Map_info *, struct Map_info *, int,
-			 double, double *, char *, char **, int);
+			 double, int, double *, char *, char **, int);

Modified: grass/trunk/vector/v.transform/main.c
===================================================================
--- grass/trunk/vector/v.transform/main.c	2011-01-10 11:12:49 UTC (rev 44928)
+++ grass/trunk/vector/v.transform/main.c	2011-01-10 13:20:57 UTC (rev 44929)
@@ -10,7 +10,7 @@
 * PURPOSE:      To transform a vector map's coordinates via a set of tie
 *               points.
 *
-* COPYRIGHT:    (C) 2002-2010 by the GRASS Development Team
+* COPYRIGHT:    (C) 2002-2011 by the GRASS Development Team
 *
 *               This program is free software under the GNU General Public
 *   	    	License (>=v2). Read the file COPYING that comes with GRASS
@@ -61,7 +61,7 @@
 
     struct Option *vold, *vnew, *pointsfile, *xshift, *yshift, *zshift,
 	*xscale, *yscale, *zscale, *zrot, *columns, *table, *field;
-    struct Flag *tozero_flag, *print_mat_flag;
+    struct Flag *tozero_flag, *print_mat_flag, *swap_flag;
 
     char mon[4], date[40], buf[1000];
     struct Map_info Old, New;
@@ -95,6 +95,11 @@
     print_mat_flag->description =
 	_("Print the transformation matrix to stdout");
     
+    swap_flag = G_define_flag();
+    swap_flag->key = 's';
+    swap_flag->description =
+	_("Swap coordinates x, y and then apply other parameters");
+    
     vold = G_define_standard_option(G_OPT_V_INPUT);
 
     field = G_define_standard_option(G_OPT_V_FIELD_ALL);
@@ -307,7 +312,7 @@
     trans_params[IDX_ZROT] = atof(zrot->answer);
 
     transform_digit_file(&Old, &New, Coord.name[0] ? 1 : 0,
-			 ztozero, trans_params,
+			 ztozero, swap_flag->answer, trans_params,
 			 table->answer, columns_name, Vect_get_field_number(&Old, field->answer));
 
     if (Vect_copy_tables(&Old, &New, 0))

Modified: grass/trunk/vector/v.transform/trans_digit.c
===================================================================
--- grass/trunk/vector/v.transform/trans_digit.c	2011-01-10 11:12:49 UTC (rev 44928)
+++ grass/trunk/vector/v.transform/trans_digit.c	2011-01-10 13:20:57 UTC (rev 44929)
@@ -29,7 +29,7 @@
 
 int
 transform_digit_file(struct Map_info *Old, struct Map_info *New,
-		     int shift_file, double ztozero, double *trans_params_def,
+		     int shift_file, double ztozero, int swap, double *trans_params_def,
 		     char *table, char **columns, int field)
 {
     int i, type, cat;
@@ -77,6 +77,14 @@
 	if (field != -1 && !Vect_cat_get(Cats, field, NULL))
 	    continue;
 	
+	if (swap) {
+	    for (i = 0; i < Points->n_points; i++) {
+		x = Points->x[i];
+		Points->x[i] = Points->y[i];
+		Points->y[i] = x;
+	    }
+	} 
+	
 	/* get transformation parameters */
 	if (table) {
 	    Vect_cat_get(Cats, field, &cat);	/* get first category */



More information about the grass-commit mailing list