[GRASS-SVN] r57765 - grass/branches/releasebranch_6_4/vector/v.transform

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Sep 20 16:13:49 PDT 2013


Author: hamish
Date: 2013-09-20 16:13:49 -0700 (Fri, 20 Sep 2013)
New Revision: 57765

Modified:
   grass/branches/releasebranch_6_4/vector/v.transform/local_proto.h
   grass/branches/releasebranch_6_4/vector/v.transform/main.c
   grass/branches/releasebranch_6_4/vector/v.transform/trans_digit.c
Log:
backport flag to swap coordinates x,y (merge from devbr6 r44930)

Modified: grass/branches/releasebranch_6_4/vector/v.transform/local_proto.h
===================================================================
--- grass/branches/releasebranch_6_4/vector/v.transform/local_proto.h	2013-09-20 14:59:09 UTC (rev 57764)
+++ grass/branches/releasebranch_6_4/vector/v.transform/local_proto.h	2013-09-20 23:13:49 UTC (rev 57765)
@@ -26,4 +26,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/branches/releasebranch_6_4/vector/v.transform/main.c
===================================================================
--- grass/branches/releasebranch_6_4/vector/v.transform/main.c	2013-09-20 14:59:09 UTC (rev 57764)
+++ grass/branches/releasebranch_6_4/vector/v.transform/main.c	2013-09-20 23:13:49 UTC (rev 57765)
@@ -10,7 +10,7 @@
 * PURPOSE:      To transform a vector map's coordinates via a set of tie
 *               points.
 *
-* COPYRIGHT:    (C) 2002-2007 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
@@ -50,8 +50,8 @@
 
     struct Option *vold, *vnew, *pointsfile, *xshift, *yshift, *zshift,
 	*xscale, *yscale, *zscale, *zrot, *columns, *table, *field;
-    struct Flag *quiet_flag, *tozero_flag, *shift_flag, *print_mat_flag;
-
+    struct Flag *quiet_flag, *tozero_flag, *shift_flag, *print_mat_flag, *swap_flag;
+    
     char *mapset, mon[4], date[40], buf[1000];
     struct Map_info Old, New;
     int ifield;
@@ -98,6 +98,11 @@
 	  "(xshift, yshift, zshift, xscale, yscale, zscale, zrot)");
     shift_flag->guisection = _("Custom");
 	
+    swap_flag = G_define_flag();
+    swap_flag->key = 'w';
+    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);
@@ -354,7 +359,7 @@
 
     /* do the transformation */
     transform_digit_file(&Old, &New, Coord.name[0] ? 1 : 0,
-			 ztozero, trans_params,
+			 ztozero, swap_flag->answer, trans_params,
 			 table->answer, columns_name, ifield);
 
     if (Vect_copy_tables(&Old, &New, 0))

Modified: grass/branches/releasebranch_6_4/vector/v.transform/trans_digit.c
===================================================================
--- grass/branches/releasebranch_6_4/vector/v.transform/trans_digit.c	2013-09-20 14:59:09 UTC (rev 57764)
+++ grass/branches/releasebranch_6_4/vector/v.transform/trans_digit.c	2013-09-20 23:13:49 UTC (rev 57765)
@@ -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, ret;
@@ -87,6 +87,14 @@
 	    break;
 	}
 
+	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 (field > 0) {
 	    Vect_cat_get(Cats, field, &cat);	/* get first category */



More information about the grass-commit mailing list